开发者

How to intercept server restart for GWT-based application?

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 t开发者_如何学Co register handler and define an action for such server events?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