This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Dear All, I have a doubt in the way unreferenced interface works. Can someone clear it? I understood that the DGC maintains a reference count for each client invoking a method on the remote object. When the count becomes zero, then the unreferenced() method is invoked. I wrote a remoteobject and implemented the unreferenced interface with a system.out.println() in the unreferenced() method - just to find out whether the method is getting called ! I accessed the remoteobject from a client application and then closed the application. But, even after 15 minutes the system.out.println() is not getting invoked! Is this because the DGC does not increment the reference counter if the remoteobject is accessed from the local machine?! (the above is not as per the requirement stated in the intructions.html). Regards, Dayanand
Originally posted by Mark Spritzler: Unreferenced runs after 15 minutes. That is the default wait time. When you closed the app, instead of it dying, I think it closed cleanly and cleaned up the Remote Object for you. Mark
Hi, I ran the client application (in win 2000) from command prompt and closed the command prompt instead of selecting the close icon from the application. But, this did not trigger the method after 15 mins (I went out and came back after 60 minutes, but no system.out.println). Can you tell me a way to crash the client!! (or)trigger the unreferenced method. Dayanand.
Interesting. I know this a stupid question, and I am sure it is, but the Server is still running in a seperate Command window, correct? I think closing the command window is a "Crash" and should work. What are you printing out? Mark
hi i read in the rmi forum at java.sun.com that registry will be holding the reference to a client and acting as a client,eventhough the client is crashed.may be we have to run the registry in the separate console window and shut this console window running registry and the one running the client, to invoke the unreferenced method.need to do more research on it http://forum.java.sun.com/thread.jsp?forum=58&thread=172926
Joined: Sep 09, 2002
Originally posted by Mark Spritzler: Interesting. ...but the Server is still running in a seperate Command window, correct?
Yes. The server is running in another console.
I think closing the command window is a "Crash" and should work. What are you printing out?
I have the following line: system.out.println(" unreferenced method invoked");
Now the object you have that implements Unreferenced is the Remote Connection object, correct? Not the object that is in the registry? Mark
Joined: Sep 09, 2002
Originally posted by Mark Spritzler: Interesting.
Another interesting detail !! I got really curious as to how the DGC works. So, started reading about how the DGC tracks the client and maintains the reference count for every remotedata that is accessed... I also tried to log using remoteserver.setLog() method... It was when doing this I noticed that the "System.out.println()" is getting called !! the following is what is happening: (a) I have a getconnection() method which returns the remotedata object to the client. (b) the client uses this data object to perform all operations of searching (c) As soon as this object is returned to the client, the unreferenced method is getting called!! How could be happening? Dayanand.
It sounds more like the Connection Object is not correctly a Remote Object. It must extend Remote and UnicastRemoteObject. So to do this you have your DataAccess interface extend Remote, and the Remote implementation extend UnicastRemoteObject, and this Remote implementation is not registered in the RMI Registry. Hope that helps Mark