File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: Connection Factory for RMI 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: Connection Factory for RMI" Watch "NX: Connection Factory for RMI" New topic

NX: Connection Factory for RMI

John Canavan

Joined: Aug 17, 2003
Posts: 29
Hi all,
I just would like to check something regarding the creation of a connection factory which I intend to use in my implementation.
In Max’s book, as part of the RMI, he does not create a new DVDDatabase object for each client, instead the one instance is shared for all clients that connect to the server. If this implementation was to be changed to use a factory so that each client would receive a DVDDatabase object, would the following changes implement it – it is just a brief overview.
1. An interface e.g. Factory would be created which would extend Remote. A method something like getDVDDatabase() would be included to return a new DVDDatabase object, the method would throw a RemoteException.
2. A FactoryImpl would be created to implement Factory and it would extend UnicastRemoteObject.
3. Instead of registering the DVDDatabaseImpl as the remote object as Max does in his book (as shown below – taken from…

…..the FactoryImpl() would be the only remote object registered.

4. The getRemote() in Max’s would look something like as follows…

5. The stub files for the DVDDatabaseImpl and FactoryImpl would still have to be created as methods will be called from the client on both of these remotely.
Is this the general idea?
Bharat Ruparel
Ranch Hand

Joined: Jul 30, 2003
Posts: 493
Hello John
Take a look at the following thread:
Rmi question
Andrew has done a wonderful job of explaining the Connection Factory concept in the most basic terms.

Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11777

Hi John
Yes, that is the general idea.
But you should be aware that there may be other issues with thread safety which may require changes to other classes from Max's design.
Regards, Andrew

The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
John Canavan

Joined: Aug 17, 2003
Posts: 29
Hi Bharat and Andrew,
Thanks for your comments. I am going to have a look through some of the threads on creating the RMI connection factory, so I may have some questions depending on what I have read!
I agree. Here's the link:
subject: NX: Connection Factory for RMI
It's not a secret anymore!