1 package org.collectionspace.services.jaxrs;
\r
3 import javax.servlet.ServletContextEvent;
\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
10 public class CSpaceResteasyBootstrap extends ResteasyBootstrap {
\r
12 public void contextInitialized(ServletContextEvent event) {
\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
19 if (currentTime % 1000 == 0) {
\r
20 System.out.print(".");
\r
22 currentTime = System.currentTimeMillis();
\r
23 } while (currentTime < stopTime);
\r
25 System.out.println();
\r
26 System.out.println("Resuming RESTEasy bootstrap initialization.");
\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
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
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