EJB application shutdown hook
How would i add a shutdown hook (just like the JVM Shutdown Hoo开发者_运维百科k) to listen (get notification) when an EJB application is deployed/undeployed (to stop the JMX MServerBean)?
I could use a ServletContextListener, unfortunately this an EJB jar.
Use @Singleton
bean and implement @PreDestroy
:
@Startup
@Singleton
public class HookBean {
@PreDestroy
void wholeApplicationShuttingDown {
}
}
UPDATE: Just noticed ejb-3.0
tag. @Singleton
was added in 3.1. But still maybe you will find it useful.
Use a Stateless Bean with a @PreDestroy
method
精彩评论