如何拦截基于 GWT 的应用程序的服务器重新启动?

发布于 2024-10-08 17:06:41 字数 233 浏览 0 评论 0原文

我开发的 Web 应用程序使用 GWT 作为客户端,使用 JCR (Jackrabbit) 来实现持久性。 Maven GWT 插件 (mvn gwt:run) 启动一些 UI,用于跟踪客户端和服务器之间的通信。此 UI 还提供了重新启动服务器的选项。

我想在服务器实际重新启动之前拦截服务器重新启动事件并执行一些操作,例如repository.shutdown()。

有没有办法注册处理程序并为此类服务器事件定义操作?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

悲欢浪云 2024-10-15 17:06:41

您可以实现ServletContextListener。 contextDestroyed() 方法将在上下文即将关闭时触发。

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

唔猫 2024-10-15 17:06:41

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

章节:3.6.1.2 销毁回调

解决方案:

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

我已将“close”方法添加到bean 类中,并在上下文xml 中将其指定为destroy-method。现在,当 Web 应用程序关闭/重新启动时,会调用此方法。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文