I\'m wondering how can I listen for Tomcat web application deployments. I would like to have my listener invoked every time an application is undeployed or deployed from/to
servlet context init/destroy
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletContextEvent;
public class AppContextListener implements ServletContextListener {
private static final Log logger = LogFactory.getLog(AppContextListener.class);
@Override
public void contextDestroyed(ServletContextEvent e) {
logger.warn("AppContext Delete: " + e.getServletContext().getContextPath());
}
@Override
public void contextInitialized(ServletContextEvent e) {
logger.warn("AppContext Create: " + e.getServletContext().getContextPath());
}
}
and put into tomcat/conf/web.xml
AppContextListener