manifoldcf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1377435 [1/2] - in /manifoldcf/trunk: ./ framework/agents/src/main/java/org/apache/manifoldcf/agents/system/ framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/ framework/api-servlet/src/main/java/org/apache/manifoldcf/api/ ...
Date Sun, 26 Aug 2012 13:37:47 GMT
Author: kwright
Date: Sun Aug 26 13:37:45 2012
New Revision: 1377435

URL: http://svn.apache.org/viewvc?rev=1377435&view=rev
Log:
Fix for CONNECTORS-514.  Refactor how environment management model can be used so that multiple entities can readily coexist in the same VM.

Modified:
    manifoldcf/trunk/CHANGES.txt
    manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/ManifoldCF.java
    manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseDerby.java
    manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseHSQLDB.java
    manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseHSQLDBext.java
    manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseMySQL.java
    manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BasePostgresql.java
    manifoldcf/trunk/framework/api-servlet/src/main/java/org/apache/manifoldcf/api/APIServlet.java
    manifoldcf/trunk/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservice/servlet/UserACLServlet.java
    manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java
    manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java
    manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java
    manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ServletListener.java
    manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/Base.java
    manifoldcf/trunk/framework/crawler-ui/src/main/webapp/adminDefaults.jsp
    manifoldcf/trunk/framework/crawler-ui/src/main/webapp/adminHeaders.jsp
    manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/ManifoldCF.java
    manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/CrawlerAgent.java
    manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseDerby.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseHSQLDB.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseHSQLDBext.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseMySQL.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BasePostgresql.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ConnectorBaseDerby.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ConnectorBaseHSQLDB.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ConnectorBaseHSQLDBext.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ConnectorBaseMySQL.java
    manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ConnectorBasePostgresql.java
    manifoldcf/trunk/tests/alfresco/build.xml
    manifoldcf/trunk/tests/jcifs/build.xml

Modified: manifoldcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Sun Aug 26 13:37:45 2012
@@ -3,6 +3,11 @@ $Id$
 
 ======================= 0.7-dev =====================
 
+CONNECTORS-514: Revamp ManifoldCF.initializeEnvironment and
+ManifoldCF.cleanUpEnvironment to use reference counting so that more
+than one user of these methods can coexist in the same VM.
+(Karl Wright)
+
 CONNECTORS-512: Revise documentation to include new access-
 method pulldown and corresponding screen shot.
 (Karl Wright)

Modified: manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/ManifoldCF.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/ManifoldCF.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/ManifoldCF.java (original)
+++ manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/ManifoldCF.java Sun Aug 26 13:37:45 2012
@@ -42,12 +42,32 @@ public class ManifoldCF extends org.apac
   {
     synchronized (initializeFlagLock)
     {
+      // Do core initialization
+      org.apache.manifoldcf.core.system.ManifoldCF.initializeEnvironment();
+      // Local initialization
+      org.apache.manifoldcf.agents.system.ManifoldCF.localInitialize();
+    }
+  }
+
+  /** Clean up environment.
+  */
+  public static void cleanUpEnvironment()
+  {
+    synchronized (initializeFlagLock)
+    {
+      org.apache.manifoldcf.agents.system.ManifoldCF.localCleanup();
+      org.apache.manifoldcf.core.system.ManifoldCF.cleanUpEnvironment();
+    }
+  }
+  
+  public static void localInitialize()
+    throws ManifoldCFException
+  {
+    synchronized (initializeFlagLock)
+    {
       if (agentsInitialized)
         return;
 
-      // Do core initialization
-      org.apache.manifoldcf.core.system.ManifoldCF.initializeEnvironment();
-      
       // Create the shutdown hook for agents.  All activity will be keyed off of runningHash, so it is safe to do this under all conditions.
       org.apache.manifoldcf.core.system.ManifoldCF.addShutdownHook(new AgentsShutdownHook());
       
@@ -58,14 +78,21 @@ public class ManifoldCF extends org.apac
     }
   }
 
+  public static void localCleanup()
+  {
+  }
+  
   /** Reset the environment.
   */
   public static void resetEnvironment()
   {
-    org.apache.manifoldcf.core.system.ManifoldCF.resetEnvironment();
-    synchronized (runningHash)
+    synchronized (initializeFlagLock)
     {
-      stopAgentsRun = false;
+      org.apache.manifoldcf.core.system.ManifoldCF.resetEnvironment();
+      synchronized (runningHash)
+      {
+        stopAgentsRun = false;
+      }
     }
   }
 

Modified: manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseDerby.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseDerby.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseDerby.java (original)
+++ manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseDerby.java Sun Aug 26 13:37:45 2012
@@ -34,9 +34,10 @@ public class BaseDerby extends org.apach
   public void setUp()
     throws Exception
   {
+    initializeSystem();
     try
     {
-      localCleanUp();
+      localReset();
     }
     catch (Exception e)
     {
@@ -58,9 +59,6 @@ public class BaseDerby extends org.apach
   {
     super.localSetUp();
     
-    // Install the agents tables
-    initialize();
-    ManifoldCF.initializeEnvironment();
     IThreadContext tc = ThreadContextFactory.make();
     ManifoldCF.installTables(tc);
   }
@@ -78,41 +76,49 @@ public class BaseDerby extends org.apach
       e.printStackTrace();
       throw e;
     }
+    cleanupSystem();
   }
 
   protected void localCleanUp()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
