Results 1 to 1 of 1
-
How to Shutdown the Spring IoC container gracefully in applications
When some Web Application Shut downs Spring's web-based ApplicationContext handles shutting down gracefully but for a non web application if you want the container to shutdown gracefully and call the relevant destroy callbacks on your singleton beans, you will need to register a shutdown hook with the JVM.
So for registering a shutdown hook that enables the graceful shutdown for the relevant Spring IoC container, we simply need to call the registerShutdownHook () method that is declared on the AbstractApplicationContext class.
Java Code:import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public final class Test { public static void main(final String[] args) throws Exception { AbstractApplicationContext ctx= new ClassPathXmlApplicationContext( new String []{"test.xml"}); ctx.registerShutdownHook(); // app runs here... // main method exits, hook is called prior to the app shutting down... } }
Similar Threads
-
How JDBC support is provided by Spring applications
By Java Tip in forum Java TipReplies: 0Last Post: 03-31-2008, 10:21 AM -
Container Managed Persistence
By Java Tip in forum Java TipReplies: 0Last Post: 12-27-2007, 10:16 AM -
Butterfly Container 1.9.9-beta
By JavaBean in forum Java SoftwareReplies: 0Last Post: 11-17-2007, 02:02 PM -
How JDBC support is provided by spring applications
By JavaBean in forum Java TipReplies: 0Last Post: 09-28-2007, 12:53 PM -
How to Shutdown the Spring IoC container gracefully in applications
By JavaBean in forum Java TipReplies: 0Last Post: 09-28-2007, 12:52 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks