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)?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With