1 package compbio.listeners;
3 import java.io.IOException;
4 import java.util.concurrent.Executors;
5 import java.util.concurrent.ScheduledExecutorService;
6 import java.util.concurrent.TimeUnit;
8 import javax.servlet.ServletContextEvent;
9 import javax.servlet.ServletContextListener;
10 import javax.servlet.annotation.WebListener;
12 import compbio.cassandra.CassandraNativeConnector;
15 * Application Lifecycle Listener implementation class ContextListener
19 public class ContextListener implements ServletContextListener {
20 private ScheduledExecutorService webjob_scheduler;
21 CassandraNativeConnector db = new CassandraNativeConnector();
24 * @see ServletContextListener#contextInitialized(ServletContextEvent)
26 public void contextInitialized(ServletContextEvent arg0) {
27 System.out.println("ProteoCache session start......");
30 webjob_scheduler = Executors.newSingleThreadScheduledExecutor();
31 webjob_scheduler.scheduleAtFixedRate(new Runnable() {
36 } catch (IOException e) {
37 // TODO Auto-generated catch block
41 }, 0, 600, TimeUnit.SECONDS);
46 * @see ServletContextListener#contextDestroyed(ServletContextEvent)
48 public void contextDestroyed(ServletContextEvent arg0) {
50 System.out.println("Shut down ProteoCache......");
51 webjob_scheduler.shutdownNow();