2 * Copyright 2009 University of California at Berkeley
4 package org.collectionspace.services.common;
6 import javax.servlet.ServletContext;
7 import javax.servlet.ServletContextEvent;
8 import javax.servlet.ServletContextListener;
11 * CollectionSpaceServiceContextListener is a ServletContextListener that helps initialize
12 * the services layer at deployment and undeployment times
14 public class CollectionSpaceServiceContextListener implements ServletContextListener {
17 public void contextInitialized(ServletContextEvent event) {
20 // Initialize/start the Nuxeo EP server instance and create/retrieve the service workspaces
22 ServletContext servletContext = event.getServletContext();
23 ServiceMain svcMain = ServiceMain.getInstance(servletContext);
25 svcMain.retrieveAllWorkspaceIds();
28 // Invoke all post-initialization handlers, passing in a DataSource instance of the Nuxeo db.
29 // Typically, these handlers modify column types and add indexes to the Nuxeo db schema.
31 svcMain.firePostInitHandlers();
33 } catch (Throwable e) {
36 System.err.println("[ERROR] The CollectionSpace Services could not initialize. Please see the log files for details.");
37 throw new RuntimeException(e);
42 public void contextDestroyed(ServletContextEvent event) {
43 //ServiceMain.getInstance().release();