To do some work when we forcly stop the web server (wildfly,tomcat etc.)
We need to create a cleanup class which extends ContextCleanupListener which is provided from spring 3+.
Follow the below steps to do some cleanup during server being stopped.
Step-1 Create the cleanup class ApplicationCleanUpListener.java
Step-2
put these lines to web.xml
We need to create a cleanup class which extends ContextCleanupListener which is provided from spring 3+.
Follow the below steps to do some cleanup during server being stopped.
Step-1 Create the cleanup class ApplicationCleanUpListener.java
package com.test;
import org.springframework.web.context.ContextCleanupListener;
import javax.servlet.ServletContextEvent;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class ApplicationCleanUpListener extends ContextCleanupListener {
@Override
public void contextDestroyed(ServletContextEvent event) {
//do some cleanup task
System.out.print("Server is shutting down.....");
}
}
Step-2
put these lines to web.xml
com.test.ApplicationCleanUpListener

0 Comments