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();
27 // Create required indexes (aka indices) in tables not associated
28 // with any specific tenant.
29 svcMain.createRequiredIndices();
31 // Invoke all post-initialization handlers, passing in a DataSource instance of the Nuxeo db.
32 // Typically, these handlers modify column types and add indexes to the Nuxeo db schema.
34 svcMain.firePostInitHandlers();
36 } catch (Throwable e) {
39 System.err.println("[ERROR] The CollectionSpace Services could not initialize. Please see the log files for details.");
40 throw new RuntimeException(e);
45 public void contextDestroyed(ServletContextEvent event) {
46 //ServiceMain.getInstance().release();