]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-4862: Needed to call post-init handlers AFTER tenant workspace folders get...
authorRichard Millet <remillet@berkeley.edu>
Fri, 2 Mar 2012 04:41:27 +0000 (20:41 -0800)
committerRichard Millet <remillet@berkeley.edu>
Fri, 2 Mar 2012 04:41:27 +0000 (20:41 -0800)
services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceServiceContextListener.java
services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java

index 6d8628e1313043096e9023e41962b60875833a05..b2ae6814c4175b70c1ea03bb4ae7ff2962c77aa2 100644 (file)
@@ -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
index 8dbd7fe4240ebd7dde4ceeb0517dc91cc854ccd8..2151c31ca703df565ed705bba628f84c692f9e4f 100644 (file)
@@ -14,7 +14,6 @@ import java.util.List;
 import java.util.UUID;\r
 \r
 import javax.naming.NamingException;\r
-import javax.security.auth.login.LoginException;\r
 import javax.servlet.ServletContext;\r
 import javax.sql.DataSource;\r
 \r
@@ -29,15 +28,11 @@ import org.collectionspace.services.common.storage.DatabaseProductType;
 import org.collectionspace.services.common.tenant.TenantBindingType;\r
 import org.collectionspace.services.common.types.PropertyItemType;\r
 import org.collectionspace.services.common.types.PropertyType;\r
-import org.collectionspace.services.nuxeo.client.java.DocHandlerBase;\r
-//import org.collectionspace.services.nuxeo.client.java.NuxeoConnector;\r
-//import org.collectionspace.services.nuxeo.client.java.NxConnect;\r
 import org.collectionspace.services.nuxeo.client.java.NuxeoConnectorEmbedded;\r
 import org.collectionspace.services.nuxeo.client.java.TenantRepository;\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
 \r
-\r
 /**\r
  * Main class for Services layer. It reads configuration and performs service\r
  * level initialization. It is a singleton.\r
@@ -176,15 +171,6 @@ public class ServiceMain {
                throw new RuntimeException("Unknown CollectionSpace services client type: " + getClientType());\r
         }\r
 \r
-        try {\r
-               //\r
-               // Invoke all post-initialization handlers, passing in a DataSource instance of the Nuxeo db.\r
-               // Typically, these handlers modify column types and add indexes to the Nuxeo db schema.\r
-               //\r
-            firePostInitHandlers(JDBCTools.getDataSource(JDBCTools.NUXEO_REPOSITORY_NAME));\r
-        } catch(Exception e) {\r
-            logger.error("ServiceMain.initialize firePostInitHandlers failed on exception: " + e.getLocalizedMessage());\r
-        }\r
     }\r
 \r
     /**\r
@@ -614,7 +600,8 @@ public class ServiceMain {
        return TENANT_READER_ACCT_PREFIX+tenantName;\r
     }\r
 \r
-    private void firePostInitHandlers(DataSource dataSource) throws Exception {\r
+    public void firePostInitHandlers() throws Exception {\r
+       DataSource dataSource = JDBCTools.getDataSource(JDBCTools.NUXEO_REPOSITORY_NAME);\r
         Hashtable<String, TenantBindingType> tenantBindingTypeMap = tenantBindingConfigReader.getTenantBindings();\r
         //Loop through all tenants in tenant-bindings.xml\r
         for (TenantBindingType tbt: tenantBindingTypeMap.values()){\r
@@ -649,8 +636,10 @@ public class ServiceMain {
         }\r
     }\r
 \r
-\r
-    public Object instantiate(String clazz, Class castTo) throws Exception {\r
+    /*\r
+     * A generic mechanism for instantiating a instance/object from a class name.\r
+     */\r
+    public Object instantiate(String clazz, Class<?> castTo) throws Exception {\r
         ClassLoader tccl = Thread.currentThread().getContextClassLoader();\r
         clazz = clazz.trim();\r
         Class<?> c = tccl.loadClass(clazz);\r