开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