Question

I develop web-application which uses GWT for clients and JCR (Jackrabbit) for persistence. Maven GWT plug-in (mvn gwt:run) launches some UI where communication between clients and server is tracked. This UI also provides an option to restart the server.

I'd like to intercept server restart event and perform some actions like repository.shutdown() before server actually goes to restart.

Is there a way to register handler and define an action for such server events?

Was it helpful?

Solution 2

Spring documentation: http://static.springsource.org/spring/docs/3.0.x/reference/beans.html

Chapter: 3.6.1.2 Destruction callbacks

Solution:

<bean id="exampleInitBean" class="examples.ExampleBean" destroy-method="cleanup"/>

I have added "close" method to the bean class and specified it as destroy-method in context xml. Now this method is called when web-application goes to shutdown/restart.

OTHER TIPS

You can implement ServletContextListener. The contextDestroyed() method will trigger when the context is about to be shut down.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top