Remove surplus code
[proteocache.git] / server / compbio / listeners / ContextListener.java
1 package compbio.listeners;
2
3 import java.util.concurrent.Executors;
4 import java.util.concurrent.ScheduledExecutorService;
5 import java.util.concurrent.TimeUnit;
6
7 import javax.servlet.ServletContextEvent;
8 import javax.servlet.ServletContextListener;
9 import javax.servlet.annotation.WebListener;
10
11 import compbio.cassandra.CassandraCreate;
12
13 /**
14  * Application Lifecycle Listener implementation class ContextListener
15  * 
16  */
17 @WebListener
18 public class ContextListener implements ServletContextListener {
19         private ScheduledExecutorService webjob_scheduler;
20         CassandraCreate cc = new CassandraCreate();
21
22         /**
23          * @see ServletContextListener#contextInitialized(ServletContextEvent)
24          */
25         public void contextInitialized(ServletContextEvent arg0) {
26                 System.out.println("ProteoCache session start......");
27                 cc.Connection();
28
29                 webjob_scheduler = Executors.newSingleThreadScheduledExecutor();
30                 webjob_scheduler.scheduleAtFixedRate(new Runnable() {
31                         @Override
32                         public void run() {
33                                 cc.Parsing("test");
34                         }
35                 }, 0, 60, TimeUnit.SECONDS);
36
37         }
38
39         /**
40          * @see ServletContextListener#contextDestroyed(ServletContextEvent)
41          */
42         public void contextDestroyed(ServletContextEvent arg0) {
43                 cc.Closing();
44                 System.out.println("Shut down ProteoCache......");
45                 webjob_scheduler.shutdownNow();
46         }
47
48 }