How do you execute cleanup code on shutdown in Resin?

275 Views Asked by At

Is there a way to register a function in Resin so that it runs whenever Resin is shut down? I know you can init servlets on startup, but I need to make sure that all of my exec()'ed processes are terminated when the server is shutdown.

1

There are 1 best solutions below

0
On BEST ANSWER

Use a ServletContextListener to receive notifications about impending shutdown of a web application. You'll need to provide an implementation for the contextDestroyed method, where you can terminate your processes.

You can also use the ServletContextListener to perform any startup operations, via it's contextInitialized method.