wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: (Contractors) server shutdown and file close 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 "NX: (Contractors) server shutdown and file close" Watch "NX: (Contractors) server shutdown and file close" New topic
Author

NX: (Contractors) server shutdown and file close

Jeff Wisard
Ranch Hand

Joined: Jan 07, 2002
Posts: 89
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
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

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


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Matt Rea
Greenhorn

Joined: Apr 22, 2003
Posts: 28
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
Vitaly Zhuravlyov
Greenhorn

Joined: Apr 11, 2003
Posts: 16
I did not think that the Shutdown Hook is not well-known. You can use something like this.

This feature is available since JDK 1.3
Vitaly
Jeff Wisard
Ranch Hand

Joined: Jan 07, 2002
Posts: 89
Wow! Very cool! I didn't know about this.
Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX: (Contractors) server shutdown and file close
 
Similar Threads
Running RMI on NT server
FBN: Closing the database in Network mode.
How to stop rmi server?
close the file on the server
Shutdown Server Properly?