aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RMI: Creation of Remote Objects?? 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 » Developer Certification (SCJD/OCMJD)
Bookmark "RMI: Creation of Remote Objects?? " Watch "RMI: Creation of Remote Objects?? " New topic
Author

RMI: Creation of Remote Objects??

Satish Avadhanam
Ranch Hand

Joined: Aug 12, 2003
Posts: 697
Hi all,
I have trouble understanding the concept of creation of remote objects. Please help me in understanding, thanks.
I will try to ask showing the code from Max's book sample project. The first one is the class where we register the remote object to RMI registry.

The second class is the DVDConnector class.

In the getRemote() method DVDConnector class, we are returning DVDDatabaseImpl that is registered with the name DVDMediator(in RMI Registry) in the RegDVDDatabase class. Does this registering of object done for each remote client or is it done only once?
If its done only once then all remote clients have access to the same DVDDatabaseImpl object, right?
Or though registering is done only once, RMI serves each remote client with a different object of DVDDatabaseImpl class?
I know this is a fundamental question, but I could not understand it.
Appreciate your help, thanks.
[ February 19, 2004: Message edited by: Satish Avadhanam ]
Ken Krebs
Ranch Hand

Joined: Nov 27, 2002
Posts: 451
Satish,

In the getRemote() method DVDConnector class, we are returning DVDDatabaseImpl that is registered with the name DVDMediator(in RMI Registry) in the RegDVDDatabase class. Does this registering of object done for each remote client or is it done only once?

The RMI server object itself is registered once, when it is bound into the registry via code like Naming.rebind("DVDMediator", aDVD).

If its done only once then all remote clients have access to the same DVDDatabaseImpl object, right?

Yes.

Or though registering is done only once, RMI serves each remote client with a different object of DVDDatabaseImpl class?

Each client has an object to work with that is local to its JVM. That object is an instance of the rmic generated RMI stub class. It acts as a proxy for the remote server object. Therefore, each client is working with the original server object, but only indirectly through the proxy.
I hope that clarifies things for you.
[ February 19, 2004: Message edited by: Ken Krebs ]

kktec<br />SCJP, SCWCD, SCJD<br />"What we observe is not nature itself, but nature exposed to our method of questioning." - Werner Heisenberg
Satish Avadhanam
Ranch Hand

Joined: Aug 12, 2003
Posts: 697
Hi Ken, thanks man. Your explanation helped me in understanding.
Appreciate it, thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RMI: Creation of Remote Objects??