dcsimg
How stubs work?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Halil_AKINCI
Posted On:   Monday, October 11, 2004 11:55 PM

Hi, Following code is part of a stub code that related to a simple addition application which is generated using j2sdk1.4.2 IDL. I want to ask questions about it. 1- Could anyone explain what are doing in this code? 2- What is the meaning of "$" and "_" prefixs in front of the variables (e.g., flaot $result) and methods (eg., _invoke($out) )? 3- What is "_invoke($out)" method doing in run-time? Sincerely... Halil ************************************************** public class _AdditionStub extends org.omg.CORBA.portable.ObjectImpl implements AdditionApp.Add {    More>>

Hi,



Following code is part of a stub code that related to a simple addition application which is generated using j2sdk1.4.2 IDL. I want to ask questions about it.



1- Could anyone explain what are doing in this code?



2- What is the meaning of "$" and "_" prefixs in front of the variables (e.g., flaot $result) and methods (eg., _invoke($out) )?



3- What is "_invoke($out)" method doing in run-time?




Sincerely...


Halil



**************************************************


			
public class _AdditionStub extends org.omg.CORBA.portable.ObjectImpl implements AdditionApp.Add {

public float add (float number1, float number2) {
org.omg.CORBA.portable.InputStream $in = null;
try {
org.omg.CORBA.portable.OutputStream $out = _request ("add", true);
$out.write_float (number1);
$out.write_float (number2);
$in = _invoke ($out);
float $result = $in.read_float ();
return $result;
} catch (org.omg.CORBA.portable.ApplicationException $ex) {
$in = $ex.getInputStream ();
String _id = $ex.getId ();
throw new org.omg.CORBA.MARSHAL (_id);
} catch (org.omg.CORBA.portable.RemarshalException $rm) {
return add (number1, number2);
} finally {
_releaseReply ($in);
}
} // add
...
...
...
} // public class
   <<Less

Re: How stubs work?

Posted By:   Anonymous  
Posted On:   Thursday, October 21, 2004 03:09 PM

>1- Could anyone explain what are doing in this code?


This code actually makes the request by marshalling the data (converting it from Java types to IIOP, a network protocol defined by the OMG) so it can be transferred. As you can see it puts the method name "add", then the two arguments to the stream and invokes the request, unmarshalls the return stream and returns the result.




>2- What is the meaning of "$" and "_" prefixs in front of >the variables (e.g., flaot $result) and methods (eg., >_invoke($out) )?



These are simply variable naming conventions. The "_" is usually for a class variable, and the $ is used for variables declared in a method.



>3- What is "_invoke($out)" method doing in run-time?



This issues a request to the distributed object.

About | Sitemap | Contact