This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Aaaaaaarrghhhhhh I'm trying to unbind my connection factory, so I can stop client accessing the Server while I re-cache the Database. Though I'm having problems, I receive the ExportError Exception: ObjID Already in use when I try to create the registry for the second time. My code is as Follows
So is there anyway of un-creating the registry once it's created, without quiting the application ? Or have people just quit the application if they want rid of the RMI connection, which to me seems a bit rubbish. Any help would be appreciated ? Tony
Joined: Jul 03, 2003
Looking through the Sun developers forum the only way to stop the RMI registry is to exit the main thread. Why I don't know ? So restarting the Server progrmatically seems to be a little difficult and I would think not worth the hassle. I wonder if all entrys in the registry are deleted when it is stoped via exit. Tony
Hi Tony, In your case, I think all you need to do is unbind() your remote object from the registry. You can leave the registry running while you re-cache the database. Any client that then tries to get a reference to your remote object will fail. This should meet your requirements. Alternatively: don't try to code for this at all . After all, there is no requirement to re-cache the database. It has also been mentioned quite a few times in this forum that it does not appear to be programattically possible to shut down the registry. I would guess that this is because of complexity / security reasons. You would presumably need the registry to listen on some other "administration" port for commands such as shutting down the registry. You would probably want to password protect it (so it cannot be shut down by a malicious user). You would probably want some command to just disable new registrations first, before removing existing registrations. You would probably want to have some way of notifying existing clients that their registrations is being removed. And so on. I think the only thing you can do is just exit() your main application which will shut down the registry. If you wanted to be nice you could check if anyone else has registered with your registry first, and display a warning message if that does happen. (But since most people don't set up the security necessary for other applications to register with their registry, I guess this can't happen anyway, so you might also wan't to skip it). Regards, Andrew