-    {
-      // Test the uninstall
-      ManifoldCF.initializeEnvironment();
-      IThreadContext tc = ThreadContextFactory.make();
+    IThreadContext tc = ThreadContextFactory.make();
       
-      Exception currentException = null;
-      try
-      {
-        ManifoldCF.deinstallTables(tc);
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
-      try
-      {
-        super.localCleanUp();
-        ManifoldCF.resetEnvironment();
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
+    Exception currentException = null;
+    try
+    {
+      ManifoldCF.deinstallTables(tc);
+    }
+    catch (Exception e)
+    {
       if (currentException != null)
-        throw currentException;
+        currentException = e;
+    }
+    try
+    {
+      super.localCleanUp();
     }
+    catch (Exception e)
+    {
+      if (currentException != null)
+        currentException = e;
+    }
+    if (currentException != null)
+      throw currentException;
   }
   
+  protected void initializeSystem()
+    throws Exception
+  {
+    super.initializeSystem();
+    org.apache.manifoldcf.agents.system.ManifoldCF.localInitialize();
+  }
+  
+  protected void cleanupSystem()
+    throws Exception
+  {
+    org.apache.manifoldcf.agents.system.ManifoldCF.localCleanup();
+    super.cleanupSystem();
+  }
+
 }

Modified: manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseHSQLDB.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseHSQLDB.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseHSQLDB.java (original)
+++ manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseHSQLDB.java Sun Aug 26 13:37:45 2012
@@ -34,9 +34,10 @@ public class BaseHSQLDB extends org.apac
   public void setUp()
     throws Exception
   {
+    initializeSystem();
     try
     {
-      localCleanUp();
+      localReset();
     }
     catch (Exception e)
     {
@@ -58,9 +59,6 @@ public class BaseHSQLDB extends org.apac
   {
     super.localSetUp();
     
-    // Install the agents tables
-    initialize();
-    ManifoldCF.initializeEnvironment();
     IThreadContext tc = ThreadContextFactory.make();
     ManifoldCF.installTables(tc);
   }
@@ -78,41 +76,49 @@ public class BaseHSQLDB extends org.apac
       e.printStackTrace();
       throw e;
     }
+    cleanupSystem();
   }
 
   protected void localCleanUp()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
-    {
-      // Test the uninstall
-      ManifoldCF.initializeEnvironment();
-      IThreadContext tc = ThreadContextFactory.make();
+    IThreadContext tc = ThreadContextFactory.make();
       
-      Exception currentException = null;
-      try
-      {
-        ManifoldCF.deinstallTables(tc);
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
-      try
-      {
-        super.localCleanUp();
-        ManifoldCF.resetEnvironment();
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
+    Exception currentException = null;
+    try
+    {
+      ManifoldCF.deinstallTables(tc);
+    }
+    catch (Exception e)
+    {
       if (currentException != null)
-        throw currentException;
+        currentException = e;
+    }
+    try
+    {
+      super.localCleanUp();
     }
+    catch (Exception e)
+    {
+      if (currentException != null)
+        currentException = e;
+    }
+    if (currentException != null)
+      throw currentException;
+  }
+
+  protected void initializeSystem()
+    throws Exception
+  {
+    super.initializeSystem();
+    org.apache.manifoldcf.agents.system.ManifoldCF.localInitialize();
   }
   
+  protected void cleanupSystem()
+    throws Exception
+  {
+    org.apache.manifoldcf.agents.system.ManifoldCF.localCleanup();
+    super.cleanupSystem();
+  }
+
 }

Modified: manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseHSQLDBext.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseHSQLDBext.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseHSQLDBext.java (original)
+++ manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseHSQLDBext.java Sun Aug 26 13:37:45 2012
@@ -34,9 +34,10 @@ public class BaseHSQLDBext extends org.a
   public void setUp()
     throws Exception
   {
+    initializeSystem();
     try
     {
-      localCleanUp();
+      localReset();
     }
     catch (Exception e)
     {
@@ -60,7 +61,7 @@ public class BaseHSQLDBext extends org.a
     
     // Install the agents tables
     initialize();
-    ManifoldCF.initializeEnvironment();
+    //ManifoldCF.initializeEnvironment();
     IThreadContext tc = ThreadContextFactory.make();
     ManifoldCF.installTables(tc);
   }
@@ -78,41 +79,49 @@ public class BaseHSQLDBext extends org.a
       e.printStackTrace();
       throw e;
     }
+    cleanupSystem();
   }
 
   protected void localCleanUp()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
-    {
-      // Test the uninstall
-      ManifoldCF.initializeEnvironment();
-      IThreadContext tc = ThreadContextFactory.make();
+    IThreadContext tc = ThreadContextFactory.make();
       
-      Exception currentException = null;
-      try
-      {
-        ManifoldCF.deinstallTables(tc);
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
-      try
-      {
-        super.localCleanUp();
-        ManifoldCF.resetEnvironment();
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
+    Exception currentException = null;
+    try
+    {
+      ManifoldCF.deinstallTables(tc);
+    }
+    catch (Exception e)
+    {
+      if (currentException != null)
+        currentException = e;
+    }
+    try
+    {
+      super.localCleanUp();
+    }
+    catch (Exception e)
+    {
       if (currentException != null)
-        throw currentException;
+        currentException = e;
     }
+    if (currentException != null)
+      throw currentException;
+  }
+  
+  protected void initializeSystem()
+    throws Exception
+  {
+    super.initializeSystem();
+    org.apache.manifoldcf.agents.system.ManifoldCF.localInitialize();
+  }
+  
+  protected void cleanupSystem()
+    throws Exception
+  {
+    org.apache.manifoldcf.agents.system.ManifoldCF.localCleanup();
+    super.cleanupSystem();
   }
   
 }

Modified: manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseMySQL.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseMySQL.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseMySQL.java (original)
+++ manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BaseMySQL.java Sun Aug 26 13:37:45 2012
@@ -34,9 +34,10 @@ public class BaseMySQL extends org.apach
   public void setUp()
     throws Exception
   {
+    initializeSystem();
     try
     {
-      localCleanUp();
+      localReset();
     }
     catch (Exception e)
     {
@@ -58,9 +59,6 @@ public class BaseMySQL extends org.apach
   {
     super.localSetUp();
     
-    // Install the agents tables
-    initialize();
-    ManifoldCF.initializeEnvironment();
     IThreadContext tc = ThreadContextFactory.make();
     ManifoldCF.installTables(tc);
   }
@@ -78,41 +76,49 @@ public class BaseMySQL extends org.apach
       e.printStackTrace();
       throw e;
     }
+    cleanupSystem();
   }
 
   protected void localCleanUp()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
-    {
-      // Test the uninstall
-      ManifoldCF.initializeEnvironment();
-      IThreadContext tc = ThreadContextFactory.make();
+    IThreadContext tc = ThreadContextFactory.make();
       
-      Exception currentException = null;
-      try
-      {
-        ManifoldCF.deinstallTables(tc);
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
-      try
-      {
-        super.localCleanUp();
-        ManifoldCF.resetEnvironment();
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
+    Exception currentException = null;
+    try
+    {
+      ManifoldCF.deinstallTables(tc);
+    }
+    catch (Exception e)
+    {
       if (currentException != null)
-        throw currentException;
+        currentException = e;
+    }
+    try
+    {
+      super.localCleanUp();
     }
+    catch (Exception e)
+    {
+      if (currentException != null)
+        currentException = e;
+    }
+    if (currentException != null)
+      throw currentException;
   }
   
+  protected void initializeSystem()
+    throws Exception
+  {
+    super.initializeSystem();
+    org.apache.manifoldcf.agents.system.ManifoldCF.localInitialize();
+  }
+  
+  protected void cleanupSystem()
+    throws Exception
+  {
+    org.apache.manifoldcf.agents.system.ManifoldCF.localCleanup();
+    super.cleanupSystem();
+  }
+
 }

Modified: manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BasePostgresql.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BasePostgresql.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BasePostgresql.java (original)
+++ manifoldcf/trunk/framework/agents/src/test/java/org/apache/manifoldcf/agents/tests/BasePostgresql.java Sun Aug 26 13:37:45 2012
@@ -34,9 +34,10 @@ public class BasePostgresql extends org.
   public void setUp()
     throws Exception
   {
+    initializeSystem();
     try
     {
-      localCleanUp();
+      localReset();
     }
     catch (Exception e)
     {
@@ -58,9 +59,6 @@ public class BasePostgresql extends org.
   {
     super.localSetUp();
     
-    // Install the agents tables
-    initialize();
-    ManifoldCF.initializeEnvironment();
     IThreadContext tc = ThreadContextFactory.make();
     ManifoldCF.installTables(tc);
   }
@@ -78,41 +76,49 @@ public class BasePostgresql extends org.
       e.printStackTrace();
       throw e;
     }
+    cleanupSystem();
   }
 
   protected void localCleanUp()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
-    {
-      // Test the uninstall
-      ManifoldCF.initializeEnvironment();
-      IThreadContext tc = ThreadContextFactory.make();
+    IThreadContext tc = ThreadContextFactory.make();
       
-      Exception currentException = null;
-      try
-      {
-        ManifoldCF.deinstallTables(tc);
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
-      try
-      {
-        super.localCleanUp();
-        ManifoldCF.resetEnvironment();
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
+    Exception currentException = null;
+    try
+    {
+      ManifoldCF.deinstallTables(tc);
+    }
+    catch (Exception e)
+    {
       if (currentException != null)
-        throw currentException;
+        currentException = e;
+    }
+    try
+    {
+      super.localCleanUp();
     }
+    catch (Exception e)
+    {
+      if (currentException != null)
+        currentException = e;
+    }
+    if (currentException != null)
+      throw currentException;
   }
   
+  protected void initializeSystem()
+    throws Exception
+  {
+    super.initializeSystem();
+    org.apache.manifoldcf.agents.system.ManifoldCF.localInitialize();
+  }
+  
+  protected void cleanupSystem()
+    throws Exception
+  {
+    org.apache.manifoldcf.agents.system.ManifoldCF.localCleanup();
+    super.cleanupSystem();
+  }
+
 }

Modified: manifoldcf/trunk/framework/api-servlet/src/main/java/org/apache/manifoldcf/api/APIServlet.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/api-servlet/src/main/java/org/apache/manifoldcf/api/APIServlet.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/api-servlet/src/main/java/org/apache/manifoldcf/api/APIServlet.java (original)
+++ manifoldcf/trunk/framework/api-servlet/src/main/java/org/apache/manifoldcf/api/APIServlet.java Sun Aug 26 13:37:45 2012
@@ -43,6 +43,7 @@ public class APIServlet extends HttpServ
     throws ServletException
   {
     super.init(config);
+/*
     try
     {
       // Set up the environment
@@ -54,13 +55,14 @@ public class APIServlet extends HttpServ
       Logging.misc.error("Error starting API service: "+e.getMessage(),e);
       throw new ServletException("Error starting API service: "+e.getMessage(),e);
     }
-
+*/
   }
 
   /** The destroy method.
   */
   public void destroy()
   {
+/*
     try
     {
       // Set up the environment
@@ -71,6 +73,7 @@ public class APIServlet extends HttpServ
     {
       Logging.misc.error("Error shutting down API service: "+e.getMessage(),e);
     }
+*/
     super.destroy();
   }
 
@@ -82,7 +85,7 @@ public class APIServlet extends HttpServ
     try
     {
       // Set up the environment
-      ManifoldCF.initializeEnvironment();
+      //ManifoldCF.initializeEnvironment();
 
       // Mint a thread context
       IThreadContext tc = ThreadContextFactory.make();
@@ -116,7 +119,7 @@ public class APIServlet extends HttpServ
     try
     {
       // Set up the environment
-      ManifoldCF.initializeEnvironment();
+      //ManifoldCF.initializeEnvironment();
 
       // Mint a thread context
       IThreadContext tc = ThreadContextFactory.make();
@@ -159,7 +162,7 @@ public class APIServlet extends HttpServ
     try
     {
       // Set up the environment
-      ManifoldCF.initializeEnvironment();
+      //ManifoldCF.initializeEnvironment();
 
       // Mint a thread context
       IThreadContext tc = ThreadContextFactory.make();
@@ -202,7 +205,7 @@ public class APIServlet extends HttpServ
     try
     {
       // Set up the environment
-      ManifoldCF.initializeEnvironment();
+      //ManifoldCF.initializeEnvironment();
 
       // Mint a thread context
       IThreadContext tc = ThreadContextFactory.make();

Modified: manifoldcf/trunk/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservice/servlet/UserACLServlet.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservice/servlet/UserACLServlet.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservice/servlet/UserACLServlet.java (original)
+++ manifoldcf/trunk/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservice/servlet/UserACLServlet.java Sun Aug 26 13:37:45 2012
@@ -63,7 +63,7 @@ public class UserACLServlet extends Http
     try
     {
       // Set up the environment
-      ManifoldCF.initializeEnvironment();
+      //ManifoldCF.initializeEnvironment();
       IThreadContext itc = ThreadContextFactory.make();
       ManifoldCF.startSystem(itc);
     }
@@ -82,7 +82,7 @@ public class UserACLServlet extends Http
     try
     {
       // Set up the environment
-      ManifoldCF.initializeEnvironment();
+      //ManifoldCF.initializeEnvironment();
       IThreadContext itc = ThreadContextFactory.make();
       ManifoldCF.stopSystem(itc);
     }
@@ -101,7 +101,7 @@ public class UserACLServlet extends Http
     try
     {
       // Set up the environment
-      ManifoldCF.initializeEnvironment();
+      //ManifoldCF.initializeEnvironment();
 
       Logging.authorityService.debug("Received request");
 

Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceDerby.java Sun Aug 26 13:37:45 2012
@@ -124,16 +124,7 @@ public class DBInterfaceDerby extends Da
   public void openDatabase()
     throws ManifoldCFException
   {
-    try
-    {
-      // Force a load of the appropriate JDBC driver
-      Class.forName(_driver).newInstance();
-      DriverManager.getConnection(_url+databaseName+";create=true;user="+userName+";password="+password,userName,password).close();
-    }
-    catch (Exception e)
-    {
-      throw new ManifoldCFException(e.getMessage(),e,ManifoldCFException.SETUP_ERROR);
-    }
+    // Does nothing
   }
   
   /** Uninitialize.  This method is called during JVM shutdown, in order to close
@@ -706,6 +697,17 @@ public class DBInterfaceDerby extends Da
   public void createUserAndDatabase(String adminUserName, String adminPassword, StringSet invalidateKeys)
     throws ManifoldCFException
   {
+    try
+    {
+      // Force a load of the appropriate JDBC driver
+      Class.forName(_driver).newInstance();
+      DriverManager.getConnection(_url+databaseName+";create=true;user="+userName+";password="+password,userName,password).close();
+    }
+    catch (Exception e)
+    {
+      throw new ManifoldCFException(e.getMessage(),e,ManifoldCFException.SETUP_ERROR);
+    }
+
     Database rootDatabase = new DBInterfaceDerby(context,databaseName);
     IResultSet set = rootDatabase.executeQuery("VALUES SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY('derby.user."+userName+"')",null,null,null,null,true,-1,null,null);
     if (set.getRowCount() == 0)

Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/database/DBInterfaceHSQLDB.java Sun Aug 26 13:37:45 2012
@@ -134,20 +134,6 @@ public class DBInterfaceHSQLDB extends D
   public void openDatabase()
     throws ManifoldCFException
   {
-    if (!isRemote)
-    {
-      try
-      {
-        // Force a load of the appropriate JDBC driver
-        Class.forName(_driver).newInstance();
-        DriverManager.getConnection(_localUrl+databaseName,userName,password).close();
-      }
-      catch (Exception e)
-      {
-        throw new ManifoldCFException(e.getMessage(),e,ManifoldCFException.SETUP_ERROR);
-      }
-      performModification("SET DATABASE TRANSACTION CONTROL MVCC",null,null);
-    }
   }
   
   /** Uninitialize.  This method is called during JVM shutdown, in order to close
@@ -610,7 +596,20 @@ public class DBInterfaceHSQLDB extends D
       }
     }
     else
+    {
+      try
+      {
+        // Force a load of the appropriate JDBC driver
+        Class.forName(_driver).newInstance();
+        DriverManager.getConnection(_localUrl+databaseName,userName,password).close();
+      }
+      catch (Exception e)
+      {
+        throw new ManifoldCFException(e.getMessage(),e,ManifoldCFException.SETUP_ERROR);
+      }
+      performModification("SET DATABASE TRANSACTION CONTROL MVCC",null,null);
       performModification("SET FILES SCALE 512",null,null);
+    }
   }
 
   private static String quoteString(String password)

Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ManifoldCF.java Sun Aug 26 13:37:45 2012
@@ -75,7 +75,7 @@ public class ManifoldCF
   }
   
   // Flag indicating whether system initialized or not, and synchronizer to protect that flag.
-  protected static boolean isInitialized = false;
+  protected static int initializeLevel = 0;
   protected static boolean alreadyClosed = false;
   protected static boolean alreadyShutdown = false;
   protected static Integer initializeFlagLock = new Integer(0);
@@ -136,20 +136,21 @@ public class ManifoldCF
   {
     synchronized (initializeFlagLock)
     {
-      if (!isInitialized)
-        return;
-      // Clean up the system doing the same thing the shutdown thread would have if the process was killed
-      cleanUpEnvironment();
-      masterDatabaseName = null;
-      masterDatabaseUsername = null;
-      masterDatabasePassword = null;
-      localConfiguration = null;
-      localProperties = null;
-      propertyFilelastMod = -1L;
-      propertyFilePath = null;
-      isInitialized = false;
-      alreadyClosed = false;
-      alreadyShutdown = false;
+      if (initializeLevel > 0)
+      {
+        // Clean up the system doing the same thing the shutdown thread would have if the process was killed
+        cleanUpEnvironment();
+        masterDatabaseName = null;
+        masterDatabaseUsername = null;
+        masterDatabasePassword = null;
+        localConfiguration = null;
+        localProperties = null;
+        propertyFilelastMod = -1L;
+        propertyFilePath = null;
+        alreadyClosed = false;
+        alreadyShutdown = false;
+        initializeLevel = 0;
+      }
     }
   }
   
@@ -160,77 +161,77 @@ public class ManifoldCF
   {
     synchronized (initializeFlagLock)
     {
-      if (isInitialized)
-        return;
-
-      try
+      if (initializeLevel == 0)
       {
-        
-        // Get system properties
-        java.util.Properties props = System.getProperties();
-        // First, look for a define that might indicate where to look
-      
-        propertyFilePath = (String)props.get(lcfConfigFileProperty);
-        if (propertyFilePath == null)
+        try
         {
-          System.err.println("Couldn't find "+lcfConfigFileProperty+" property; using default");
-          String configPath = (String)props.get("user.home") + "/"+applicationName;
-          configPath = configPath.replace('\\', '/');
-          propertyFilePath = new File(configPath,"properties.xml").toString();
-        }
+          
+          // Get system properties
+          java.util.Properties props = System.getProperties();
+          // First, look for a define that might indicate where to look
+        
+          propertyFilePath = (String)props.get(lcfConfigFileProperty);
+          if (propertyFilePath == null)
+          {
+            System.err.println("Couldn't find "+lcfConfigFileProperty+" property; using default");
+            String configPath = (String)props.get("user.home") + "/"+applicationName;
+            configPath = configPath.replace('\\', '/');
+            propertyFilePath = new File(configPath,"properties.xml").toString();
+          }
 
-        // Initialize working directory.  We cannot use the actual system cwd, because different ManifoldCF processes will have different ones.
-        // So, instead, we use the location of the property file itself, and call that the "working directory".
-        workingDirectory = new File(propertyFilePath).getAbsoluteFile().getParentFile();
+          // Initialize working directory.  We cannot use the actual system cwd, because different ManifoldCF processes will have different ones.
+          // So, instead, we use the location of the property file itself, and call that the "working directory".
+          workingDirectory = new File(propertyFilePath).getAbsoluteFile().getParentFile();
 
-        // Initialize resource loader.
-        resourceLoader = new ManifoldCFResourceLoader(Thread.currentThread().getContextClassLoader());
-        
-        // Read configuration!
-        localConfiguration = new ManifoldCFConfiguration();
-        localProperties = new HashMap();
-        checkProperties();
+          // Initialize resource loader.
+          resourceLoader = new ManifoldCFResourceLoader(Thread.currentThread().getContextClassLoader());
+          
+          // Read configuration!
+          localConfiguration = new ManifoldCFConfiguration();
+          localProperties = new HashMap();
+          checkProperties();
 
-        File logConfigFile = getFileProperty(logConfigFileProperty);
-        if (logConfigFile == null)
-        {
-          System.err.println("Couldn't find "+logConfigFileProperty+" property; using default");
-          String configPath = (String)props.get("user.home") + "/"+applicationName;
-          configPath = configPath.replace('\\', '/');
-          logConfigFile = new File(configPath,"logging.ini");
-        }
+          File logConfigFile = getFileProperty(logConfigFileProperty);
+          if (logConfigFile == null)
+          {
+            System.err.println("Couldn't find "+logConfigFileProperty+" property; using default");
+            String configPath = (String)props.get("user.home") + "/"+applicationName;
+            configPath = configPath.replace('\\', '/');
+            logConfigFile = new File(configPath,"logging.ini");
+          }
 
-        Logging.initializeLoggingSystem(logConfigFile);
+          Logging.initializeLoggingSystem(logConfigFile);
 
-        // Set up local loggers
-        Logging.initializeLoggers();
-        Logging.setLogLevels();
-
-        masterDatabaseName = getProperty(masterDatabaseNameProperty);
-        if (masterDatabaseName == null)
-          masterDatabaseName = "dbname";
-        masterDatabaseUsername = getProperty(masterDatabaseUsernameProperty);
-        if (masterDatabaseUsername == null)
-          masterDatabaseUsername = "manifoldcf";
-        masterDatabasePassword = getProperty(masterDatabasePasswordProperty);
-        if (masterDatabasePassword == null)
-          masterDatabasePassword = "local_pg_passwd";
-
-        // Register the file tracker for cleanup on shutdown
-	tracker = new FileTrack();
-        addShutdownHook(tracker);
-        // Register the database cleanup hook
-        addShutdownHook(new DatabaseShutdown());
-
-        // Open the database.  Done once per JVM.
-        IThreadContext threadcontext = ThreadContextFactory.make();
-        DBInterfaceFactory.make(threadcontext,masterDatabaseName,masterDatabaseUsername,masterDatabasePassword).openDatabase();
-        isInitialized = true;
-      }
-      catch (ManifoldCFException e)
-      {
-        throw new ManifoldCFException("Initialization failed: "+e.getMessage(),e,ManifoldCFException.SETUP_ERROR);
+          // Set up local loggers
+          Logging.initializeLoggers();
+          Logging.setLogLevels();
+
+          masterDatabaseName = getProperty(masterDatabaseNameProperty);
+          if (masterDatabaseName == null)
+            masterDatabaseName = "dbname";
+          masterDatabaseUsername = getProperty(masterDatabaseUsernameProperty);
+          if (masterDatabaseUsername == null)
+            masterDatabaseUsername = "manifoldcf";
+          masterDatabasePassword = getProperty(masterDatabasePasswordProperty);
+          if (masterDatabasePassword == null)
+            masterDatabasePassword = "local_pg_passwd";
+
+          // Register the file tracker for cleanup on shutdown
+          tracker = new FileTrack();
+          addShutdownHook(tracker);
+          // Register the database cleanup hook
+          addShutdownHook(new DatabaseShutdown());
+
+          // Open the database.  Done once per JVM.
+          IThreadContext threadcontext = ThreadContextFactory.make();
+          DBInterfaceFactory.make(threadcontext,masterDatabaseName,masterDatabaseUsername,masterDatabasePassword).openDatabase();
+        }
+        catch (ManifoldCFException e)
+        {
+          throw new ManifoldCFException("Initialization failed: "+e.getMessage(),e,ManifoldCFException.SETUP_ERROR);
+        }
       }
+      initializeLevel++;
     }
 
   }
@@ -1158,29 +1159,33 @@ public class ManifoldCF
   /** Perform system shutdown, using the registered shutdown hooks. */
   public static void cleanUpEnvironment()
   {
-    // It needs to call all registered shutdown hooks, in reverse order.
-    // A failure of any one hook should cause the cleanup to continue, after a logging attempt is made.
-    if (isInitialized && !alreadyShutdown)
+    synchronized (initializeFlagLock)
     {
-      synchronized (cleanupHooks)
+      initializeLevel--;
+      // It needs to call all registered shutdown hooks, in reverse order.
+      // A failure of any one hook should cause the cleanup to continue, after a logging attempt is made.
+      if (initializeLevel == 0 && !alreadyShutdown)
       {
-        int i = cleanupHooks.size();
-        while (i > 0)
+        synchronized (cleanupHooks)
         {
-          i--;
-          IShutdownHook hook = (IShutdownHook)cleanupHooks.get(i);
-          try
+          int i = cleanupHooks.size();
+          while (i > 0)
           {
-            hook.doCleanup();
-          }
-          catch (ManifoldCFException e)
-          {
-            Logging.root.warn("Error during system shutdown: "+e.getMessage(),e);
+            i--;
+            IShutdownHook hook = (IShutdownHook)cleanupHooks.get(i);
+            try
+            {
+              hook.doCleanup();
+            }
+            catch (ManifoldCFException e)
+            {
+              Logging.root.warn("Error during system shutdown: "+e.getMessage(),e);
+            }
           }
+          cleanupHooks.clear();
         }
-        cleanupHooks.clear();
+        alreadyShutdown = true;
       }
-      alreadyShutdown = true;
     }
   }
 
@@ -1278,7 +1283,7 @@ public class ManifoldCF
     {
       synchronized (initializeFlagLock)
       {
-        if (isInitialized && !alreadyClosed)
+        if (initializeLevel == 0 && !alreadyClosed)
         {
           IThreadContext threadcontext = ThreadContextFactory.make();
           

Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ServletListener.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ServletListener.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ServletListener.java (original)
+++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/system/ServletListener.java Sun Aug 26 13:37:45 2012
@@ -31,6 +31,14 @@ public class ServletListener implements 
 
   public void contextInitialized(ServletContextEvent sce)
   {
+    try
+    {
+      ManifoldCF.initializeEnvironment();
+    }
+    catch (ManifoldCFException e)
+    {
+      throw new RuntimeException("Could not initialize servlet; "+e.getMessage(),e);
+    }
   }
   
   public void contextDestroyed(ServletContextEvent sce)

Modified: manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/Base.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/Base.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/Base.java (original)
+++ manifoldcf/trunk/framework/core/src/test/java/org/apache/manifoldcf/core/tests/Base.java Sun Aug 26 13:37:45 2012
@@ -60,9 +60,10 @@ public class Base
   public void setUp()
     throws Exception
   {
+    initializeSystem();
     try
     {
-      localCleanUp();
+      localReset();
     }
     catch (Exception e)
     {
@@ -138,7 +139,7 @@ public class Base
     return "";
   }
 
-  protected void localSetUp()
+  protected void initializeSystem()
     throws Exception
   {
     initialize();
@@ -152,11 +153,14 @@ public class Base
     writeFile(configFile,propertiesXMLContents.toString());
 
     ManifoldCF.initializeEnvironment();
+  }
+  
+  protected void localSetUp()
+    throws Exception
+  {
     IThreadContext tc = ThreadContextFactory.make();
-    
     // Create the database
     ManifoldCF.createSystemDatabase(tc,getDatabaseSuperuserName(),getDatabaseSuperuserPassword());
-
   }
   
   @After
@@ -172,28 +176,39 @@ public class Base
       e.printStackTrace();
       throw e;
     }
+    cleanupSystem();
   }
 
-  protected void localCleanUp()
+  protected void cleanupSystem()
     throws Exception
   {
     initialize();
     if (isInitialized())
     {
-      ManifoldCF.initializeEnvironment();
-      IThreadContext tc = ThreadContextFactory.make();
-      
-      // Remove the database
-      ManifoldCF.dropSystemDatabase(tc,getDatabaseSuperuserName(),getDatabaseSuperuserPassword());
-      
       // Get rid of the property and logging files.
       logOutputFile.delete();
       configFile.delete();
       loggingFile.delete();
       
+      ManifoldCF.cleanUpEnvironment();
+      // Just in case we're not synchronized...
       ManifoldCF.resetEnvironment();
     }
   }
+  
+  protected void localReset()
+    throws Exception
+  {
+    IThreadContext tc = ThreadContextFactory.make();
+    // Remove the database
+    ManifoldCF.dropSystemDatabase(tc,getDatabaseSuperuserName(),getDatabaseSuperuserPassword());
+  }
+  
+  protected void localCleanUp()
+    throws Exception
+  {
+    localReset();
+  }
 
   protected static void writeFile(File f, String fileContents)
     throws IOException

Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/adminDefaults.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/adminDefaults.jsp?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/adminDefaults.jsp (original)
+++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/adminDefaults.jsp Sun Aug 26 13:37:45 2012
@@ -28,10 +28,6 @@
 */
 %>
 
-<%
-	org.apache.manifoldcf.crawler.system.ManifoldCF.initializeEnvironment();
-%>
-
 <jsp:useBean id="thread" class="org.apache.manifoldcf.ui.beans.ThreadContext" scope="request"/>
 <jsp:useBean id="adminprofile" class="org.apache.manifoldcf.ui.beans.AdminProfile" scope="session"/>
 

Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/adminHeaders.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/adminHeaders.jsp?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/adminHeaders.jsp (original)
+++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/adminHeaders.jsp Sun Aug 26 13:37:45 2012
@@ -36,10 +36,6 @@ response.setContentType("text/html;chars
 <%@ page import="org.apache.manifoldcf.authorities.interfaces.*" %>
 <%@ page import="java.util.*" %>
 
-<%
-	org.apache.manifoldcf.crawler.system.ManifoldCF.initializeEnvironment();
-%>
-
 <jsp:useBean id="thread" class="org.apache.manifoldcf.ui.beans.ThreadContext" scope="request"/>
 <jsp:useBean id="adminprofile" class="org.apache.manifoldcf.ui.beans.AdminProfile" scope="session"/>
 

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/ManifoldCF.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/ManifoldCF.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/ManifoldCF.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/ManifoldCF.java Sun Aug 26 13:37:45 2012
@@ -47,17 +47,38 @@ public class ManifoldCF extends org.apac
   {
     synchronized (initializeFlagLock)
     {
+      org.apache.manifoldcf.core.system.ManifoldCF.initializeEnvironment();
+      org.apache.manifoldcf.authorities.system.ManifoldCF.localInitialize();
+    }
+  }
+
+  public static void cleanUpEnvironment()
+  {
+    synchronized (initializeFlagLock)
+    {
+      org.apache.manifoldcf.authorities.system.ManifoldCF.localCleanup();
+      org.apache.manifoldcf.core.system.ManifoldCF.cleanUpEnvironment();
+    }
+  }
+
+  public static void localInitialize()
+    throws ManifoldCFException
+  {
+    synchronized (initializeFlagLock)
+    {
       if (authoritiesInitialized)
         return;
 
-      org.apache.manifoldcf.core.system.ManifoldCF.initializeEnvironment();
       Logging.initializeLoggers();
       Logging.setLogLevels();
       authoritiesInitialized = true;
     }
   }
-
-
+  
+  public static void localCleanup()
+  {
+  }
+  
   /** Install all the authority manager system tables.
   *@param threadcontext is the thread context.
   */

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/CrawlerAgent.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/CrawlerAgent.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/CrawlerAgent.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/CrawlerAgent.java Sun Aug 26 13:37:45 2012
@@ -45,7 +45,6 @@ public class CrawlerAgent implements IAg
     throws ManifoldCFException
   {
     // Install the system tables for the crawler.
-    ManifoldCF.initializeEnvironment();
     ManifoldCF.installSystemTables(threadContext);
   }
 
@@ -54,7 +53,6 @@ public class CrawlerAgent implements IAg
   public void deinstall()
     throws ManifoldCFException
   {
-    ManifoldCF.initializeEnvironment();
     ManifoldCF.deinstallSystemTables(threadContext);
   }
 
@@ -64,7 +62,6 @@ public class CrawlerAgent implements IAg
   public void startAgent()
     throws ManifoldCFException
   {
-    ManifoldCF.initializeEnvironment();
     ManifoldCF.startSystem(threadContext);
   }
 

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java Sun Aug 26 13:37:45 2012
@@ -96,18 +96,41 @@ public class ManifoldCF extends org.apac
   {
     synchronized (initializeFlagLock)
     {
-      org.apache.manifoldcf.authorities.system.ManifoldCF.initializeEnvironment();
+      org.apache.manifoldcf.agents.system.ManifoldCF.initializeEnvironment();
+      org.apache.manifoldcf.authorities.system.ManifoldCF.localInitialize();
+      org.apache.manifoldcf.crawler.system.ManifoldCF.localInitialize();
+    }
+  }
+
+  public static void cleanUpEnvironment()
+  {
+    synchronized (initializeFlagLock)
+    {
+      org.apache.manifoldcf.authorities.system.ManifoldCF.localCleanup();
+      org.apache.manifoldcf.crawler.system.ManifoldCF.localCleanup();
+      org.apache.manifoldcf.agents.system.ManifoldCF.cleanUpEnvironment();
+    }
+  }
+  
+  public static void localInitialize()
+    throws ManifoldCFException
+  {
+    synchronized (initializeFlagLock)
+    {
       
       if (crawlerInitialized)
         return;
       
-      org.apache.manifoldcf.agents.system.ManifoldCF.initializeEnvironment();
       Logging.initializeLoggers();
       Logging.setLogLevels();
       crawlerInitialized = true;
     }
   }
-
+  
+  public static void localCleanup()
+  {
+  }
+  
   /** Create system database using superuser properties from properties.xml.
   */
   public static void createSystemDatabase(IThreadContext threadContext)

Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseDerby.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseDerby.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseDerby.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseDerby.java Sun Aug 26 13:37:45 2012
@@ -35,9 +35,10 @@ public class BaseDerby extends org.apach
   public void setUp()
     throws Exception
   {
+    initializeSystem();
     try
     {
-      localCleanUp();
+      localReset();
     }
     catch (Exception e)
     {
@@ -59,9 +60,6 @@ public class BaseDerby extends org.apach
   {
     super.localSetUp();
     
-    // Install the agents tables
-    initialize();
-    ManifoldCF.initializeEnvironment();
     IThreadContext tc = ThreadContextFactory.make();
     IAgentManager mgr = AgentManagerFactory.make(tc);
     mgr.registerAgent("org.apache.manifoldcf.crawler.system.CrawlerAgent");
@@ -80,41 +78,54 @@ public class BaseDerby extends org.apach
       e.printStackTrace();
       throw e;
     }
+    cleanupSystem();
   }
 
   protected void localCleanUp()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
-    {
-      // Test the uninstall
-      ManifoldCF.initializeEnvironment();
-      IThreadContext tc = ThreadContextFactory.make();
+    // Test the uninstall
+    //ManifoldCF.initializeEnvironment();
+    IThreadContext tc = ThreadContextFactory.make();
       
-      Exception currentException = null;
-      try
-      {
-        IAgentManager mgr = AgentManagerFactory.make(tc);
-        mgr.unregisterAgent("org.apache.manifoldcf.crawler.system.CrawlerAgent");
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
-      try
-      {
-        super.localCleanUp();
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
+    Exception currentException = null;
+    try
+    {
+      IAgentManager mgr = AgentManagerFactory.make(tc);
+      mgr.unregisterAgent("org.apache.manifoldcf.crawler.system.CrawlerAgent");
+    }
+    catch (Exception e)
+    {
       if (currentException != null)
-        throw currentException;
+        currentException = e;
+    }
+    try
+    {
+      super.localCleanUp();
     }
+    catch (Exception e)
+    {
+      if (currentException != null)
+        currentException = e;
+    }
+    if (currentException != null)
+      throw currentException;
+  }
+
+  protected void initializeSystem()
+    throws Exception
+  {
+    super.initializeSystem();
+    org.apache.manifoldcf.authorities.system.ManifoldCF.localInitialize();
+    org.apache.manifoldcf.crawler.system.ManifoldCF.localInitialize();
+  }
+  
+  protected void cleanupSystem()
+    throws Exception
+  {
+    org.apache.manifoldcf.authorities.system.ManifoldCF.localCleanup();
+    org.apache.manifoldcf.crawler.system.ManifoldCF.localCleanup();
+    super.cleanupSystem();
   }
 
 }

Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseHSQLDB.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseHSQLDB.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseHSQLDB.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseHSQLDB.java Sun Aug 26 13:37:45 2012
@@ -35,9 +35,10 @@ public class BaseHSQLDB extends org.apac
   public void setUp()
     throws Exception
   {
+    initializeSystem();
     try
     {
-      localCleanUp();
+      localReset();
     }
     catch (Exception e)
     {
@@ -59,9 +60,6 @@ public class BaseHSQLDB extends org.apac
   {
     super.localSetUp();
     
-    // Install the agents tables
-    initialize();
-    ManifoldCF.initializeEnvironment();
     IThreadContext tc = ThreadContextFactory.make();
     IAgentManager mgr = AgentManagerFactory.make(tc);
     mgr.registerAgent("org.apache.manifoldcf.crawler.system.CrawlerAgent");
@@ -80,41 +78,52 @@ public class BaseHSQLDB extends org.apac
       e.printStackTrace();
       throw e;
     }
+    cleanupSystem();
   }
 
   protected void localCleanUp()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
-    {
-      // Test the uninstall
-      ManifoldCF.initializeEnvironment();
-      IThreadContext tc = ThreadContextFactory.make();
+    IThreadContext tc = ThreadContextFactory.make();
       
-      Exception currentException = null;
-      try
-      {
-        IAgentManager mgr = AgentManagerFactory.make(tc);
-        mgr.unregisterAgent("org.apache.manifoldcf.crawler.system.CrawlerAgent");
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
-      try
-      {
-        super.localCleanUp();
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
+    Exception currentException = null;
+    try
+    {
+      IAgentManager mgr = AgentManagerFactory.make(tc);
+      mgr.unregisterAgent("org.apache.manifoldcf.crawler.system.CrawlerAgent");
+    }
+    catch (Exception e)
+    {
       if (currentException != null)
-        throw currentException;
+        currentException = e;
+    }
+    try
+    {
+      super.localCleanUp();
     }
+    catch (Exception e)
+    {
+      if (currentException != null)
+        currentException = e;
+    }
+    if (currentException != null)
+      throw currentException;
+  }
+
+  protected void initializeSystem()
+    throws Exception
+  {
+    super.initializeSystem();
+    org.apache.manifoldcf.authorities.system.ManifoldCF.localInitialize();
+    org.apache.manifoldcf.crawler.system.ManifoldCF.localInitialize();
+  }
+  
+  protected void cleanupSystem()
+    throws Exception
+  {
+    org.apache.manifoldcf.authorities.system.ManifoldCF.localCleanup();
+    org.apache.manifoldcf.crawler.system.ManifoldCF.localCleanup();
+    super.cleanupSystem();
   }
 
 }

Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseHSQLDBext.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseHSQLDBext.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseHSQLDBext.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseHSQLDBext.java Sun Aug 26 13:37:45 2012
@@ -35,9 +35,10 @@ public class BaseHSQLDBext extends org.a
   public void setUp()
     throws Exception
   {
+    initializeSystem();
     try
     {
-      localCleanUp();
+      localReset();
     }
     catch (Exception e)
     {
@@ -59,9 +60,6 @@ public class BaseHSQLDBext extends org.a
   {
     super.localSetUp();
     
-    // Install the agents tables
-    initialize();
-    ManifoldCF.initializeEnvironment();
     IThreadContext tc = ThreadContextFactory.make();
     IAgentManager mgr = AgentManagerFactory.make(tc);
     mgr.registerAgent("org.apache.manifoldcf.crawler.system.CrawlerAgent");
@@ -80,41 +78,52 @@ public class BaseHSQLDBext extends org.a
       e.printStackTrace();
       throw e;
     }
+    cleanupSystem();
   }
 
   protected void localCleanUp()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
-    {
-      // Test the uninstall
-      ManifoldCF.initializeEnvironment();
-      IThreadContext tc = ThreadContextFactory.make();
+    IThreadContext tc = ThreadContextFactory.make();
       
-      Exception currentException = null;
-      try
-      {
-        IAgentManager mgr = AgentManagerFactory.make(tc);
-        mgr.unregisterAgent("org.apache.manifoldcf.crawler.system.CrawlerAgent");
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
-      try
-      {
-        super.localCleanUp();
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
+    Exception currentException = null;
+    try
+    {
+      IAgentManager mgr = AgentManagerFactory.make(tc);
+      mgr.unregisterAgent("org.apache.manifoldcf.crawler.system.CrawlerAgent");
+    }
+    catch (Exception e)
+    {
       if (currentException != null)
-        throw currentException;
+        currentException = e;
+    }
+    try
+    {
+      super.localCleanUp();
     }
+    catch (Exception e)
+    {
+      if (currentException != null)
+        currentException = e;
+    }
+    if (currentException != null)
+      throw currentException;
+  }
+
+  protected void initializeSystem()
+    throws Exception
+  {
+    super.initializeSystem();
+    org.apache.manifoldcf.authorities.system.ManifoldCF.localInitialize();
+    org.apache.manifoldcf.crawler.system.ManifoldCF.localInitialize();
+  }
+  
+  protected void cleanupSystem()
+    throws Exception
+  {
+    org.apache.manifoldcf.authorities.system.ManifoldCF.localCleanup();
+    org.apache.manifoldcf.crawler.system.ManifoldCF.localCleanup();
+    super.cleanupSystem();
   }
 
 }

Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITDerby.java Sun Aug 26 13:37:45 2012
@@ -181,7 +181,24 @@ public class BaseITDerby extends Connect
   public void setUp()
     throws Exception
   {
-    super.setUp();
+    initializeSystem();
+    try
+    {
+      localReset();
+    }
+    catch (Exception e)
+    {
+      System.out.println("Warning: Preclean failed: "+e.getMessage());
+    }
+    try
+    {
+      localSetUp();
+    }
+    catch (Exception e)
+    {
+      e.printStackTrace();
+      throw e;
+    }
     mcfInstance.start();
   }
   
@@ -189,43 +206,39 @@ public class BaseITDerby extends Connect
   public void cleanUp()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
+    Exception currentException = null;
+    try
+    {
+      mcfInstance.stop();
+    }
+    catch (Exception e)
+    {
+      if (currentException == null)
+        currentException = e;
+    }
+    // Last, shut down the web applications.
+    // If this is done too soon it closes the database before the rest of the cleanup happens.
+    try
+    {
+      mcfInstance.unload();
+    }
+    catch (Exception e)
+    {
+      if (currentException == null)
+        currentException = e;
+    }
+    try
+    {
+      localCleanUp();
+    }
+    catch (Exception e)
     {
-      Exception currentException = null;
-      try
-      {
-        mcfInstance.stop();
-      }
-      catch (Exception e)
-      {
-        if (currentException == null)
-          currentException = e;
-      }
-      // Clean up everything else
-      try
-      {
-        super.cleanUp();
-      }
-      catch (Exception e)
-      {
-        if (currentException == null)
-          currentException = e;
-      }
-      // Last, shut down the web applications.
-      // If this is done too soon it closes the database before the rest of the cleanup happens.
-      try
-      {
-        mcfInstance.unload();
-      }
-      catch (Exception e)
-      {
-        if (currentException == null)
-          currentException = e;
-      }
-      if (currentException != null)
-        throw currentException;
+      e.printStackTrace();
+      throw e;
     }
+    if (currentException != null)
+      throw currentException;
+    cleanupSystem();
   }
   
 }

Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITHSQLDB.java Sun Aug 26 13:37:45 2012
@@ -181,7 +181,24 @@ public class BaseITHSQLDB extends Connec
   public void setUp()
     throws Exception
   {
-    super.setUp();
+    initializeSystem();
+    try
+    {
+      localReset();
+    }
+    catch (Exception e)
+    {
+      System.out.println("Warning: Preclean failed: "+e.getMessage());
+    }
+    try
+    {
+      localSetUp();
+    }
+    catch (Exception e)
+    {
+      e.printStackTrace();
+      throw e;
+    }
     mcfInstance.start();
   }
   
@@ -189,43 +206,39 @@ public class BaseITHSQLDB extends Connec
   public void cleanUp()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
+    Exception currentException = null;
+    try
+    {
+      mcfInstance.stop();
+    }
+    catch (Exception e)
+    {
+      if (currentException == null)
+        currentException = e;
+    }
+    // Last, shut down the web applications.
+    // If this is done too soon it closes the database before the rest of the cleanup happens.
+    try
+    {
+      mcfInstance.unload();
+    }
+    catch (Exception e)
+    {
+      if (currentException == null)
+        currentException = e;
+    }
+    try
+    {
+      localCleanUp();
+    }
+    catch (Exception e)
     {
-      Exception currentException = null;
-      try
-      {
-        mcfInstance.stop();
-      }
-      catch (Exception e)
-      {
-        if (currentException == null)
-          currentException = e;
-      }
-      // Clean up everything else
-      try
-      {
-        super.cleanUp();
-      }
-      catch (Exception e)
-      {
-        if (currentException == null)
-          currentException = e;
-      }
-      // Last, shut down the web applications.
-      // If this is done too soon it closes the database before the rest of the cleanup happens.
-      try
-      {
-        mcfInstance.unload();
-      }
-      catch (Exception e)
-      {
-        if (currentException == null)
-          currentException = e;
-      }
-      if (currentException != null)
-        throw currentException;
+      e.printStackTrace();
+      throw e;
     }
+    if (currentException != null)
+      throw currentException;
+    cleanupSystem();
   }
   
 }

Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITMySQL.java Sun Aug 26 13:37:45 2012
@@ -181,7 +181,24 @@ public class BaseITMySQL extends Connect
   public void setUp()
     throws Exception
   {
-    super.setUp();
+    initializeSystem();
+    try
+    {
+      localReset();
+    }
+    catch (Exception e)
+    {
+      System.out.println("Warning: Preclean failed: "+e.getMessage());
+    }
+    try
+    {
+      localSetUp();
+    }
+    catch (Exception e)
+    {
+      e.printStackTrace();
+      throw e;
+    }
     mcfInstance.start();
   }
   
@@ -189,43 +206,39 @@ public class BaseITMySQL extends Connect
   public void cleanUp()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
+    Exception currentException = null;
+    try
+    {
+      mcfInstance.stop();
+    }
+    catch (Exception e)
+    {
+      if (currentException == null)
+        currentException = e;
+    }
+    // Last, shut down the web applications.
+    // If this is done too soon it closes the database before the rest of the cleanup happens.
+    try
+    {
+      mcfInstance.unload();
+    }
+    catch (Exception e)
+    {
+      if (currentException == null)
+        currentException = e;
+    }
+    try
+    {
+      localCleanUp();
+    }
+    catch (Exception e)
     {
-      Exception currentException = null;
-      try
-      {
-        mcfInstance.stop();
-      }
-      catch (Exception e)
-      {
-        if (currentException == null)
-          currentException = e;
-      }
-      // Clean up everything else
-      try
-      {
-        super.cleanUp();
-      }
-      catch (Exception e)
-      {
-        if (currentException == null)
-          currentException = e;
-      }
-      // Last, shut down the web applications.
-      // If this is done too soon it closes the database before the rest of the cleanup happens.
-      try
-      {
-        mcfInstance.unload();
-      }
-      catch (Exception e)
-      {
-        if (currentException == null)
-          currentException = e;
-      }
-      if (currentException != null)
-        throw currentException;
+      e.printStackTrace();
+      throw e;
     }
+    if (currentException != null)
+      throw currentException;
+    cleanupSystem();
   }
   
 }

Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseITPostgresql.java Sun Aug 26 13:37:45 2012
@@ -181,7 +181,24 @@ public class BaseITPostgresql extends Co
   public void setUp()
     throws Exception
   {
-    super.setUp();
+    initializeSystem();
+    try
+    {
+      localReset();
+    }
+    catch (Exception e)
+    {
+      System.out.println("Warning: Preclean failed: "+e.getMessage());
+    }
+    try
+    {
+      localSetUp();
+    }
+    catch (Exception e)
+    {
+      e.printStackTrace();
+      throw e;
+    }
     mcfInstance.start();
   }
   
@@ -189,43 +206,39 @@ public class BaseITPostgresql extends Co
   public void cleanUp()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
+    Exception currentException = null;
+    try
+    {
+      mcfInstance.stop();
+    }
+    catch (Exception e)
+    {
+      if (currentException == null)
+        currentException = e;
+    }
+    // Last, shut down the web applications.
+    // If this is done too soon it closes the database before the rest of the cleanup happens.
+    try
+    {
+      mcfInstance.unload();
+    }
+    catch (Exception e)
+    {
+      if (currentException == null)
+        currentException = e;
+    }
+    try
+    {
+      localCleanUp();
+    }
+    catch (Exception e)
     {
-      Exception currentException = null;
-      try
-      {
-        mcfInstance.stop();
-      }
-      catch (Exception e)
-      {
-        if (currentException == null)
-          currentException = e;
-      }
-      // Clean up everything else
-      try
-      {
-        super.cleanUp();
-      }
-      catch (Exception e)
-      {
-        if (currentException == null)
-          currentException = e;
-      }
-      // Last, shut down the web applications.
-      // If this is done too soon it closes the database before the rest of the cleanup happens.
-      try
-      {
-        mcfInstance.unload();
-      }
-      catch (Exception e)
-      {
-        if (currentException == null)
-          currentException = e;
-      }
-      if (currentException != null)
-        throw currentException;
+      e.printStackTrace();
+      throw e;
     }
+    if (currentException != null)
+      throw currentException;
+    cleanupSystem();
   }
   
 }

Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseMySQL.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseMySQL.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseMySQL.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BaseMySQL.java Sun Aug 26 13:37:45 2012
@@ -35,9 +35,10 @@ public class BaseMySQL extends org.apach
   public void setUp()
     throws Exception
   {
+    initializeSystem();
     try
     {
-      localCleanUp();
+      localReset();
     }
     catch (Exception e)
     {
@@ -59,9 +60,6 @@ public class BaseMySQL extends org.apach
   {
     super.localSetUp();
     
-    // Install the agents tables
-    initialize();
-    ManifoldCF.initializeEnvironment();
     IThreadContext tc = ThreadContextFactory.make();
     IAgentManager mgr = AgentManagerFactory.make(tc);
     mgr.registerAgent("org.apache.manifoldcf.crawler.system.CrawlerAgent");
@@ -80,41 +78,52 @@ public class BaseMySQL extends org.apach
       e.printStackTrace();
       throw e;
     }
+    cleanupSystem();
   }
 
   protected void localCleanUp()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
-    {
-      // Test the uninstall
-      ManifoldCF.initializeEnvironment();
-      IThreadContext tc = ThreadContextFactory.make();
+    IThreadContext tc = ThreadContextFactory.make();
       
-      Exception currentException = null;
-      try
-      {
-        IAgentManager mgr = AgentManagerFactory.make(tc);
-        mgr.unregisterAgent("org.apache.manifoldcf.crawler.system.CrawlerAgent");
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
-      try
-      {
-        super.localCleanUp();
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
+    Exception currentException = null;
+    try
+    {
+      IAgentManager mgr = AgentManagerFactory.make(tc);
+      mgr.unregisterAgent("org.apache.manifoldcf.crawler.system.CrawlerAgent");
+    }
+    catch (Exception e)
+    {
       if (currentException != null)
-        throw currentException;
+        currentException = e;
+    }
+    try
+    {
+      super.localCleanUp();
     }
+    catch (Exception e)
+    {
+      if (currentException != null)
+        currentException = e;
+    }
+    if (currentException != null)
+      throw currentException;
+  }
+
+  protected void initializeSystem()
+    throws Exception
+  {
+    super.initializeSystem();
+    org.apache.manifoldcf.authorities.system.ManifoldCF.localInitialize();
+    org.apache.manifoldcf.crawler.system.ManifoldCF.localInitialize();
+  }
+  
+  protected void cleanupSystem()
+    throws Exception
+  {
+    org.apache.manifoldcf.authorities.system.ManifoldCF.localCleanup();
+    org.apache.manifoldcf.crawler.system.ManifoldCF.localCleanup();
+    super.cleanupSystem();
   }
 
 }

Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BasePostgresql.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BasePostgresql.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BasePostgresql.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/BasePostgresql.java Sun Aug 26 13:37:45 2012
@@ -35,9 +35,10 @@ public class BasePostgresql extends org.
   public void setUp()
     throws Exception
   {
+    initializeSystem();
     try
     {
-      localCleanUp();
+      localReset();
     }
     catch (Exception e)
     {
@@ -59,9 +60,6 @@ public class BasePostgresql extends org.
   {
     super.localSetUp();
     
-    // Install the agents tables
-    initialize();
-    ManifoldCF.initializeEnvironment();
     IThreadContext tc = ThreadContextFactory.make();
     IAgentManager mgr = AgentManagerFactory.make(tc);
     mgr.registerAgent("org.apache.manifoldcf.crawler.system.CrawlerAgent");
@@ -80,41 +78,52 @@ public class BasePostgresql extends org.
       e.printStackTrace();
       throw e;
     }
+    cleanupSystem();
   }
 
   protected void localCleanUp()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
-    {
-      // Test the uninstall
-      ManifoldCF.initializeEnvironment();
-      IThreadContext tc = ThreadContextFactory.make();
+    IThreadContext tc = ThreadContextFactory.make();
       
-      Exception currentException = null;
-      try
-      {
-        IAgentManager mgr = AgentManagerFactory.make(tc);
-        mgr.unregisterAgent("org.apache.manifoldcf.crawler.system.CrawlerAgent");
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
-      try
-      {
-        super.localCleanUp();
-      }
-      catch (Exception e)
-      {
-        if (currentException != null)
-          currentException = e;
-      }
+    Exception currentException = null;
+    try
+    {
+      IAgentManager mgr = AgentManagerFactory.make(tc);
+      mgr.unregisterAgent("org.apache.manifoldcf.crawler.system.CrawlerAgent");
+    }
+    catch (Exception e)
+    {
       if (currentException != null)
-        throw currentException;
+        currentException = e;
+    }
+    try
+    {
+      super.localCleanUp();
     }
+    catch (Exception e)
+    {
+      if (currentException != null)
+        currentException = e;
+    }
+    if (currentException != null)
+      throw currentException;
+  }
+
+  protected void initializeSystem()
+    throws Exception
+  {
+    super.initializeSystem();
+    org.apache.manifoldcf.authorities.system.ManifoldCF.localInitialize();
+    org.apache.manifoldcf.crawler.system.ManifoldCF.localInitialize();
+  }
+  
+  protected void cleanupSystem()
+    throws Exception
+  {
+    org.apache.manifoldcf.authorities.system.ManifoldCF.localCleanup();
+    org.apache.manifoldcf.crawler.system.ManifoldCF.localCleanup();
+    super.cleanupSystem();
   }
 
 }

Modified: manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ConnectorBaseDerby.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ConnectorBaseDerby.java?rev=1377435&r1=1377434&r2=1377435&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ConnectorBaseDerby.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/test/java/org/apache/manifoldcf/crawler/tests/ConnectorBaseDerby.java Sun Aug 26 13:37:45 2012
@@ -66,9 +66,10 @@ public class ConnectorBaseDerby extends 
   public void setUp()
     throws Exception
   {
+    initializeSystem();
     try
     {
-      localCleanUp();
+      localReset();
     }
     catch (Exception e)
     {
@@ -91,9 +92,6 @@ public class ConnectorBaseDerby extends 
     
     super.localSetUp();
     
-    // Register the connector we're testing
-    initialize();
-    ManifoldCF.initializeEnvironment();
     IThreadContext tc = ThreadContextFactory.make();
 
     IDBInterface database = DBInterfaceFactory.make(tc,
@@ -186,145 +184,140 @@ public class ConnectorBaseDerby extends 
       e.printStackTrace();
       throw e;
     }
+    cleanupSystem();
   }
 
   protected void localCleanUp()
     throws Exception
   {
-    initialize();
-    if (isInitialized())
-    {
-      // Test the uninstall
-      ManifoldCF.initializeEnvironment();
-      IThreadContext tc = ThreadContextFactory.make();
+    IThreadContext tc = ThreadContextFactory.make();
       
-      Exception currentException = null;
-      // First, tear down all jobs, connections, authority connections, and output connections.
-      try
-      {
-        IRepositoryConnectionManager connMgr = RepositoryConnectionManagerFactory.make(tc);
-        IAuthorityConnectionManager authConnMgr = AuthorityConnectionManagerFactory.make(tc);
-        IOutputConnectionManager outputMgr = OutputConnectionManagerFactory.make(tc);
-        
-        // Now, get a list of the repository connections
-        IRepositoryConnection[] connections = connMgr.getAllConnections();
-        int i = 0;
-        while (i < connections.length)
-        {
-          connMgr.delete(connections[i++].getName());
-        }
-
-        // Get a list of authority connections
-        IAuthorityConnection[] authorities = authConnMgr.getAllConnections();
-        i = 0;
-        while (i < authorities.length)
-        {
-          authConnMgr.delete(authorities[i++].getName());
-        }
+    Exception currentException = null;
+    // First, tear down all jobs, connections, authority connections, and output connections.
+    try
+    {
+      IRepositoryConnectionManager connMgr = RepositoryConnectionManagerFactory.make(tc);
+      IAuthorityConnectionManager authConnMgr = AuthorityConnectionManagerFactory.make(tc);
+      IOutputConnectionManager outputMgr = OutputConnectionManagerFactory.make(tc);
         
-        // Finally, get rid of output connections
-        IOutputConnection[] outputs = outputMgr.getAllConnections();
-        i = 0;
-        while (i < outputs.length)
-        {
-          outputMgr.delete(outputs[i++].getName());
-        }
-
+      // Now, get a list of the repository connections
+      IRepositoryConnection[] connections = connMgr.getAllConnections();
+      int i = 0;
+      while (i < connections.length)
+      {
+        connMgr.delete(connections[i++].getName());
       }
-      catch (Exception e)
+
+      // Get a list of authority connections
+      IAuthorityConnection[] authorities = authConnMgr.getAllConnections();
+      i = 0;
+      while (i < authorities.length)
       {
-        currentException = e;
+        authConnMgr.delete(authorities[i++].getName());
       }
-      try
+        
+      // Finally, get rid of output connections
+      IOutputConnection[] outputs = outputMgr.getAllConnections();
+      i = 0;
+      while (i < outputs.length)
       {
-        IDBInterface database = DBInterfaceFactory.make(tc,
-          ManifoldCF.getMasterDatabaseName(),
-          ManifoldCF.getMasterDatabaseUsername(),
-          ManifoldCF.getMasterDatabasePassword());
+        outputMgr.delete(outputs[i++].getName());
+      }
+
+    }
+    catch (Exception e)
+    {
+      currentException = e;
+    }
+    try
+    {
+      IDBInterface database = DBInterfaceFactory.make(tc,
+        ManifoldCF.getMasterDatabaseName(),
+        ManifoldCF.getMasterDatabaseUsername(),
+        ManifoldCF.getMasterDatabasePassword());
         
-        IConnectorManager mgr = ConnectorManagerFactory.make(tc);
-        IAuthorityConnectorManager authMgr = AuthorityConnectorManagerFactory.make(tc);
-        IOutputConnectorManager outputMgr = OutputConnectorManagerFactory.make(tc);
-        IOutputConnectionManager outputConnManager = OutputConnectionManagerFactory.make(tc);
-        IJobManager jobManager = JobManagerFactory.make(tc);
-        IRepositoryConnectionManager connManager = RepositoryConnectionManagerFactory.make(tc);
+      IConnectorManager mgr = ConnectorManagerFactory.make(tc);
+      IAuthorityConnectorManager authMgr = AuthorityConnectorManagerFactory.make(tc);
+      IOutputConnectorManager outputMgr = OutputConnectorManagerFactory.make(tc);
+      IOutputConnectionManager outputConnManager = OutputConnectionManagerFactory.make(tc);
+      IJobManager jobManager = JobManagerFactory.make(tc);
+      IRepositoryConnectionManager connManager = RepositoryConnectionManagerFactory.make(tc);
         
-        // Deregistration should be done in a transaction
-        database.beginTransaction();
-        try
-        {
-          int i;
-          
-          String[] connectorClasses = getConnectorClasses();
-
-          i = 0;
-          while (i < connectorClasses.length)
-          {
-            // Find the connection names that come with this class
-            String[] connectionNames = connManager.findConnectionsForConnector(connectorClasses[i]);
-            // For each connection name, modify the jobs to note that the connector is no longer installed
-            jobManager.noteConnectorDeregistration(connectionNames);
-            // Now that all jobs have been placed into an appropriate state, actually do the deregistration itself.
-            mgr.unregisterConnector(connectorClasses[i]);
-            i++;
-          }
-          
-          String[] authorityClasses = getAuthorityClasses();
-          
-          i = 0;
-          while (i < authorityClasses.length)
-          {
-            authMgr.unregisterConnector(authorityClasses[i]);
-            i++;
-          }
-          
-          String[] outputClasses = getOutputClasses();
-          
-          i = 0;
-          while (i < outputClasses.length)
-          {
-            // Find the connection names that come with this class
-            String[] connectionNames = outputConnManager.findConnectionsForConnector(outputClasses[i]);
-            // For all connection names, notify all agents of the deregistration
-            AgentManagerFactory.noteOutputConnectorDeregistration(tc,connectionNames);
-            // Now that all jobs have been placed into an appropriate state, actually do the deregistration itself.
-            outputMgr.unregisterConnector(outputClasses[i]);
-            i++;
-          }
+      // Deregistration should be done in a transaction
+      database.beginTransaction();
+      try
+      {
+        int i;
           
-        }
-        catch (ManifoldCFException e)
+        String[] connectorClasses = getConnectorClasses();
+        
+        i = 0;
+        while (i < connectorClasses.length)
         {
-          database.signalRollback();
-          throw e;
+          // Find the connection names that come with this class
+          String[] connectionNames = connManager.findConnectionsForConnector(connectorClasses[i]);
+          // For each connection name, modify the jobs to note that the connector is no longer installed
+          jobManager.noteConnectorDeregistration(connectionNames);
+          // Now that all jobs have been placed into an appropriate state, actually do the deregistration itself.
+          mgr.unregisterConnector(connectorClasses[i]);
+          i++;
         }
-        catch (Error e)
+          
+        String[] authorityClasses = getAuthorityClasses();
+        
+        i = 0;
+        while (i < authorityClasses.length)
         {
-          database.signalRollback();
-          throw e;
+          authMgr.unregisterConnector(authorityClasses[i]);
+          i++;
         }
-        finally
+          
+        String[] outputClasses = getOutputClasses();
+          
+        i = 0;
+        while (i < outputClasses.length)
         {
-          database.endTransaction();
+          // Find the connection names that come with this class
+          String[] connectionNames = outputConnManager.findConnectionsForConnector(outputClasses[i]);
+          // For all connection names, notify all agents of the deregistration
+          AgentManagerFactory.noteOutputConnectorDeregistration(tc,connectionNames);
+          // Now that all jobs have been placed into an appropriate state, actually do the deregistration itself.
+          outputMgr.unregisterConnector(outputClasses[i]);
+          i++;
         }
+          
       }
-      catch (Exception e)
+      catch (ManifoldCFException e)
       {
-        if (currentException != null)
-          currentException = e;
+        database.signalRollback();
+        throw e;
       }
-      try
+      catch (Error e)
       {
-        super.localCleanUp();
+        database.signalRollback();
+        throw e;
       }
-      catch (Exception e)
+      finally
       {
-        if (currentException != null)
-          currentException = e;
+        database.endTransaction();
       }
+    }
+    catch (Exception e)
+    {
+      if (currentException != null)
+        currentException = e;
+    }
+    try
+    {
+      super.localCleanUp();
+    }
+    catch (Exception e)
+    {
       if (currentException != null)
-        throw currentException;
+        currentException = e;
     }
+    if (currentException != null)
+      throw currentException;
   }
 
 }



Mime
View raw message