Originally posted by Sean Lee:
I think when DBFactory create a Connection for a client, there's a object created and run in the server. when client closing itself, I should inform the server to close the Connection object. am i right? yes, I know i should call a Connection's close method to do that. but how?
Calling close() is not the problem. It's just a
Java method call and isn't obviously different from any ordinary method call (well, it may throw RemoteException, but that's it).
The only sensible thing the server-side implementation of close() might do is clean up any remaining locks held by the client.
I may understand your problem though: what happens to the Connection object itself? Like the method call, that isn't much different from what happens normally. RMI features a distributed garbage collector (DGC) which finds out that the client has released all references to your Connection, or exited altogether which boils down to the same thing. If the Connection implements Unreferenced, the unreferenced method is called. In any case, if you don't keep any further server-side references to the Connection, it will become eligible for garbage collection and ultimately be cleaned up.
In other words, beyond implementing a sensible close() method you don't have to anything.
Does that clarify things?
- Peter
[ January 04, 2003: Message edited by: Peter den Haan ]