Can my remote object obtain notification when there are no live references to it?

Govind Seshadri

Yes, you can enable remote objects to get notified as soon as there are no valid references to it. Although the distributed garbage collection mechanism takes care of memory management issues, explicit notification can help the remote server release valuable resources like network and database connections immediately.

Any remote object that implements java.rmi.server.Unreferenced interface can get immediate notification via the unreferenced() method as soon as the server does not have any valid references to it. The following code snippet demonstrates how:

public class RemoteServerImpl extends UnicastRemoteObject implements 
          MyRemoteInterface, Unreferenced {

          public RemoteServerImpl() {
            super();
            . . .
            //allocate resources
         }

         . . .
         public void unreferenced() {
            //deallocate resources here
         }
}
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact