This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hello everyone, I have not been able to figure out how to gracefully shut the RMI-based server down. I want to do this so that I can close my database file properly when exiting the server. What is a good way to shut down an RMI server so that resources can be released? What are the issues here? Thanks!
Jeff Wisard<br />Sun Certified Java Programmer (Java 2)<br />Sun Certified Web Component Developer
Hi Jeff, I have not seen any way of shutting down the RMI Server programatically. I think the best you can do is derigister your own services, and check that no other services have been registered. They do a System.exit(). Regards, Andrew
Hey guys, I have always been a fan of shutdown hooks to gracefully handle shutdowns in these types of cases. From memory it is something along the lines of: Runtime localVM = Runtime.getRuntime(); localVM.addShutdownHook(cleanupThread ); cleanupThread is a inner class extending thread. All your cleanup and graceful shutdown code is in the run method. Even if you control-C to shutdown your server it will still run the shutdown hook. regards, Matt