wood burning stoves
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX:RMI Easy Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX:RMI Easy Question " Watch "NX:RMI Easy Question " New topic

NX:RMI Easy Question

Tony Collins
Ranch Hand

Joined: Jul 03, 2003
Posts: 435
Can anyone tell me how and when the RMI System creates a new instance of DatabaseImpl on the Server side. Max's book seems to create a DatabaseImpl on the client side and binds it to a name, then uses the naming lookup sevice to get a reference to this object on the server???
Am I right in saying the DVDAdapter is not created on the client but on the server when the naming service is used ?
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Creating an instance on the server isn't about the Naming Service.
The naming service is like a directory structure. It can hold objects and other information. So if you bind an object into the registry, it is already a created instance.
Now you can have two different kind of objects resiing on the server. One that would be bound to the registry, and one that is just a Remote object that the Remote JVM handles and is not bound to the registry.
So in you server code you will create the instance of the DataImpl class and then bind that instance to the registry.
But better yet, you will have a ConnectionFactory that instantiated in the server code and passed a reference to the instance of the DataImpl. This factory is what is looked up by the client. You then call a method like getConnection(). This will create a new instance of a Connection Object, that will act as a Remote object uniquely for the client. It will be a one to one relationship between a client and the server.
Good Luck and I hope that helps answer your question.

Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Tony Collins
Ranch Hand

Joined: Jul 03, 2003
Posts: 435
oh sorry, Max's book confused me as the Server and client were on the same JVM.
I agree. Here's the link: http://aspose.com/file-tools
subject: NX:RMI Easy Question
It's not a secret anymore!