Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RMI: Creation of Remote Objects??

 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ken, thanks man. Your explanation helped me in understanding.
Appreciate it, thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic