wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: RMI implemention question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: RMI implemention question" Watch "NX: RMI implemention question" New topic

NX: RMI implemention question

Jeff Wisard
Ranch Hand

Joined: Jan 07, 2002
Posts: 89
In my implementation of the Contractors, I want to ensure that each client instance gets its own instance of the RemoteDataImpl running on the server. That is, if there are 3 clients, three instances of RemoteDataImpl will be created.
I was planning on making this happen by creating a RemoteDataFactory interface (extends Remote). The factory would then be responsible for creating a new instance of RemoteDataImpl to send back to the client. Something has confused me though. Do I implicitly create RemoteDataImpl objects by 'new'ing them? Or do I need to look up a RemoteDataImpl in the RMI Registry and return that?
I guess I am not sure of the semantics of either situation. If I 'new' the RemoteDataImpl, does the RMI system automatically just send the stub to the client? Also, if I get the instance from the RMI Registry, does that create a new instance?

Jeff Wisard<br />Sun Certified Java Programmer (Java 2)<br />Sun Certified Web Component Developer
Jeff Wisard
Ranch Hand

Joined: Jan 07, 2002
Posts: 89
Nevermind...I had a momentary lapse of reason. For those interested:

This does exactly what I need.
Jeff Wisard
Ranch Hand

Joined: Jan 07, 2002
Posts: 89
New question, though. When the client has exited or no longer needs the reference to the remote object returned via the factory, does the remote implementation instance get garbage collected?
frank sun
Ranch Hand

Joined: Apr 11, 2003
Posts: 102
Perhaps you could replace your HashMap with WeakHashMap, the later could clean the object if no reference.
I also got one question about the RMI design, how to keep the RMI factory service running always(we cannot run the RMI factory service by : java package.rmifactoryclass,we start it from another class), and what's the better approach to stop the service do you think?
I agree. Here's the link: http://aspose.com/file-tools
subject: NX: RMI implemention question
Similar Threads
FBN: Closing the database in Network mode.
Can multiple servers share one RMI Registry?
Questions of Max's example , plus registry.rebind().
About RemoteData and RemoteDataFactory, need your help
"Serving" Remote Objects