[英]EJB application shutdown hook
How would i add a shutdown hook (just like the JVM Shutdown Hook ) to listen (get notification) when an EJB application is deployed/undeployed (to stop the JMX MServerBean)?当部署/取消部署 EJB 应用程序(以停止 JMX MServerBean)时,我将如何添加关闭挂钩(就像JVM 关闭挂钩)来侦听(获取通知)?
I could use a ServletContextListener, unfortunately this an EJB jar.我可以使用 ServletContextListener,不幸的是这是一个 EJB jar。
Use @Singleton
bean and implement @PreDestroy
:使用
@Singleton
bean 并实现@PreDestroy
:
@Startup
@Singleton
public class HookBean {
@PreDestroy
void wholeApplicationShuttingDown {
}
}
UPDATE: Just noticed ejb-3.0
tag.更新:刚刚注意到
ejb-3.0
标签。 @Singleton
was added in 3.1. @Singleton
是在 3.1 中添加的。 But still maybe you will find it useful.但也许你会发现它很有用。
使用带有@PreDestroy
方法的无状态 Bean
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.