取消部署应用程序时的触发功能

Mak*_*sim 3 java glassfish quartz-scheduler

在 Glassfish 中部署/取消部署/重新部署 JEE5 应用程序时,如何自动触发 Java 功能以停止 Quartz 调度程序作业。

Bal*_*usC 5

实施ServletContextListener并挂上contextDestroyed().

基本示例:

public class Config implements ServletContextListener {

    public void contextInitialized(ServletContextEvent event) {
        // Write code here which should be executed on webapp startup.
    }

    public void contextDestroyed(ServletContextEvent event) {
        // Write code here which should be executed on webapp shutdown.
    }

}
Run Code Online (Sandbox Code Playgroud)

并将其注册为<listener>in web.xml

public class Config implements ServletContextListener {

    public void contextInitialized(ServletContextEvent event) {
        // Write code here which should be executed on webapp startup.
    }

    public void contextDestroyed(ServletContextEvent event) {
        // Write code here which should be executed on webapp shutdown.
    }

}
Run Code Online (Sandbox Code Playgroud)