• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Pass by value and Pass by reference

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,

can one please clarify my doubts regarding my post.\

thanks in advance,
kumar
 
MyExamCloud Support
Posts: 267
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 4012
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4012
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
[email protected]
 
cloclo sisi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
[email protected]
 
cloclo sisi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...I have to precise that 'IIOP' means 'RMI-IIOP'...sorry
Claude
reply
    Bookmark Topic Watch Topic
  • New Topic