开发者

EJB application shutdown hook

开发者 https://www.devze.com 2023-04-09 16:54 出处:网络
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)?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消