java - Tomcat application deployment listener -


i'm wondering how can listen tomcat web application deployments. have listener invoked every time application undeployed or deployed from/to container.

i investigate bit , found out listeners, i.e. lifecyclelistener can registered on jmx. unfortunatelly listener ins't enough me since triggers events when engine/host/context in shutdown or startup process.

the same containerlistener informs container shutdown , startup events.

so, question is: which interface shall implement , how can register tomcat in order notified every time new application deployed?

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 tomcat/conf/web.xml

   <listener>      <listener-class>appcontextlistener</listener-class>    </listener> 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -