File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Unreferenced Interface, 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 Interface," Watch "Unreferenced Interface," New topic
Author

Unreferenced Interface,

Sam Stackly
Ranch Hand

Joined: May 04, 2002
Posts: 109
Hi Guys,
Do we need to implemet Unreferenced interface for our remote object? and why?
Thanks in advance
Sam
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Sam,
Well it depends on whether or not and how you plan to deal with stale clients. Read through (you can actually skip most of it and do a search from your browser for unreferenced) this post and you decide if you need to implement it:
Long Thread on Locking
Hope this helps,
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Sam Stackly
Ranch Hand

Joined: May 04, 2002
Posts: 109
Michael,
The way I did clean the dead client is different.

I create a nested class inside of LockManager to hold objectID, recordNum and the time it received the lock and I have Vector to store or remove that kind of object during lock and unlock, I also create a daemon thread running every 2 second and check if there is any expired object is in Vector then it will clean the dead client and unlock that record too.
how do you feel about it ? is that the right design
Regards
Sam
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Sam,
It's OK to do it that way, I know that many have taken a similar approach. A couple of points though:
  • Implementing Unreferenced is a no-brainer
  • Using a roll-your-own timeout assumes something that may not be true, ie the client may just be taking its own sweet time


  • But I don't think you'll lose any points for dealing with stale clients in this manner.
    Hope this helps,
    Michael Morris
    Mark Spritzler
    ranger
    Sheriff

    Joined: Feb 05, 2001
    Posts: 17250
        
        6

    Sam, I'd suggest you use ArrayList instead of Vector.
    Vector and HashTable is considered the old collections, whereas ArrayList and HashSet are par tof the newer collections objects, the are more light-weight than the older versions.
    Mark


    Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
    How to Ask Questions the Smart Way FAQ
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Unreferenced Interface,