Actually i have the requirement to execute a method which takes hours to complete on every machine reboot.I have deployed my web application on apache tomcat and i have enabled automatic start of Apache tomcat.For this I have called a method in ServletContextListener contextInitialized in a simple java class.Now my doubt is does the method called in contextInitialized will be executed each time the machine reboots.
Here is my ServletContextListener implemented class..
public class Startup implements ServletContextListener {
@Override
public void contextDestroyed(ServletContextEvent sce) {
}
public void contextInitialized(ServletContextEvent sce) {
// Do your startup work here
System.out.println("Started....");
//captureCDRProcess();
new Thread(new Runnable() {
@Override
public void run() {
captureCDRProcess();
}
}).start();
}
and this is my web.xml..
<listener>
<listener-class>org.myapp.Startup</listener-class>
</listener>
Please guys help me .. Thanks in advance...
have deployed my web application on apache tomcat and i have enabled automatic start of Apache tomcat.
Yes , for each start of Tomcat , ServletContextListener
's contextInitialized
method invokes.