File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes HELP - Larry the rodent bites 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 "HELP - Larry the rodent bites" Watch "HELP - Larry the rodent bites" New topic

HELP - Larry the rodent bites

Mag Hoehme
Ranch Hand

Joined: Apr 07, 2002
Posts: 194
I've designed a nice Connection Server, which is registered with a well-known address and dishes out a remote Data Access object to everyone who asks its getConnection() method. And all this works fine...
I donated my ConnectionServer a command that prints out the current number of active connections. And this works fine, too - and helped me to see the following problem: If Larry the rodent and his kumpel Rudi bite the cable (or - what has the same effect -if the user presses Ctrl-C to kill the VM whein which the client is running), the remote DataAccess object does not say good-bye.
So, if my application is running for a longer time, and if the users are not well-behaved (they do not take the exit door but simply kill the VM to leave their clients), then my server is getting congested with shadow DataAccess objects that no longer have a counterpart at the other end of the line.
Here are some solutions I can think of:
  • Don't do anything about this (no hear - no see - no speak).
  • Tell the users they must no use Ctrl-C on the VM, and in case they do, they should tell the Systems Admin (or alternatively let the examiner know that you are aware of this problem but you did not implement a solution for it)
  • Have the connection polling the client whether it's still alive (uaarrgh)
  • Do not let the client have a connection but let it send Joblets to the server (quite elegant).
  • I've also checked custom sockets - but this would only help to implement the polling solution.

  • Any comments on how to address this problem in the context of the SCJD exam is welcomed!!!

    Michael Morris
    Ranch Hand

    Joined: Jan 30, 2002
    Posts: 3451
    Hi Mag,
    Or just implement Unreferenced.
    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
    Mag Hoehme
    Ranch Hand

    Joined: Apr 07, 2002
    Posts: 194
    Thank you Michael -
    unreferenced did help.
    I agree. Here's the link:
    subject: HELP - Larry the rodent bites
    It's not a secret anymore!