Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger function when Undeploying application

How do I automatically trigger Java function to stop Quartz scheduler jobs when I deploy/undeploy/redeploy JEE5 application in Glassfish.

like image 870
Maksim Avatar asked Mar 05 '26 08:03

Maksim


1 Answers

Implement ServletContextListener and hook on contextDestroyed().

Basic example:

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.
    }

}

and register it as a <listener> in web.xml.

<listener>
    <listener-class>com.example.Config</listener-class>
</listener>
like image 70
BalusC Avatar answered Mar 06 '26 23:03

BalusC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!