This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
I don't have much experience with RMI, so I have a dumb question: In the Registry interface of RMI is the "unbind(String name)" method used to disconnect a client from a server without shutting the server down? Would this be the way to swap between remote servers for a client, or swap between standalone and remote modes? If I swap between modes, I don't want to shut the server down until the user shuts it down. I guess I would just do a rebind to get an RMI connection back to the desired server?
The unbind method is designed to be used on the server side - it removes the specified method from the registry of methods that can be called remotely. If the 'force' parameter is false, this will only remove the specified method from the registry - it will not disconnect any currently connected clients.
From the client side, if you wanted to change servers, all you need do is remove your current reference to the remote method (set it to null) and do a lookup for an alternate method and/or on an alternate server (or implicitly do both at once by just setting your reference to the new looked up value, which will automatically make your old value eligible for garbage collection).
I believe it is better to explicitly set the reference to the remote method to null, then call the garbage collector. This will result in the distributed garbage collector knowing that the client has disconnected earlier, which means that Unreferenced and/or WeakHashMap code can be called earlier. But this is all dependant on the operations of the garbage collector and the distributed garbage collector, which, as we know, is all a black box and cannot be relied on. So this is just a technicality.