From 7d085db87d98aa4aac5f549ec34c493bb43d724a Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Thu, 1 Mar 2012 20:41:27 -0800 Subject: [PATCH] CSPACE-4862: Needed to call post-init handlers AFTER tenant workspace folders get created. --- ...CollectionSpaceServiceContextListener.java | 13 +++++------ .../services/common/ServiceMain.java | 23 +++++-------------- 2 files changed, 12 insertions(+), 24 deletions(-) diff --git a/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java b/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java index 6d8628e13..b2ae6814c 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java +++ b/services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java @@ -3,11 +3,9 @@ */ package org.collectionspace.services.common; -import org.collectionspace.services.common.log.CollectionSpaceLog4jRepositorySelector; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; -import org.apache.log4j.LogManager; /** * CollectionSpaceServiceContextListener is a ServletContextListener that helps initialize @@ -18,11 +16,6 @@ public class CollectionSpaceServiceContextListener implements ServletContextList @Override public void contextInitialized(ServletContextEvent event) { try { - //create logging repository select to stop jboss from jamming - //our log on top of theirs -// LogManager.setRepositorySelector(new CollectionSpaceLog4jRepositorySelector(), -// null); - // // Initialize/start the Nuxeo EP server instance and create/retrieve the service workspaces // @@ -30,6 +23,12 @@ public class CollectionSpaceServiceContextListener implements ServletContextList ServiceMain svcMain = ServiceMain.getInstance(servletContext); svcMain.retrieveAllWorkspaceIds(); + // + // Invoke all post-initialization handlers, passing in a DataSource instance of the Nuxeo db. + // Typically, these handlers modify column types and add indexes to the Nuxeo db schema. + // + svcMain.firePostInitHandlers(); + } catch (Exception e) { e.printStackTrace(); //fail here diff --git a/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java b/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java index 8dbd7fe42..2151c31ca 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java @@ -14,7 +14,6 @@ import java.util.List; import java.util.UUID; import javax.naming.NamingException; -import javax.security.auth.login.LoginException; import javax.servlet.ServletContext; import javax.sql.DataSource; @@ -29,15 +28,11 @@ import org.collectionspace.services.common.storage.DatabaseProductType; import org.collectionspace.services.common.tenant.TenantBindingType; import org.collectionspace.services.common.types.PropertyItemType; import org.collectionspace.services.common.types.PropertyType; -import org.collectionspace.services.nuxeo.client.java.DocHandlerBase; -//import org.collectionspace.services.nuxeo.client.java.NuxeoConnector; -//import org.collectionspace.services.nuxeo.client.java.NxConnect; import org.collectionspace.services.nuxeo.client.java.NuxeoConnectorEmbedded; import org.collectionspace.services.nuxeo.client.java.TenantRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** * Main class for Services layer. It reads configuration and performs service * level initialization. It is a singleton. @@ -176,15 +171,6 @@ public class ServiceMain { throw new RuntimeException("Unknown CollectionSpace services client type: " + getClientType()); } - try { - // - // Invoke all post-initialization handlers, passing in a DataSource instance of the Nuxeo db. - // Typically, these handlers modify column types and add indexes to the Nuxeo db schema. - // - firePostInitHandlers(JDBCTools.getDataSource(JDBCTools.NUXEO_REPOSITORY_NAME)); - } catch(Exception e) { - logger.error("ServiceMain.initialize firePostInitHandlers failed on exception: " + e.getLocalizedMessage()); - } } /** @@ -614,7 +600,8 @@ public class ServiceMain { return TENANT_READER_ACCT_PREFIX+tenantName; } - private void firePostInitHandlers(DataSource dataSource) throws Exception { + public void firePostInitHandlers() throws Exception { + DataSource dataSource = JDBCTools.getDataSource(JDBCTools.NUXEO_REPOSITORY_NAME); Hashtable tenantBindingTypeMap = tenantBindingConfigReader.getTenantBindings(); //Loop through all tenants in tenant-bindings.xml for (TenantBindingType tbt: tenantBindingTypeMap.values()){ @@ -649,8 +636,10 @@ public class ServiceMain { } } - - public Object instantiate(String clazz, Class castTo) throws Exception { + /* + * A generic mechanism for instantiating a instance/object from a class name. + */ + public Object instantiate(String clazz, Class castTo) throws Exception { ClassLoader tccl = Thread.currentThread().getContextClassLoader(); clazz = clazz.trim(); Class c = tccl.loadClass(clazz); -- 2.47.3