• Post Reply Bookmark Topic Watch Topic
  • New Topic

pass by value/reference in Corba?

 
Frank Wu
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused about the parameter pass mechanisim in corba? Is it pass by value or by reference?
Some article said: It is pass by value for regular objects, it is pass by reference for those interface objects.
If this is the case, why the hell do we need IN or OUT modifier in the method definition?
Thanks,
John
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember that CORBA is multi-language. The IN, OUT or INOUT associated with a parameter is a language-independent way of saying what will be done with a parameter of an operation. How that translates to a particular language is a feature of that language's CORBA binding.
For Java, all method parameters are pass by value. But remember that variables in Java cannot be objects, they can only be object references. The object references are passed by value. This means that a Java method can change the content of the object pointed to by one of its parameters, but cannot change that parameter to point to a different object.
Since Java passes all parameters by value, it cannot do CORBA OUT or INOUT parameters directly. To get around this, the Java CORBA binding introduces holder classes, which are little classes that wrap an object reference. For example, CarHolder would be the holder class for CORBA Car objects. The holder object is passed into the Java method; its content can be changed (see above).
 
Doug Wang
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Peter. You have given a excellent explanation for this topic.
There is another pair of concepts often confusing people -- object-by-value and object-by-reference. It is said object-by-value will be writen into CORBA3.0. I know that OMG creates a new construct called valuetype for this new feature. And also object-by-value may be used in parameter passing.
Could you give further explanation on that?
[ January 30, 2002: Message edited by: Doug Wang ]
 
Morten Moeller
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some ORBs can be setup to "cheat" for performance reasons, but I'm sure that isn't really legal.
Like webspheres ORB can be setup to pass by reference on local transactions.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!