aspose file tools*
The moose likes Distributed Java and the fly likes Can remote object be automatically unexported? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Can remote object be automatically unexported?" Watch "Can remote object be automatically unexported?" New topic
Author

Can remote object be automatically unexported?

Aleksander Zielinski
Ranch Hand

Joined: Nov 11, 2005
Posts: 127
Hi everybody,

I have a factory that produces remote objects (lets call it RO), I keep a Set of these ROs in the factory so when I stop the server I am able to unexport them all.

RO implements Unreferenced interface so when it crashes or simply exits its unreferenced() method will let know the factory that it can unexport this object and remove it from the Set.

The UnicastRemoteObject.unexportObject method throws NoSuchObjectException, and my question is, is there any possibility (other than the remote object is unreferenced) that object can be removed from table by rmi or any other reason? Object should be unexported when rmi finds out that the remote object is no longer referenced, what about if client would connect and do nothing for 3 days or something? Is this situation possible? Now everything works fine, but I'm not sure how should I handle that exception, because I'm not sure what can cause the object to be removed from the table. I wonder if I should close the server entirely if this happens.

Any comments would be really appreciated.
Edward Harned
Ranch Hand

Joined: Sep 19, 2005
Posts: 291

You're asking a general question so you'll probably get many different responses. Here's mine.

I don't use unreferenced(). My server(s) are available whenever a client needs them. It's none of my business if a client doesn't call for three days. If I need to save resources on a low volume server, then I use the Activatable RMI.

It's nice to unexport a server when it exits. But I don't get excited about not doing it. I always use rebind, never bind. That takes care of the crash problem. If unexport throws a not-found, I just ignore it.


Ed's latest article: A Java Parallel Calamity http://coopsoft.com/ar/Calamity2Article.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can remote object be automatically unexported?
 
Similar Threads
FBNX: Locking, clientID and deadlock...
Using Unreferenced vs a daemon thread
NX:URlyBird 1.3.2/ A question for Database cache.
here I am again - one more time with unreferenced problems
Clean unexport with RMI. Server side