1 package org.collectionspace.services.jaxrs;
\r
3 import javax.servlet.ServletContext;
\r
4 import javax.servlet.ServletContextEvent;
\r
6 import org.jboss.resteasy.core.Dispatcher;
\r
7 import org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap;
\r
8 import org.collectionspace.services.common.ResourceMap;
\r
9 import org.collectionspace.services.common.ServiceMain;
\r
11 public class CSpaceResteasyBootstrap extends ResteasyBootstrap {
\r
13 // private static final String
\r
14 public void contextInitialized(ServletContextEvent event) {
\r
16 System.out.print("Pausing 1 seconds in RESTEasy bootstrap for you to attached the debugger");
\r
17 long startTime, currentTime;
\r
18 currentTime = startTime = System.currentTimeMillis();
\r
19 long stopTime = startTime + 1 * 1000; //5 seconds
\r
21 if (currentTime % 1000 == 0) {
\r
22 System.out.print(".");
\r
24 currentTime = System.currentTimeMillis();
\r
25 } while (currentTime < stopTime);
\r
27 System.out.println();
\r
28 System.out.println("Resuming RESTEasy bootstrap initialization.");
\r
31 // // Save a copy of the ServletContext inside our ServiceMain singleton
\r
32 // ServletContext servletContext = event.getServletContext();
\r
34 // ServiceMain.getInstance(servletContext); //First access causes initialization of the Services' main class
\r
35 // } catch (RuntimeException e) {
\r
36 // e.printStackTrace();
\r
37 // //rethrow the exception
\r
42 // This call to super instantiates and initializes our JAX-RS application class.
\r
43 // The application class is org.collectionspace.services.jaxrs.CollectionSpaceJaxRsApplication.
\r
45 super.contextInitialized(event);
\r
46 CollectionSpaceJaxRsApplication app =
\r
47 (CollectionSpaceJaxRsApplication)deployment.getApplication();
\r
48 Dispatcher disp = deployment.getDispatcher();
\r
49 disp.getDefaultContextObjects().put(ResourceMap.class, app.getResourceMap());
\r