Shutting down the EJB application

How to add a shutdown box (like a JVM Shutdown Hook ) to listen (receive notification) when deploying an EJB / undeployed application (to stop JMX MServerBean)?

I could use ServletContextListener, unfortunately this is an EJB ATM.

+4
source share
2 answers

Use @Singleton bean and implement @PreDestroy :

 @Startup @Singleton public class HookBean { @PreDestroy void wholeApplicationShuttingDown { } } 

UPDATE: just noticed the ejb-3.0 tag. @Singleton was added in 3.1. But perhaps you will find it useful.

+7
source

Use a stand-alone Bean using the @PreDestroy method

0
source

All Articles