]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
69962a8e5724f3c44f2139129b13966112c49aa5
[tmp/jakarta-migration.git] /
1 package org.collectionspace.services.jaxrs;\r
2 \r
3 import javax.servlet.ServletContextEvent;\r
4 \r
5 import org.jboss.resteasy.core.Dispatcher;\r
6 import org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap;\r
7 import org.collectionspace.services.common.ResourceMap;\r
8 import org.collectionspace.services.common.ServiceMain;\r
9 \r
10 public class CSpaceResteasyBootstrap extends ResteasyBootstrap {\r
11         \r
12         public void  contextInitialized(ServletContextEvent event) {\r
13         if (true) {\r
14                 System.out.print("Pausing 1 seconds in RESTEasy bootstrap for you to attached the debugger");\r
15                 long startTime, currentTime;\r
16                 currentTime = startTime = System.currentTimeMillis();\r
17                 long stopTime = startTime + 1 * 1000; //5 seconds\r
18                 do {\r
19                         if (currentTime % 1000 == 0) {\r
20                                 System.out.print(".");\r
21                         }\r
22                         currentTime = System.currentTimeMillis();\r
23                 } while (currentTime < stopTime);\r
24                         \r
25                 System.out.println();\r
26                 System.out.println("Resuming RESTEasy bootstrap initialization.");\r
27         }\r
28                                 \r
29                 //\r
30         // This call to super instantiates and initializes our JAX-RS application class.\r
31         // The application class is org.collectionspace.services.jaxrs.CollectionSpaceJaxRsApplication.\r
32         //\r
33         System.out.println("[INFO] Starting up the CollectionSpace Services' JAX-RS application.");\r
34                 super.contextInitialized(event);\r
35                 CollectionSpaceJaxRsApplication app = \r
36                         (CollectionSpaceJaxRsApplication)deployment.getApplication();\r
37                 Dispatcher disp = deployment.getDispatcher();\r
38                 disp.getDefaultContextObjects().put(ResourceMap.class, app.getResourceMap());\r
39                 System.out.println("[INFO] CollectionSpace Services' JAX-RS application started.");\r
40         }\r
41         \r
42     @Override\r
43     public void contextDestroyed(ServletContextEvent event) {\r
44         System.out.println("[INFO] Shutting down the CollectionSpace Services' JAX-RS application.");\r
45         //Do something if needed.\r
46         System.out.println("[INFO] CollectionSpace Services' JAX-RS application stopped.");\r
47     }   \r
48 \r
49 }\r