⌂ Catalog
⇦
Previous section 13 - Template
⇨
Next section 15 - Formula
server web context start or shutdown will run java class bean.
WebSystemCtxBeanSupportListener will auto create bean( ContextInitializedAndDestroyedBean ) and call execute(ServletContextEvent event)
method for INITIALIZE or DESTROY.
You must first understand the following framework
- ServletContextListener https://tomcat.apache.org/tomcat-8.0-doc/servletapi/javax/servlet/ServletContextListener.html
The class need extends ContextInitializedAndDestroyedBean
Example:
public class CleanTempUploadForContextInitAndDestroy extends ContextInitializedAndDestroyedBean {
private static final long serialVersionUID = 5017459384696932226L;
@Override
public void execute(ServletContextEvent event) throws Exception {
// do something ...
}
}
And need restart tomcat server to effective
Name | return | description |
---|---|---|
execute(ServletContextEvent event) | void | do event function, WebSystemCtxBeanSupportListener will call it |