*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Unreferenced Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Unreferenced " Watch "Unreferenced " New topic
Author

Unreferenced

Dayanand Kangala
Greenhorn

Joined: Sep 09, 2002
Posts: 26
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
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Dayanand Kangala
Greenhorn

Joined: Sep 09, 2002
Posts: 26
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.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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
harcharan kanwal
Ranch Hand

Joined: Jul 02, 2001
Posts: 64
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
Dayanand Kangala
Greenhorn

Joined: Sep 09, 2002
Posts: 26
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");
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Now the object you have that implements Unreferenced is the Remote Connection object, correct? Not the object that is in the registry?
Mark
Dayanand Kangala
Greenhorn

Joined: Sep 09, 2002
Posts: 26
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.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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
 
 
subject: Unreferenced
 
Similar Threads
Implementin Unreferenced
NX:URlyBird 1.3.2/ A question for Database cache.
A small issue about unreferenced
Using Unreferenced vs a daemon thread
NX:Client crashed cause deadlock in LockManager