File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can remote object be automatically unexported?

 
Aleksander Zielinski
Ranch Hand
Posts: 127
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 291
Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic