aspose file tools*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Pass by value and Pass by reference Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Pass by value and Pass by reference" Watch "Pass by value and Pass by reference" New topic
Author

Pass by value and Pass by reference

kumar as
Ranch Hand

Joined: Mar 16, 2006
Posts: 36
Hi all,

I am on the way of preparing SCEA part I , I have one question regarding pass by value and pass by reference ?

My question is RMI supports pass by value but CORBA does'nt , what it meant to say.
Another question is RMI use stub download (it it happnes to EJB too) can any one clarify my doubts or give me the related document?

thanks in advance
kumar
kumar as
Ranch Hand

Joined: Mar 16, 2006
Posts: 36
hi all,

can one please clarify my doubts regarding my post.\

thanks in advance,
kumar
Ganesan Ponnusamy
EPractice Labs Support
Ranch Hand

Joined: Nov 07, 2005
Posts: 249
CORBA architecture depends on an Object Request Broker (ORB) and ORB acts as a central Object Bus over which each CORBA object interacts transparently with other CORBA objects located either locally or remotely.
Each CORBA server object has an interface and exposes a set of methods. To request a service, a CORBA client acquires an object reference to a CORBA server object. The client can now make method calls on the object reference as if the CORBA server object resided in the client's address space. The ORB is responsible for finding a CORBA object's implementation, preparing it to receive requests, communicate requests to it and carry the reply back to the client. A CORBA object interacts with the ORB either through the ORB interface or through an Object Adapter - either a Basic Object Adapter (BOA) or a Portable Object Adapter (POA).



Java/RMI relies on a protocol called the Java Remote Method Protocol (JRMP). Java relies heavily on Java Object Serialization, which allows objects to be marshaled (or transmitted) as a stream. Since Java Object Serialization is specific to Java, both the Java/RMI server object and the client object have to be written in Java. Each Java/RMI Server object defines an interface which can be used to access the server object outside of the current Java Virtual Machine(JVM) and on another machine's JVM. The interface exposes a set of methods which are indicative of the services offered by the server object. For a client to locate a server object for the first time, RMI depends on a naming mechanism called an RMIRegistry that runs on the Server machine and holds information about available Server Objects. A Java/RMI client acquires an object reference to a Java/RMI server object by doing a lookup for a Server Object reference and invokes methods on the Server Object as if the Java/RMI server object resided in the client's address space.

Reference from http://my.execpc.com/~gopalan/misc/compare.html

Regards
Ganesan
http://www.epractizelabs.com


Ganesan Ponnusamy Java Certification | Test Generator | OCAJP | OCPJP | OCEJWSD | EJB Certification
OCEJPAD | SCJD | SCWCD | SCBCD | SCDJWS | OCMJEA | Web Services Certification | SCMAD
Jeff Belisle
Ranch Hand

Joined: Jun 11, 2006
Posts: 39
A Note on Remote Method Invocation (RMI)

When passing parameters to remote methods, things get a bit more complex. First, we're (usually) dealing with passing data between two independent virtual machines, which might be on separate physical machines as well. Passing the value of a pointer wouldn't do any good, as the target virtual machine doesn't have access to the caller's heap.

You'll often hear "pass by value" and "pass by reference" used with respect to RMI. These terms have more of a "logical" meaning, and really aren't correct for the intended use.

Here's what is usually meant by these phrases with regard to RMI. Note that this is not proper usage of "pass by value" and "pass by reference" semantics:

RMI Pass-by-value

The actual parameter is serialized and passed using a network protocol to the target remote object. Serialization essentially "squeezes" the data out of an object/primitive. On the receiving end, that data is used to build a "clone" of the original object or primitive. Note that this process can be rather expensive if the actual parameters point to large objects (or large graphs of objects).
This isn't quite the right use of "pass-by-value"; I think it should really be called something like "pass-by-memento". (See "Design Patterns" by Gamma et al for a description of the Memento pattern).

RMI Pass-by-reference

The actual parameter, which is itself a remote object, is represented by a proxy. The proxy keeps track of where the actual parameter lives, and anytime the target method uses the formal parameter, another remote method invocation occurs to "call back" to the actual parameter. This can be useful if the actual parameter points to a large object (or graph of objects) and there are few call backs.
This isn't quite the right use of "pass-by-reference" (again, you cannot change the actual parameter itself). I think it should be called something like "pass-by-proxy". (Again, see "Design Patterns" for descriptions of the Proxy pattern).


