Add still not-working code for the 2nd cassandra call
[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         //private ScheduledExecutorService localjob_scheduler;
21         CassandraCreate cc = new CassandraCreate();
22
23         /**
24          * @see ServletContextListener#contextInitialized(ServletContextEvent)
25          */
26         public void contextInitialized(ServletContextEvent arg0) {
27                 System.out.println("ProteoCache session start......");
28                 cc.Connection();
29
30                 webjob_scheduler = Executors.newSingleThreadScheduledExecutor();
31                 webjob_scheduler.scheduleAtFixedRate(new Runnable() {
32                         @Override
33                         public void run() {
34                                 cc.Parsing("http");
35                                 //cc.Parsing("file");
36                         }
37                 }, 0, 20, TimeUnit.SECONDS);
38 /*
39                 localjob_scheduler = Executors.newSingleThreadScheduledExecutor();
40                 localjob_scheduler.scheduleAtFixedRate(new Runnable() {
41                         @Override
42                         public void run() {
43                                 cc.Parsing("http");
44                                 //cc.Parsing("file");
45                         }
46                 }, 0, 20000, TimeUnit.SECONDS);
47 */
48         }
49
50         /**
51          * @see ServletContextListener#contextDestroyed(ServletContextEvent)
52          */
53         public void contextDestroyed(ServletContextEvent arg0) {
54                 cc.Closing();
55                 System.out.println("Shut down ProteoCache......");
56                 webjob_scheduler.shutdownNow();
57                 //localjob_scheduler.shutdownNow();
58         }
59
60 }