| CONTENTS | PREV | NEXT | Java Remote Method Invocation |
Unreferenced Interface
package java.rmi.server;public interface Unreferenced { public void unreferenced(); }
Thejava.rmi.server.Unreferencedinterface allows a server object to receive notification that there are no clients holding remote references to it. The distributed garbage collection mechanism maintains for each remote object, the set of client virtual machines that hold references to that remote object. As long as some client holds a remote reference to the remote object, the RMI runtime keeps a local reference to the remote object. Each time the remote object's "reference" set becomes empty (meaning that the number of clients that reference the object becomes zero), theUnreferenced.unreferencedmethod is invoked (if that remote object implements theUnreferencedinterface). A remote object is not required to support theUnreferencedinterface.As long as some local reference to the remote object exists, it may be passed in remote calls or returned to clients. The process that receives the reference is added to the reference set for the remote object. When the reference set becomes empty, the remote object's
unreferencedmethod will be invoked. As such, theunreferencedmethod can be called more than once (each time the set is newly emptied). Remote objects are only collected when no more references, either local references or those held by clients, still exist.