<a href="http://<b rel="nofollow">http://java.sys-con.com/read/35848.htm</b>" target="_blank">http://java.sys-con.com/read/35848.htm

Some other non-CORBA compliant Object Request Brokers also support passing objects by value. For example, in Remote Method Invocation (RMI), objects are categorized as either local or remote at the time the object is implemented. This is done by implementing the Java interface java.rmi.Remote to indicate that an object is remote. All other objects are treated as local objects. When determining what argument passing policy to use, RMI depends on these categories. Remote objects are passed by reference, while local objects are passed by value.
[ July 25, 2006: Message edited by: My First My Last ]
kumar as
Ranch Hand

Joined: Mar 16, 2006
Posts: 36
I got the concept from ur reply as follow

Pass By Value :- Copy of object is just transferred across JVM's by Serialization .Now the client can work on that copy .But here the disadvantage is the larger object will reduce performance.RMI uses this technic.

Pass By Reference:- stub dispatches the method call, the client ORB converts the request, including all parameters, into a standardized byte format, in this case IIOP. The request is then sent out on the wire to the server ORB , here the server ORB converts the request call to actual Object .Here the real object resides only on one JVM that is only on server side.RMI-IIOP uses this tecnology , If RMI-IIOP wants to go for Pass By Value then corresponding ORB should support this technic.

But I confused with STUB download in RMI? have any one have any idea on this.
Jeff Belisle
Ranch Hand

Joined: Jun 11, 2006
Posts: 39
In RMI there are two things you need at the cilent side to run it:
1. Remote interface to make remote method calls and compile your client
2. At run time client needs remote object's stubs in order to marshall/unmarshall and do other JRMP stuff befind the scene for you. (stubs/skel are generated by RMIC at server side)

To solve #2 you have two options
1.) Make available a jar file from server to the client.
2.) If Client is unknown you may enable a dynamic downloading at the server to make stubs available only at the runtime, just like an applet codebase.

For more details:
http://java.sun.com/j2se/1.4.2/docs/guide/rmi/codebase.html
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
Greetings "My First My Last", welcome to Javaranch!

Could you please take a minute to change your display name to one that meets the famous Javaranch Naming Policy? We appreciate it, thanks.


Hope you enjoy hanging out at the ranch,
Pauline
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
Hello "SCEA.L1", otherwise known as "Jeff", that's not quite it, as you probably know (since reading instructions is such an important part of passing exams.)

We're a friendly bunch around here, but we take the naming policy seriously. You are risking having your account blocked.

Pauline
Jeff Belisle
Ranch Hand

Joined: Jun 11, 2006
Posts: 39
Pauline,
I am now using my real name but I am not sure if its good enough for this forum. If not please feel free to block me and I will be happy to take my business elsewhere. My only intention to join this forum was to share information of course both ways. Looks like people are getting fussy over nothing.

best regards
-Jeff
cloclo sisi
Greenhorn

Joined: Mar 08, 2006
Posts: 5
Hello,
According to http://my.execpc.com/~gopalan/misc/compare.html things are a little more subtle.
-----------------------------Arguments----------------------------

| Passed-by-reference | Passed-by-value
-------------------------------------------------------------------
CORBA | yes: if it's an IF | Yes: if objects and not IFs
IIOP | yes: not sure | No: not sure
Java/RMI | yes: if extends Remorte IF | yes: if doesn't extend Remote
-------------------------------------------------------------------

Could anybody agree or disagree...
Thanks

Claude
charles_magnes@hotmail.com
cloclo sisi
Greenhorn

Joined: Mar 08, 2006
Posts: 5
Better presented :-)

Hello,
According to http://my.execpc.com/~gopalan/misc/compare.html things are a little more subtle.
-----------------------------Arguments----------------------------

.........|.......Passed-by-reference..|..Passed-by-value
-------------------------------------------------------------------
CORBA....|.yes:.if it's an IF.........|..Yes: if objects and not IFs
IIOP.....|.yes:.not sure..............|..No: not sure
Java/RMI.|.yes:.if extends Remorte IF.|..yes: if doesn't extend Remote
-------------------------------------------------------------------

Could anybody agree or disagree...
Thanks

Claude
charles_magnes@hotmail.com
cloclo sisi
Greenhorn

Joined: Mar 08, 2006
Posts: 5
...I have to precise that 'IIOP' means 'RMI-IIOP'...sorry
Claude
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pass by value and Pass by reference