You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2013/12/05 11:31:02 UTC

svn commit: r1548081 [2/3] - in /manifoldcf/trunk: ./ framework/agents/src/main/java/org/apache/manifoldcf/agents/incrementalingest/ framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/ framework/agents/src/main/java/org/apache/manif...

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorFactory.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorFactory.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorFactory.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorFactory.java Thu Dec  5 10:31:01 2013
@@ -26,24 +26,31 @@ import java.lang.reflect.*;
 
 /** This class manages a pool of mapping connectors.
 */
-public class MappingConnectorFactory
+public class MappingConnectorFactory extends ConnectorFactory<IMappingConnector>
 {
-  // Pool hash table.
-  // Keyed by PoolKey; value is Pool
-  protected static Map poolHash = new HashMap();
 
-  private MappingConnectorFactory()
+  // Static factory
+  protected final static MappingConnectorFactory thisFactory = new MappingConnectorFactory();
+
+  protected MappingConnectorFactory()
   {
   }
 
+  @Override
+  protected boolean isInstalled(IThreadContext tc, String className)
+    throws ManifoldCFException
+  {
+    IMappingConnectorManager connMgr = MappingConnectorManagerFactory.make(tc);
+    return connMgr.isInstalled(className);
+  }
+
   /** Install connector.
   *@param className is the class name.
   */
   public static void install(IThreadContext threadContext, String className)
     throws ManifoldCFException
   {
-    IMappingConnector connector = getConnectorNoCheck(className);
-    connector.install(threadContext);
+    thisFactory.installThis(threadContext,className);
   }
 
   /** Uninstall connector.
@@ -52,8 +59,7 @@ public class MappingConnectorFactory
   public static void deinstall(IThreadContext threadContext, String className)
     throws ManifoldCFException
   {
-    IMappingConnector connector = getConnectorNoCheck(className);
-    connector.deinstall(threadContext);
+    thisFactory.deinstallThis(threadContext,className);
   }
 
   /** Output the configuration header section.
@@ -61,10 +67,7 @@ public class MappingConnectorFactory
   public static void outputConfigurationHeader(IThreadContext threadContext, String className, IHTTPOutput out, Locale locale, ConfigParams parameters, ArrayList tabsArray)
     throws ManifoldCFException, IOException
   {
-    IMappingConnector connector = getConnector(threadContext, className);
-    if (connector == null)
-      return;
-    connector.outputConfigurationHeader(threadContext,out,locale,parameters,tabsArray);
+    thisFactory.outputThisConfigurationHeader(threadContext,className,out,locale,parameters,tabsArray);
   }
 
   /** Output the configuration body section.
@@ -72,10 +75,7 @@ public class MappingConnectorFactory
   public static void outputConfigurationBody(IThreadContext threadContext, String className, IHTTPOutput out, Locale locale, ConfigParams parameters, String tabName)
     throws ManifoldCFException, IOException
   {
-    IMappingConnector connector = getConnector(threadContext, className);
-    if (connector == null)
-      return;
-    connector.outputConfigurationBody(threadContext,out,locale,parameters,tabName);
+    thisFactory.outputThisConfigurationBody(threadContext,className,out,locale,parameters,tabName);
   }
 
   /** Process configuration post data for a connector.
@@ -83,10 +83,7 @@ public class MappingConnectorFactory
   public static String processConfigurationPost(IThreadContext threadContext, String className, IPostParameters variableContext, Locale locale, ConfigParams configParams)
     throws ManifoldCFException
   {
-    IMappingConnector connector = getConnector(threadContext, className);
-    if (connector == null)
-      return null;
-    return connector.processConfigurationPost(threadContext,variableContext,locale,configParams);
+    return thisFactory.processThisConfigurationPost(threadContext,className,variableContext,locale,configParams);
   }
   
   /** View connector configuration.
@@ -94,11 +91,7 @@ public class MappingConnectorFactory
   public static void viewConfiguration(IThreadContext threadContext, String className, IHTTPOutput out, Locale locale, ConfigParams configParams)
     throws ManifoldCFException, IOException
   {
-    IMappingConnector connector = getConnector(threadContext, className);
-    // We want to be able to view connections even if they have unregistered connectors.
-    if (connector == null)
-      return;
-    connector.viewConfiguration(threadContext,out,locale,configParams);
+    thisFactory.viewThisConfiguration(threadContext,className,out,locale,configParams);
   }
 
   /** Get a mapping connector instance, but do NOT check if class is installed first!
@@ -108,473 +101,8 @@ public class MappingConnectorFactory
   public static IMappingConnector getConnectorNoCheck(String className)
     throws ManifoldCFException
   {
-    try
-    {
-      Class theClass = ManifoldCF.findClass(className);
-      Class[] argumentClasses = new Class[0];
-      // Look for a constructor
-      Constructor c = theClass.getConstructor(argumentClasses);
-      Object[] arguments = new Object[0];
-      Object o = c.newInstance(arguments);
-      if (!(o instanceof IMappingConnector))
-        throw new ManifoldCFException("Class '"+className+"' does not implement IMappingConnector.");
-      return (IMappingConnector)o;
-    }
-    catch (InvocationTargetException e)
-    {
-      Throwable z = e.getTargetException();
-      if (z instanceof Error)
-        throw (Error)z;
-      else if (z instanceof RuntimeException)
-        throw (RuntimeException)z;
-      else
-        throw (ManifoldCFException)z;
-    }
-    catch (ClassNotFoundException e)
-    {
-      throw new ManifoldCFException("No mapping connector class '"+className+"' was found.",
-        e);
-    }
-    catch (NoSuchMethodException e)
-    {
-      throw new ManifoldCFException("No appropriate constructor for IMappingConnector implementation '"+
-        className+"'.  Need xxx().",
-        e);
-    }
-    catch (SecurityException e)
-    {
-      throw new ManifoldCFException("Protected constructor for IMappingConnector implementation '"+className+"'",
-        e);
-    }
-    catch (IllegalAccessException e)
-    {
-      throw new ManifoldCFException("Unavailable constructor for IMappingConnector implementation '"+className+"'",
-        e);
-    }
-    catch (IllegalArgumentException e)
-    {
-      throw new ManifoldCFException("Shouldn't happen!!!",e);
-    }
-    catch (InstantiationException e)
-    {
-      throw new ManifoldCFException("InstantiationException for IMappingConnector implementation '"+className+"'",
-        e);
-    }
-    catch (ExceptionInInitializerError e)
-    {
-      throw new ManifoldCFException("ExceptionInInitializerError for IMappingConnector implementation '"+className+"'",
-        e);
-    }
-
-  }
-
-  /** Get a mapping connector instance.
-  *@param className is the class name.
-  *@return the instance.
-  */
-  protected static IMappingConnector getConnector(IThreadContext threadContext, String className)
-    throws ManifoldCFException
-  {
-    IMappingConnectorManager connMgr = MappingConnectorManagerFactory.make(threadContext);
-    if (connMgr.isInstalled(className) == false)
-      return null;
-
-    try
-    {
-      Class theClass = ManifoldCF.findClass(className);
-      Class[] argumentClasses = new Class[0];
-      // Look for a constructor
-      Constructor c = theClass.getConstructor(argumentClasses);
-      Object[] arguments = new Object[0];
-      Object o = c.newInstance(arguments);
-      if (!(o instanceof IMappingConnector))
-        throw new ManifoldCFException("Class '"+className+"' does not implement IMappingConnector.");
-      return (IMappingConnector)o;
-    }
-    catch (InvocationTargetException e)
-    {
-      Throwable z = e.getTargetException();
-      if (z instanceof Error)
-        throw (Error)z;
-      else if (z instanceof RuntimeException)
-        throw (RuntimeException)z;
-      else
-        throw (ManifoldCFException)z;
-    }
-    catch (ClassNotFoundException e)
-    {
-      // If we get this exception, it may mean that the mapping is not registered.
-      if (connMgr.isInstalled(className) == false)
-        return null;
-
-      throw new ManifoldCFException("No mapping connector class '"+className+"' was found.",
-        e);
-    }
-    catch (NoSuchMethodException e)
-    {
-      throw new ManifoldCFException("No appropriate constructor for IMappingConnector implementation '"+
-        className+"'.  Need xxx().",
-        e);
-    }
-    catch (SecurityException e)
-    {
-      throw new ManifoldCFException("Protected constructor for IMappingConnector implementation '"+className+"'",
-        e);
-    }
-    catch (IllegalAccessException e)
-    {
-      throw new ManifoldCFException("Unavailable constructor for IMappingConnector implementation '"+className+"'",
-        e);
-    }
-    catch (IllegalArgumentException e)
-    {
-      throw new ManifoldCFException("Shouldn't happen!!!",e);
-    }
-    catch (InstantiationException e)
-    {
-      throw new ManifoldCFException("InstantiationException for IMappingConnector implementation '"+className+"'",
-        e);
-    }
-    catch (ExceptionInInitializerError e)
-    {
-      throw new ManifoldCFException("ExceptionInInitializerError for IMappingConnector implementation '"+className+"'",
-        e);
-    }
-
-  }
-
-  /** Get a mapping connector.
-  * The connector is specified by its class and its parameters.
-  *@param threadContext is the current thread context.
-  *@param className is the name of the class to get a connector for.
-  *@param configInfo are the name/value pairs constituting configuration info
-  * for this class.
-  */
-  public static IMappingConnector grab(IThreadContext threadContext,
-    String className, ConfigParams configInfo, int maxPoolSize)
-    throws ManifoldCFException
-  {
-    // We want to get handles off the pool and use them.  But the
-    // handles we fetch have to have the right config information.
-
-    // Use the classname and config info to build a pool key
-    PoolKey pk = new PoolKey(className,configInfo);
-    Pool p;
-    synchronized (poolHash)
-    {
-      p = (Pool)poolHash.get(pk);
-      if (p == null)
-      {
-        // Build it again, this time making a copy
-        pk = new PoolKey(className,configInfo.duplicate());
-        p = new Pool(pk,maxPoolSize);
-        poolHash.put(pk,p);
-      }
-    }
-
-    IMappingConnector rval = p.getConnector(threadContext);
-    return rval;
-  }
-
-  /** Release a repository connector.
-  *@param connector is the connector to release.
-  */
-  public static void release(IMappingConnector connector)
-    throws ManifoldCFException
-  {
-    if (connector == null)
-      return;
-
-    // Figure out which pool this goes on, and put it there
-    PoolKey pk = new PoolKey(connector.getClass().getName(),connector.getConfiguration());
-    Pool p;
-    synchronized (poolHash)
-    {
-      p = (Pool)poolHash.get(pk);
-    }
-
-    p.releaseConnector(connector);
-    // System.out.println("Done releasing");
-  }
-
-  /** Idle notification for inactive mapping connector handles.
-  * This method polls all inactive handles.
-  */
-  public static void pollAllConnectors(IThreadContext threadContext)
-    throws ManifoldCFException
-  {
-    // Go through the whole pool and notify everyone
-    synchronized (poolHash)
-    {
-      Iterator iter = poolHash.values().iterator();
-      while (iter.hasNext())
-      {
-        Pool p = (Pool)iter.next();
-        p.pollAll(threadContext);
-      }
-    }
-
-  }
-
-  /** Clean up all open mapping connector handles.
-  * This method is called when the connector pool needs to be flushed,
-  * to free resources.
-  *@param threadContext is the local thread context.
-  */
-  public static void closeAllConnectors(IThreadContext threadContext)
-    throws ManifoldCFException
-  {
-    // Go through the whole pool and clean it out
-    synchronized (poolHash)
-    {
-      Iterator iter = poolHash.values().iterator();
-      while (iter.hasNext())
-      {
-        Pool p = (Pool)iter.next();
-        p.releaseAll(threadContext);
-      }
-    }
+    return thisFactory.getThisConnectorNoCheck(className);
   }
 
-  /** This is an immutable pool key class, which describes a pool in terms of two independent keys.
-  */
-  public static class PoolKey
-  {
-    protected String className;
-    protected ConfigParams configInfo;
-
-    /** Constructor.
-    */
-    public PoolKey(String className, Map configInfo)
-    {
-      this.className = className;
-      this.configInfo = new ConfigParams(configInfo);
-    }
-
-    public PoolKey(String className, ConfigParams configInfo)
-    {
-      this.className = className;
-      this.configInfo = configInfo;
-    }
-
-    /** Get the class name.
-    *@return the class name.
-    */
-    public String getClassName()
-    {
-      return className;
-    }
-
-    /** Get the config info.
-    *@return the params
-    */
-    public ConfigParams getParams()
-    {
-      return configInfo;
-    }
-
-    /** Hash code.
-    */
-    public int hashCode()
-    {
-      return className.hashCode() + configInfo.hashCode();
-    }
-
-    /** Equals operator.
-    */
-    public boolean equals(Object o)
-    {
-      if (!(o instanceof PoolKey))
-        return false;
-
-      PoolKey pk = (PoolKey)o;
-      return pk.className.equals(className) && pk.configInfo.equals(configInfo);
-    }
-
-  }
-
-  /** This class represents a value in the pool hash, which corresponds to a given key.
-  */
-  public static class Pool
-  {
-    protected ArrayList stack = new ArrayList();
-    protected PoolKey key;
-    protected int numFree;
-
-    /** Constructor
-    */
-    public Pool(PoolKey pk, int maxCount)
-    {
-      key = pk;
-      numFree = maxCount;
-    }
-
-    /** Grab a mapping connector.
-    * If none exists, construct it using the information in the pool key.
-    *@return the connector.
-    */
-    public synchronized IMappingConnector getConnector(IThreadContext threadContext)
-      throws ManifoldCFException
-    {
-      while (numFree == 0)
-      {
-        try
-        {
-          wait();
-        }
-        catch (InterruptedException e)
-        {
-          throw new ManifoldCFException("Interrupted",e,ManifoldCFException.INTERRUPTED);
-        }
-      }
-
-      if (stack.size() == 0)
-      {
-        String className = key.getClassName();
-        ConfigParams configParams = key.getParams();
-
-        IMappingConnectorManager connMgr = MappingConnectorManagerFactory.make(threadContext);
-        if (connMgr.isInstalled(className) == false)
-          return null;
-
-        try
-        {
-          Class theClass = ManifoldCF.findClass(className);
-          Class[] argumentClasses = new Class[0];
-          // Look for a constructor
-          Constructor c = theClass.getConstructor(argumentClasses);
-          Object[] arguments = new Object[0];
-          Object o = c.newInstance(arguments);
-          if (!(o instanceof IMappingConnector))
-            throw new ManifoldCFException("Class '"+className+"' does not implement IMappingConnector.");
-          IMappingConnector newrc = (IMappingConnector)o;
-          newrc.connect(configParams);
-	  stack.add(newrc);
-        }
-        catch (InvocationTargetException e)
-        {
-          Throwable z = e.getTargetException();
-          if (z instanceof Error)
-            throw (Error)z;
-          else if (z instanceof RuntimeException)
-            throw (RuntimeException)z;
-          else
-            throw (ManifoldCFException)z;
-        }
-        catch (ClassNotFoundException e)
-        {
-          // If we get this exception, it may mean that the mapping is not registered.
-          if (connMgr.isInstalled(className) == false)
-            return null;
-
-          throw new ManifoldCFException("No mapping connector class '"+className+"' was found.",
-            e);
-        }
-        catch (NoSuchMethodException e)
-        {
-          throw new ManifoldCFException("No appropriate constructor for IMappingConnector implementation '"+
-            className+"'.  Need xxx(ConfigParams).",
-            e);
-        }
-        catch (SecurityException e)
-        {
-          throw new ManifoldCFException("Protected constructor for IMappingConnector implementation '"+className+"'",
-            e);
-        }
-        catch (IllegalAccessException e)
-        {
-          throw new ManifoldCFException("Unavailable constructor for IMappingConnector implementation '"+className+"'",
-            e);
-        }
-        catch (IllegalArgumentException e)
-        {
-          throw new ManifoldCFException("Shouldn't happen!!!",e);
-        }
-        catch (InstantiationException e)
-        {
-          throw new ManifoldCFException("InstantiationException for IMappingConnector implementation '"+className+"'",
-            e);
-        }
-        catch (ExceptionInInitializerError e)
-        {
-          throw new ManifoldCFException("ExceptionInInitializerError for IMappingConnector implementation '"+className+"'",
-            e);
-        }
-      }
-      
-      // Since thread context set can fail, do that before we remove it from the pool.
-      IMappingConnector rc = (IMappingConnector)stack.get(stack.size()-1);
-      rc.setThreadContext(threadContext);
-      stack.remove(stack.size()-1);
-      numFree--;
-
-      return rc;
-    }
-
-    /** Release a repository connector to the pool.
-    *@param connector is the connector.
-    */
-    public synchronized void releaseConnector(IMappingConnector connector)
-      throws ManifoldCFException
-    {
-      if (connector == null)
-        return;
-
-      // Make sure connector knows it's released
-      connector.clearThreadContext();
-      // Append
-      stack.add(connector);
-      numFree++;
-      notifyAll();
-    }
-
-    /** Notify all free connectors.
-    */
-    public synchronized void pollAll(IThreadContext threadContext)
-      throws ManifoldCFException
-    {
-      int i = 0;
-      while (i < stack.size())
-      {
-        IConnector rc = (IConnector)stack.get(i++);
-        // Notify
-        rc.setThreadContext(threadContext);
-        try
-        {
-          rc.poll();
-        }
-        finally
-        {
-          rc.clearThreadContext();
-        }
-      }
-    }
-
-    /** Release all free connectors.
-    */
-    public synchronized void releaseAll(IThreadContext threadContext)
-      throws ManifoldCFException
-    {
-      while (stack.size() > 0)
-      {
-        // Disconnect
-        IConnector rc = (IConnector)stack.get(stack.size()-1);
-        rc.setThreadContext(threadContext);
-        try
-        {
-          rc.disconnect();
-          stack.remove(stack.size()-1);
-        }
-        finally
-        {
-          rc.clearThreadContext();
-        }
-      }
-    }
-
-  }
-
-
-
 }
 

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java Thu Dec  5 10:31:01 2013
@@ -50,114 +50,123 @@ public class AuthCheckThread extends Thr
   {
     // Create a thread context object.
     IThreadContext threadContext = ThreadContextFactory.make();
-
-    // Loop
-    while (true)
+    try
     {
-      // Do another try/catch around everything in the loop
-      try
+      // Create an authority connection pool object.
+      IAuthorityConnectorPool authorityConnectorPool = AuthorityConnectorPoolFactory.make(threadContext);
+      
+      // Loop
+      while (true)
       {
-        if (Thread.currentThread().isInterrupted())
-          throw new ManifoldCFException("Interrupted",ManifoldCFException.INTERRUPTED);
+        // Do another try/catch around everything in the loop
+        try
+        {
+          if (Thread.currentThread().isInterrupted())
+            throw new ManifoldCFException("Interrupted",ManifoldCFException.INTERRUPTED);
 
-        // Wait for a request.
-        AuthRequest theRequest = requestQueue.getRequest();
+          // Wait for a request.
+          AuthRequest theRequest = requestQueue.getRequest();
 
-        // Try to fill the request before going back to sleep.
-        if (Logging.authorityService.isDebugEnabled())
-        {
-          Logging.authorityService.debug(" Calling connector class '"+theRequest.getClassName()+"'");
-        }
+          // Try to fill the request before going back to sleep.
+          if (Logging.authorityService.isDebugEnabled())
+          {
+            Logging.authorityService.debug(" Calling connector class '"+theRequest.getAuthorityConnection().getClassName()+"'");
+          }
 
-        AuthorizationResponse response = null;
-        Throwable exception = null;
+          AuthorizationResponse response = null;
+          Throwable exception = null;
 
-        // Grab an authorization response only if there's a user
-        if (theRequest.getUserID() != null)
-        {
-          try
+          // Grab an authorization response only if there's a user
+          if (theRequest.getUserID() != null)
           {
-            IAuthorityConnector connector = AuthorityConnectorFactory.grab(threadContext,
-              theRequest.getClassName(),
-              theRequest.getConfigurationParams(),
-              theRequest.getMaxConnections());
-            // If this is null, we MUST treat this as an "unauthorized" condition!!
-            // We signal that by setting the exception value.
             try
             {
-              if (connector == null)
-                exception = new ManifoldCFException("Authority connector "+theRequest.getClassName()+" is not registered.");
-              else
+              IAuthorityConnector connector = authorityConnectorPool.grab(theRequest.getAuthorityConnection());
+              // If this is null, we MUST treat this as an "unauthorized" condition!!
+              // We signal that by setting the exception value.
+              try
               {
-                // Get the acl for the user
-                try
+                if (connector == null)
+                  exception = new ManifoldCFException("Authority connector "+theRequest.getAuthorityConnection().getClassName()+" is not registered.");
+                else
                 {
-                  response = connector.getAuthorizationResponse(theRequest.getUserID());
-                }
-                catch (ManifoldCFException e)
-                {
-                  if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-                    throw e;
-                  Logging.authorityService.warn("Authority error: "+e.getMessage(),e);
-                  response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getClassName(),theRequest.getUserID());
-                }
+                  // Get the acl for the user
+                  try
+                  {
+                    response = connector.getAuthorizationResponse(theRequest.getUserID());
+                  }
+                  catch (ManifoldCFException e)
+                  {
+                    if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+                      throw e;
+                    Logging.authorityService.warn("Authority error: "+e.getMessage(),e);
+                    response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getAuthorityConnection().getClassName(),theRequest.getUserID());
+                  }
 
+                }
+              }
+              finally
+              {
+                authorityConnectorPool.release(connector);
               }
             }
-            finally
+            catch (ManifoldCFException e)
             {
-              AuthorityConnectorFactory.release(connector);
+              if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+                throw e;
+              Logging.authorityService.warn("Authority connection exception: "+e.getMessage(),e);
+              response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getAuthorityConnection().getClassName(),theRequest.getUserID());
+              if (response == null)
+                exception = e;
+            }
+            catch (Throwable e)
+            {
+              Logging.authorityService.warn("Authority connection error: "+e.getMessage(),e);
+              response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getAuthorityConnection().getClassName(),theRequest.getUserID());
+              if (response == null)
+                exception = e;
             }
           }
-          catch (ManifoldCFException e)
-          {
-            if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-              throw e;
-            Logging.authorityService.warn("Authority connection exception: "+e.getMessage(),e);
-            response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getClassName(),theRequest.getUserID());
-            if (response == null)
-              exception = e;
-          }
-          catch (Throwable e)
-          {
-            Logging.authorityService.warn("Authority connection error: "+e.getMessage(),e);
-            response = AuthorityConnectorFactory.getDefaultAuthorizationResponse(threadContext,theRequest.getClassName(),theRequest.getUserID());
-            if (response == null)
-              exception = e;
-          }
-        }
 
-        // The request is complete
-        theRequest.completeRequest(response,exception);
+          // The request is complete
+          theRequest.completeRequest(response,exception);
 
-        // Repeat, and only go to sleep if there are no more requests.
-      }
-      catch (ManifoldCFException e)
-      {
-        if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-          break;
+          // Repeat, and only go to sleep if there are no more requests.
+        }
+        catch (ManifoldCFException e)
+        {
+          if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+            break;
 
-        // Log it, but keep the thread alive
-        Logging.authorityService.error("Exception tossed: "+e.getMessage(),e);
+          // Log it, but keep the thread alive
+          Logging.authorityService.error("Exception tossed: "+e.getMessage(),e);
 
-        if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)
+          if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)
+          {
+            // Shut the whole system down!
+            System.exit(1);
+          }
+
+        }
+        catch (InterruptedException e)
         {
-          // Shut the whole system down!
-          System.exit(1);
+          // We're supposed to quit
+          break;
+        }
+        catch (Throwable e)
+        {
+          // A more severe error - but stay alive
+          Logging.authorityService.fatal("Error tossed: "+e.getMessage(),e);
         }
-
-      }
-      catch (InterruptedException e)
-      {
-        // We're supposed to quit
-        break;
-      }
-      catch (Throwable e)
-      {
-        // A more severe error - but stay alive
-        Logging.authorityService.fatal("Error tossed: "+e.getMessage(),e);
       }
     }
+    catch (ManifoldCFException e)
+    {
+      // Severe error on initialization
+      System.err.println("Authority service auth check thread could not start - shutting down");
+      Logging.authorityService.fatal("AuthCheckThread initialization error tossed: "+e.getMessage(),e);
+      System.exit(-300);
+    }
   }
 
 }

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthRequest.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthRequest.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthRequest.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthRequest.java Thu Dec  5 10:31:01 2013
@@ -32,10 +32,8 @@ public class AuthRequest
 
   // This is where the request data actually lives
   protected String userID;
-  protected final String className;
+  protected final IAuthorityConnection authorityConnection;
   protected final String identifyingString;
-  protected final ConfigParams configParameters;
-  protected final int maxConnections;
 
   // These are the possible results of the request
   protected boolean answerComplete = false;
@@ -44,12 +42,10 @@ public class AuthRequest
 
   /** Construct the request, and record the question.
   */
-  public AuthRequest(String className, String identifyingString, ConfigParams configParameters, int maxConnections)
+  public AuthRequest(IAuthorityConnection authorityConnection, String identifyingString)
   {
-    this.className = className;
+    this.authorityConnection = authorityConnection;
     this.identifyingString = identifyingString;
-    this.configParameters = configParameters;
-    this.maxConnections = maxConnections;
   }
 
   /** Set the user ID we'll be using */
@@ -64,10 +60,10 @@ public class AuthRequest
     return userID;
   }
 
-  /** Get the class name */
-  public String getClassName()
+  /** Get the authority connection */
+  public IAuthorityConnection getAuthorityConnection()
   {
-    return className;
+    return authorityConnection;
   }
 
   /** Get the identifying string, to pass back to the user if there was a problem */
@@ -76,18 +72,6 @@ public class AuthRequest
     return identifyingString;
   }
 
-  /** Get the configuration parameters */
-  public ConfigParams getConfigurationParams()
-  {
-    return configParameters;
-  }
-
-  /** Get the maximum number of connections */
-  public int getMaxConnections()
-  {
-    return maxConnections;
-  }
-
   /** Wait for an auth request to be complete.
   */
   public void waitForComplete()

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java Thu Dec  5 10:31:01 2013
@@ -52,6 +52,8 @@ public class IdleCleanupThread extends T
       // Create a thread context object.
       IThreadContext threadContext = ThreadContextFactory.make();
       ICacheManager cacheManager = CacheManagerFactory.make(threadContext);
+      IAuthorityConnectorPool authorityConnectorPool = AuthorityConnectorPoolFactory.make(threadContext);
+      IMappingConnectorPool mappingConnectorPool = MappingConnectorPoolFactory.make(threadContext);
       
       // Loop
       while (true)
@@ -60,7 +62,8 @@ public class IdleCleanupThread extends T
         try
         {
           // Do the cleanup
-          AuthorityConnectorFactory.pollAllConnectors(threadContext);
+          authorityConnectorPool.pollAllConnectors();
+          mappingConnectorPool.pollAllConnectors();
           cacheManager.expireObjects(System.currentTimeMillis());
           
           // Sleep for the retry interval.
@@ -72,7 +75,7 @@ public class IdleCleanupThread extends T
             break;
 
           // Log it, but keep the thread alive
-          Logging.authorityService.error("Exception tossed",e);
+          Logging.authorityService.error("Exception tossed: "+e.getMessage(),e);
 
           if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)
           {

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=1548081&r1=1548080&r2=1548081&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 Thu Dec  5 10:31:01 2013
@@ -83,6 +83,26 @@ public class ManifoldCF extends org.apac
   
   public static void localCleanup(IThreadContext tc)
   {
+    // Since pools are a shared resource, we clean them up only
+    // when we are certain nothing else is using them in the JVM.
+    try
+    {
+      AuthorityConnectorPoolFactory.make(tc).closeAllConnectors();
+    }
+    catch (ManifoldCFException e)
+    {
+      if (Logging.authorityService != null)
+        Logging.authorityService.warn("Exception closing authority connection pool: "+e.getMessage(),e);
+    }
+    try
+    {
+      MappingConnectorPoolFactory.make(tc).closeAllConnectors();
+    }
+    catch (ManifoldCFException e)
+    {
+      if (Logging.authorityService != null)
+        Logging.authorityService.warn("Exception closing mapping connection pool: "+e.getMessage(),e);
+    }
   }
   
   /** Install all the authority manager system tables.
@@ -248,10 +268,10 @@ public class ManifoldCF extends org.apac
     }
 
     // Release all authority connectors
-    AuthorityConnectorFactory.closeAllConnectors(threadContext);
+    AuthorityConnectorPoolFactory.make(threadContext).flushUnusedConnectors();
     numAuthCheckThreads = 0;
     requestQueue = null;
-    MappingConnectorFactory.closeAllConnectors(threadContext);
+    MappingConnectorPoolFactory.make(threadContext).flushUnusedConnectors();
     numMappingThreads = 0;
     mappingRequestQueue = null;
   }

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingRequest.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingRequest.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingRequest.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingRequest.java Thu Dec  5 10:31:01 2013
@@ -32,10 +32,8 @@ public class MappingRequest
 
   // This is where the request data actually lives
   protected String userID;
-  protected final String className;
+  protected final IMappingConnection mappingConnection;
   protected final String identifyingString;
-  protected final ConfigParams configParameters;
-  protected final int maxConnections;
 
   // These are the possible results of the request
   protected boolean answerComplete = false;
@@ -44,12 +42,10 @@ public class MappingRequest
 
   /** Construct the request, and record the question.
   */
-  public MappingRequest(String className, String identifyingString, ConfigParams configParameters, int maxConnections)
+  public MappingRequest(IMappingConnection mappingConnection, String identifyingString)
   {
-    this.className = className;
+    this.mappingConnection = mappingConnection;
     this.identifyingString = identifyingString;
-    this.configParameters = configParameters;
-    this.maxConnections = maxConnections;
   }
 
   /** Set the user ID we'll be using */
@@ -64,10 +60,11 @@ public class MappingRequest
     return userID;
   }
   
-  /** Get the class name */
-  public String getClassName()
+  /** Get the mapping connection.
+  */
+  public IMappingConnection getMappingConnection()
   {
-    return className;
+    return mappingConnection;
   }
 
   /** Get the identifying string, to pass back to the user if there was a problem */
@@ -76,18 +73,6 @@ public class MappingRequest
     return identifyingString;
   }
 
-  /** Get the configuration parameters */
-  public ConfigParams getConfigurationParams()
-  {
-    return configParameters;
-  }
-
-  /** Get the maximum number of connections */
-  public int getMaxConnections()
-  {
-    return maxConnections;
-  }
-
   /** Wait for an auth request to be complete.
   */
   public void waitForComplete()

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java Thu Dec  5 10:31:01 2013
@@ -49,107 +49,114 @@ public class MappingThread extends Threa
   {
     // Create a thread context object.
     IThreadContext threadContext = ThreadContextFactory.make();
-
-    // Loop
-    while (true)
+    try
     {
-      // Do another try/catch around everything in the loop
-      try
+      IMappingConnectorPool mappingConnectorPool = MappingConnectorPoolFactory.make(threadContext);
+      // Loop
+      while (true)
       {
-        if (Thread.currentThread().isInterrupted())
-          throw new ManifoldCFException("Interrupted",ManifoldCFException.INTERRUPTED);
+        // Do another try/catch around everything in the loop
+        try
+        {
+          if (Thread.currentThread().isInterrupted())
+            throw new ManifoldCFException("Interrupted",ManifoldCFException.INTERRUPTED);
 
-        // Wait for a request.
-        MappingRequest theRequest = requestQueue.getRequest();
+          // Wait for a request.
+          MappingRequest theRequest = requestQueue.getRequest();
 
-        // Try to fill the request before going back to sleep.
-        if (Logging.authorityService.isDebugEnabled())
-        {
-          Logging.authorityService.debug(" Calling mapping connector class '"+theRequest.getClassName()+"'");
-        }
+          // Try to fill the request before going back to sleep.
+          if (Logging.authorityService.isDebugEnabled())
+          {
+            Logging.authorityService.debug(" Calling mapping connector class '"+theRequest.getMappingConnection().getClassName()+"'");
+          }
 
-	String outputUserID = null;
-        Throwable exception = null;
+          String outputUserID = null;
+          Throwable exception = null;
 
-        // Only try a mapping if we have a user to map...
-        if (theRequest.getUserID() != null)
-        {
-          try
+          // Only try a mapping if we have a user to map...
+          if (theRequest.getUserID() != null)
           {
-            IMappingConnector connector = MappingConnectorFactory.grab(threadContext,
-              theRequest.getClassName(),
-              theRequest.getConfigurationParams(),
-              theRequest.getMaxConnections());
             try
             {
-              if (connector == null)
-                exception = new ManifoldCFException("Mapping connector "+theRequest.getClassName()+" is not registered.");
-              else
+              IMappingConnector connector = mappingConnectorPool.grab(theRequest.getMappingConnection());
+              try
               {
-                // Do the mapping
-                try
+                if (connector == null)
+                  exception = new ManifoldCFException("Mapping connector "+theRequest.getMappingConnection().getClassName()+" is not registered.");
+                else
                 {
-                  outputUserID = connector.mapUser(theRequest.getUserID());
-                }
-                catch (ManifoldCFException e)
-                {
-                  if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-                    throw e;
-                  Logging.authorityService.warn("Mapping error: "+e.getMessage(),e);
-                }
+                  // Do the mapping
+                  try
+                  {
+                    outputUserID = connector.mapUser(theRequest.getUserID());
+                  }
+                  catch (ManifoldCFException e)
+                  {
+                    if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+                      throw e;
+                    Logging.authorityService.warn("Mapping error: "+e.getMessage(),e);
+                  }
 
+                }
+              }
+              finally
+              {
+                mappingConnectorPool.release(connector);
               }
             }
-            finally
+            catch (ManifoldCFException e)
             {
-              MappingConnectorFactory.release(connector);
+              if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+                throw e;
+              Logging.authorityService.warn("Mapping connection exception: "+e.getMessage(),e);
+              exception = e;
+            }
+            catch (Throwable e)
+            {
+              Logging.authorityService.warn("Mapping connection error: "+e.getMessage(),e);
+              exception = e;
             }
           }
-          catch (ManifoldCFException e)
-          {
-            if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-              throw e;
-            Logging.authorityService.warn("Mapping connection exception: "+e.getMessage(),e);
-            exception = e;
-          }
-          catch (Throwable e)
-          {
-            Logging.authorityService.warn("Mapping connection error: "+e.getMessage(),e);
-            exception = e;
-          }
-        }
 
-        // The request is complete
-        theRequest.completeRequest(outputUserID, exception);
+          // The request is complete
+          theRequest.completeRequest(outputUserID, exception);
 
-        // Repeat, and only go to sleep if there are no more requests.
-      }
-      catch (ManifoldCFException e)
-      {
-        if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
-          break;
+          // Repeat, and only go to sleep if there are no more requests.
+        }
+        catch (ManifoldCFException e)
+        {
+          if (e.getErrorCode() == ManifoldCFException.INTERRUPTED)
+            break;
 
-        // Log it, but keep the thread alive
-        Logging.authorityService.error("Exception tossed: "+e.getMessage(),e);
+          // Log it, but keep the thread alive
+          Logging.authorityService.error("Exception tossed: "+e.getMessage(),e);
 
-        if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)
+          if (e.getErrorCode() == ManifoldCFException.SETUP_ERROR)
+          {
+            // Shut the whole system down!
+            System.exit(1);
+          }
+
+        }
+        catch (InterruptedException e)
         {
-          // Shut the whole system down!
-          System.exit(1);
+          // We're supposed to quit
+          break;
+        }
+        catch (Throwable e)
+        {
+          // A more severe error - but stay alive
+          Logging.authorityService.fatal("Error tossed: "+e.getMessage(),e);
         }
-
-      }
-      catch (InterruptedException e)
-      {
-        // We're supposed to quit
-        break;
-      }
-      catch (Throwable e)
-      {
-        // A more severe error - but stay alive
-        Logging.authorityService.fatal("Error tossed: "+e.getMessage(),e);
       }
     }
+    catch (ManifoldCFException e)
+    {
+      // Severe error on initialization
+      System.err.println("Authority service mapping thread could not start - shutting down");
+      Logging.authorityService.fatal("MappingThread initialization error tossed: "+e.getMessage(),e);
+      System.exit(-300);
+    }
   }
 
 }

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/RepositoryConnectorFactory.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/RepositoryConnectorFactory.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/RepositoryConnectorFactory.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/RepositoryConnectorFactory.java Thu Dec  5 10:31:01 2013
@@ -29,28 +29,75 @@ import java.lang.reflect.*;
 
 /** This is the factory class for IRepositoryConnector objects.
 */
-public class RepositoryConnectorFactory
+public class RepositoryConnectorFactory extends ConnectorFactory<IRepositoryConnector>
 {
   public static final String _rcsid = "@(#)$Id: RepositoryConnectorFactory.java 988245 2010-08-23 18:39:35Z kwright $";
 
-  // Pool hash table.
-  // Keyed by PoolKey; value is Pool
-  protected static Map poolHash = new HashMap();
-
-  // private static HashMap checkedOutConnectors = new HashMap();
+  // Static factory
+  protected final static RepositoryConnectorFactory thisFactory = new RepositoryConnectorFactory();
 
   private RepositoryConnectorFactory()
   {
   }
 
+  @Override
+  protected boolean isInstalled(IThreadContext tc, String className)
+    throws ManifoldCFException
+  {
+    IConnectorManager connMgr = ConnectorManagerFactory.make(tc);
+    return connMgr.isInstalled(className);
+  }
+
+  /** Get the activities supported by this connector.
+  *@param className is the class name.
+  *@return the list of activities.
+  */
+  protected String[] getThisActivitiesList(IThreadContext threadContext, String className)
+    throws ManifoldCFException
+  {
+    IRepositoryConnector connector = getThisConnector(threadContext, className);
+    if (connector == null)
+      return null;
+    String[] values = connector.getActivitiesList();
+    java.util.Arrays.sort(values);
+    return values;
+  }
+
+  /** Get the link types logged by this connector.
+  *@param className is the class name.
+  *@return the list of link types, in sorted order.
+  */
+  protected String[] getThisRelationshipTypes(IThreadContext threadContext, String className)
+    throws ManifoldCFException
+  {
+    IRepositoryConnector connector = getThisConnector(threadContext, className);
+    if (connector == null)
+      return null;
+    String[] values = connector.getRelationshipTypes();
+    java.util.Arrays.sort(values);
+    return values;
+  }
+
+  /** Get the operating mode for a connector.
+  *@param className is the class name.
+  *@return the connector operating model, as specified in IRepositoryConnector.
+  */
+  protected int getThisConnectorModel(IThreadContext threadContext, String className)
+    throws ManifoldCFException
+  {
+    IRepositoryConnector connector = getThisConnector(threadContext, className);
+    if (connector == null)
+      return -1;
+    return connector.getConnectorModel();
+  }
+
   /** Install connector.
   *@param className is the class name.
   */
   public static void install(IThreadContext threadContext, String className)
     throws ManifoldCFException
   {
-    IRepositoryConnector connector = getConnectorNoCheck(className);
-    connector.install(threadContext);
+    thisFactory.installThis(threadContext,className);
   }
 
   /** Uninstall connector.
@@ -59,8 +106,7 @@ public class RepositoryConnectorFactory
   public static void deinstall(IThreadContext threadContext, String className)
     throws ManifoldCFException
   {
-    IRepositoryConnector connector = getConnectorNoCheck(className);
-    connector.deinstall(threadContext);
+    thisFactory.deinstallThis(threadContext,className);
   }
 
   /** Get the activities supported by this connector.
@@ -70,12 +116,7 @@ public class RepositoryConnectorFactory
   public static String[] getActivitiesList(IThreadContext threadContext, String className)
     throws ManifoldCFException
   {
-    IRepositoryConnector connector = getConnector(threadContext, className);
-    if (connector == null)
-      return null;
-    String[] values = connector.getActivitiesList();
-    java.util.Arrays.sort(values);
-    return values;
+    return thisFactory.getThisActivitiesList(threadContext,className);
   }
 
   /** Get the link types logged by this connector.
@@ -85,12 +126,7 @@ public class RepositoryConnectorFactory
   public static String[] getRelationshipTypes(IThreadContext threadContext, String className)
     throws ManifoldCFException
   {
-    IRepositoryConnector connector = getConnector(threadContext, className);
-    if (connector == null)
-      return null;
-    String[] values = connector.getRelationshipTypes();
-    java.util.Arrays.sort(values);
-    return values;
+    return thisFactory.getThisRelationshipTypes(threadContext,className);
   }
 
   /** Get the operating mode for a connector.
@@ -100,10 +136,7 @@ public class RepositoryConnectorFactory
   public static int getConnectorModel(IThreadContext threadContext, String className)
     throws ManifoldCFException
   {
-    IRepositoryConnector connector = getConnector(threadContext, className);
-    if (connector == null)
-      return -1;
-    return connector.getConnectorModel();
+    return thisFactory.getThisConnectorModel(threadContext,className);
   }
 
   /** Output the configuration header section.
@@ -111,10 +144,7 @@ public class RepositoryConnectorFactory
   public static void outputConfigurationHeader(IThreadContext threadContext, String className, IHTTPOutput out, Locale locale, ConfigParams parameters, ArrayList tabsArray)
     throws ManifoldCFException, IOException
   {
-    IRepositoryConnector connector = getConnector(threadContext, className);
-    if (connector == null)
-      return;
-    connector.outputConfigurationHeader(threadContext,out,locale,parameters,tabsArray);
+    thisFactory.outputThisConfigurationHeader(threadContext,className,out,locale,parameters,tabsArray);
   }
 
   /** Output the configuration body section.
@@ -122,10 +152,7 @@ public class RepositoryConnectorFactory
   public static void outputConfigurationBody(IThreadContext threadContext, String className, IHTTPOutput out, Locale locale, ConfigParams parameters, String tabName)
     throws ManifoldCFException, IOException
   {
-    IRepositoryConnector connector = getConnector(threadContext, className);
-    if (connector == null)
-      return;
-    connector.outputConfigurationBody(threadContext,out,locale,parameters,tabName);
+    thisFactory.outputThisConfigurationBody(threadContext,className,out,locale,parameters,tabName);
   }
 
   /** Process configuration post data for a connector.
@@ -133,10 +160,7 @@ public class RepositoryConnectorFactory
   public static String processConfigurationPost(IThreadContext threadContext, String className, IPostParameters variableContext, Locale locale, ConfigParams configParams)
     throws ManifoldCFException
   {
-    IRepositoryConnector connector = getConnector(threadContext, className);
-    if (connector == null)
-      return null;
-    return connector.processConfigurationPost(threadContext,variableContext,locale,configParams);
+    return thisFactory.processThisConfigurationPost(threadContext,className,variableContext,locale,configParams);
   }
   
   /** View connector configuration.
@@ -144,11 +168,7 @@ public class RepositoryConnectorFactory
   public static void viewConfiguration(IThreadContext threadContext, String className, IHTTPOutput out, Locale locale, ConfigParams configParams)
     throws ManifoldCFException, IOException
   {
-    IRepositoryConnector connector = getConnector(threadContext, className);
-    // We want to be able to view connections even if they have unregistered connectors.
-    if (connector == null)
-      return;
-    connector.viewConfiguration(threadContext,out,locale,configParams);
+    thisFactory.viewThisConfiguration(threadContext,className,out,locale,configParams);
   }
 
   /** Get a repository connector instance, without checking for installed connector.
@@ -158,619 +178,7 @@ public class RepositoryConnectorFactory
   public static IRepositoryConnector getConnectorNoCheck(String className)
     throws ManifoldCFException
   {
-    try
-    {
-      Class theClass = ManifoldCF.findClass(className);
-      Class[] argumentClasses = new Class[0];
-      // Look for a constructor
-      Constructor c = theClass.getConstructor(argumentClasses);
-      Object[] arguments = new Object[0];
-      Object o = c.newInstance(arguments);
-      if (!(o instanceof IRepositoryConnector))
-        throw new ManifoldCFException("Class '"+className+"' does not implement IRepositoryConnector.");
-      return (IRepositoryConnector)o;
-    }
-    catch (InvocationTargetException e)
-    {
-      Throwable z = e.getTargetException();
-      if (z instanceof Error)
-        throw (Error)z;
-      else if (z instanceof RuntimeException)
-        throw (RuntimeException)z;
-      else
-        throw (ManifoldCFException)z;
-    }
-    catch (ClassNotFoundException e)
-    {
-      throw new ManifoldCFException("No repository connector class '"+className+"' was found.",
-        e);
-    }
-    catch (NoSuchMethodException e)
-    {
-      throw new ManifoldCFException("No appropriate constructor for IRepositoryConnector implementation '"+
-        className+"'.  Need xxx(ConfigParams).",
-        e);
-    }
-    catch (SecurityException e)
-    {
-      throw new ManifoldCFException("Protected constructor for IRepositoryConnector implementation '"+className+"'",
-        e);
-    }
-    catch (IllegalAccessException e)
-    {
-      throw new ManifoldCFException("Unavailable constructor for IRepositoryConnector implementation '"+className+"'",
-        e);
-    }
-    catch (IllegalArgumentException e)
-    {
-      throw new ManifoldCFException("Shouldn't happen!!!",e);
-    }
-    catch (InstantiationException e)
-    {
-      throw new ManifoldCFException("InstantiationException for IRepositoryConnector implementation '"+className+"'",
-        e);
-    }
-    catch (ExceptionInInitializerError e)
-    {
-      throw new ManifoldCFException("ExceptionInInitializerError for IRepositoryConnector implementation '"+className+"'",
-        e);
-    }
-
+    return thisFactory.getThisConnectorNoCheck(className);
   }
 
-  /** Get a repository connector instance.
-  *@param className is the class name.
-  *@return the instance.
-  */
-  protected static IRepositoryConnector getConnector(IThreadContext threadContext, String className)
-    throws ManifoldCFException
-  {
-    IConnectorManager connMgr = ConnectorManagerFactory.make(threadContext);
-    if (connMgr.isInstalled(className) == false)
-      return null;
-
-    try
-    {
-      Class theClass = ManifoldCF.findClass(className);
-      Class[] argumentClasses = new Class[0];
-      // Look for a constructor
-      Constructor c = theClass.getConstructor(argumentClasses);
-      Object[] arguments = new Object[0];
-      Object o = c.newInstance(arguments);
-      if (!(o instanceof IRepositoryConnector))
-        throw new ManifoldCFException("Class '"+className+"' does not implement IRepositoryConnector.");
-      return (IRepositoryConnector)o;
-    }
-    catch (InvocationTargetException e)
-    {
-      Throwable z = e.getTargetException();
-      if (z instanceof Error)
-        throw (Error)z;
-      else if (z instanceof RuntimeException)
-        throw (RuntimeException)z;
-      else
-        throw (ManifoldCFException)z;
-    }
-    catch (ClassNotFoundException e)
-    {
-      // This MAY mean that an existing connector has been uninstalled; check out this possibility!
-      // We return null because that is the signal that we cannot get a connector instance for that reason.
-      if (connMgr.isInstalled(className) == false)
-        return null;
-
-      throw new ManifoldCFException("No repository connector class '"+className+"' was found.",
-        e);
-    }
-    catch (NoSuchMethodException e)
-    {
-      throw new ManifoldCFException("No appropriate constructor for IRepositoryConnector implementation '"+
-        className+"'.  Need xxx(ConfigParams).",
-        e);
-    }
-    catch (SecurityException e)
-    {
-      throw new ManifoldCFException("Protected constructor for IRepositoryConnector implementation '"+className+"'",
-        e);
-    }
-    catch (IllegalAccessException e)
-    {
-      throw new ManifoldCFException("Unavailable constructor for IRepositoryConnector implementation '"+className+"'",
-        e);
-    }
-    catch (IllegalArgumentException e)
-    {
-      throw new ManifoldCFException("Shouldn't happen!!!",e);
-    }
-    catch (InstantiationException e)
-    {
-      throw new ManifoldCFException("InstantiationException for IRepositoryConnector implementation '"+className+"'",
-        e);
-    }
-    catch (ExceptionInInitializerError e)
-    {
-      throw new ManifoldCFException("ExceptionInInitializerError for IRepositoryConnector implementation '"+className+"'",
-        e);
-    }
-
-  }
-
-  /** Get multiple repository connectors, all at once.  Do this in a particular order
-  * so that any connector exhaustion will not cause a deadlock.
-  */
-  public static IRepositoryConnector[] grabMultiple(IThreadContext threadContext,
-    String[] orderingKeys, String[] classNames, ConfigParams[] configInfos, int[] maxPoolSizes)
-    throws ManifoldCFException
-  {
-    IRepositoryConnector[] rval = new IRepositoryConnector[classNames.length];
-    HashMap orderMap = new HashMap();
-    int i = 0;
-    while (i < orderingKeys.length)
-    {
-      if (orderMap.get(orderingKeys[i]) != null)
-        throw new ManifoldCFException("Found duplicate order key");
-      orderMap.put(orderingKeys[i],new Integer(i));
-      i++;
-    }
-    java.util.Arrays.sort(orderingKeys);
-    i = 0;
-    while (i < orderingKeys.length)
-    {
-      String orderingKey = orderingKeys[i];
-      int index = ((Integer)orderMap.get(orderingKey)).intValue();
-      String className = classNames[index];
-      ConfigParams cp = configInfos[index];
-      int maxPoolSize = maxPoolSizes[index];
-      try
-      {
-        IRepositoryConnector connector = grab(threadContext,className,cp,maxPoolSize);
-        rval[index] = connector;
-      }
-      catch (Throwable e)
-      {
-        while (i > 0)
-        {
-          i--;
-          orderingKey = orderingKeys[i];
-          index = ((Integer)orderMap.get(orderingKey)).intValue();
-          try
-          {
-            release(rval[index]);
-          }
-          catch (ManifoldCFException e2)
-          {
-          }
-        }
-        if (e instanceof ManifoldCFException)
-          throw (ManifoldCFException)e;
-	else if (e instanceof RuntimeException)
-          throw (RuntimeException)e;
-        throw (Error)e;
-      }
-      i++;
-    }
-    return rval;
-  }
-
-  /** Get a repository connector.
-  * The connector is specified by its class and its parameters.
-  *@param threadContext is the current thread context.
-  *@param className is the name of the class to get a connector for.
-  *@param configInfo are the name/value pairs constituting configuration info
-  * for this class.
-  */
-  public static IRepositoryConnector grab(IThreadContext threadContext,
-    String className, ConfigParams configInfo, int maxPoolSize)
-    throws ManifoldCFException
-  {
-    // We want to get handles off the pool and use them.  But the
-    // handles we fetch have to have the right config information.
-
-    // Use the classname and config info to build a pool key.  This
-    // key will be discarded if we actually have to save a key persistently,
-    // since we avoid copying the configInfo unnecessarily.
-    PoolKey pk = new PoolKey(className,configInfo);
-    Pool p;
-    synchronized (poolHash)
-    {
-      p = (Pool)poolHash.get(pk);
-      if (p == null)
-      {
-        pk = new PoolKey(className,configInfo.duplicate());
-        p = new Pool(pk,maxPoolSize);
-        poolHash.put(pk,p);
-      }
-    }
-
-    IRepositoryConnector rval = p.getConnector(threadContext);
-
-    // Enter it in the pool so we can figure out whether it closed
-    // synchronized (checkedOutConnectors)
-    // {
-    //      checkedOutConnectors.put(rval.toString(),new ConnectorTracker(rval));
-    // }
-
-    return rval;
-
-  }
-
-  /** Release multiple repository connectors.
-  */
-  public static void releaseMultiple(IRepositoryConnector[] connectors)
-    throws ManifoldCFException
-  {
-    int i = 0;
-    ManifoldCFException currentException = null;
-    while (i < connectors.length)
-    {
-      IRepositoryConnector c = connectors[i++];
-      try
-      {
-        release(c);
-      }
-      catch (ManifoldCFException e)
-      {
-        if (currentException == null)
-          currentException = e;
-      }
-    }
-    if (currentException != null)
-      throw currentException;
-  }
-
-  /** Release a repository connector.
-  *@param connector is the connector to release.
-  */
-  public static void release(IRepositoryConnector connector)
-    throws ManifoldCFException
-  {
-    // If the connector is null, skip the release, because we never really got the connector in the first place.
-    if (connector == null)
-      return;
-
-    // Figure out which pool this goes on, and put it there
-    PoolKey pk = new PoolKey(connector.getClass().getName(),connector.getConfiguration());
-    Pool p;
-    synchronized (poolHash)
-    {
-      p = (Pool)poolHash.get(pk);
-    }
-
-    p.releaseConnector(connector);
-
-    // synchronized (checkedOutConnectors)
-    // {
-    //      checkedOutConnectors.remove(connector.toString());
-    // }
-
-  }
-
-  /** Idle notification for inactive repository connector handles.
-  * This method polls all inactive handles.
-  */
-  public static void pollAllConnectors(IThreadContext threadContext)
-    throws ManifoldCFException
-  {
-    // System.out.println("Pool stats:");
-
-    // Go through the whole pool and notify everyone
-    synchronized (poolHash)
-    {
-      Iterator iter = poolHash.values().iterator();
-      while (iter.hasNext())
-      {
-        Pool p = (Pool)iter.next();
-        p.pollAll(threadContext);
-        //p.printStats();
-      }
-    }
-
-    // System.out.println("About to check if any repository connector instances have been abandoned...");
-    // checkConnectors(System.currentTimeMillis());
-  }
-
-  /** Clean up all open repository connector handles.
-  * This method is called when the connector pool needs to be flushed,
-  * to free resources.
-  *@param threadContext is the local thread context.
-  */
-  public static void closeAllConnectors(IThreadContext threadContext)
-    throws ManifoldCFException
-  {
-    // Go through the whole pool and clean it out
-    synchronized (poolHash)
-    {
-      Iterator iter = poolHash.values().iterator();
-      while (iter.hasNext())
-      {
-        Pool p = (Pool)iter.next();
-        p.releaseAll(threadContext);
-      }
-    }
-  }
-
-  /** Track connection allocation */
-  // public static void checkConnectors(long currentTime)
-  // {
-  //      synchronized (checkedOutConnectors)
-  //      {
-  //              Iterator iter = checkedOutConnectors.keySet().iterator();
-  //              while (iter.hasNext())
-  //              {
-  //                      Object key = iter.next();
-  //                      ConnectorTracker ct = (ConnectorTracker)checkedOutConnectors.get(key);
-  //                      if (ct.hasExpired(currentTime))
-  //                              ct.printDetails();
-  //              }
-  //      }
-  // }
-
-  /** This is an immutable pool key class, which describes a pool in terms of two independent keys.
-  */
-  public static class PoolKey
-  {
-    protected String className;
-    protected ConfigParams configInfo;
-
-    /** Constructor.
-    */
-    public PoolKey(String className, Map configInfo)
-    {
-      this.className = className;
-      this.configInfo = new ConfigParams(configInfo);
-    }
-
-    public PoolKey(String className, ConfigParams configInfo)
-    {
-      this.className = className;
-      this.configInfo = configInfo;
-    }
-
-    /** Get the class name.
-    *@return the class name.
-    */
-    public String getClassName()
-    {
-      return className;
-    }
-
-    /** Get the config info.
-    *@return the params
-    */
-    public ConfigParams getParams()
-    {
-      return configInfo;
-    }
-
-    /** Hash code.
-    */
-    public int hashCode()
-    {
-      return className.hashCode() + configInfo.hashCode();
-    }
-
-    /** Equals operator.
-    */
-    public boolean equals(Object o)
-    {
-      if (!(o instanceof PoolKey))
-        return false;
-
-      PoolKey pk = (PoolKey)o;
-      return pk.className.equals(className) && pk.configInfo.equals(configInfo);
-    }
-
-  }
-
-  /** This class represents a value in the pool hash, which corresponds to a given key.
-  */
-  public static class Pool
-  {
-    protected ArrayList stack = new ArrayList();
-    protected PoolKey key;
-    protected int numFree;
-
-    /** Constructor
-    */
-    public Pool(PoolKey pk, int maxCount)
-    {
-      key = pk;
-      numFree = maxCount;
-    }
-
-    /** Grab a repository connector.
-    * If none exists, construct it using the information in the pool key.
-    *@return the connector, or null if no connector could be connected.
-    */
-    public synchronized IRepositoryConnector getConnector(IThreadContext threadContext)
-      throws ManifoldCFException
-    {
-      while (numFree == 0)
-      {
-        try
-        {
-          wait();
-        }
-        catch (InterruptedException e)
-        {
-          throw new ManifoldCFException("Interrupted: "+e.getMessage(),e,ManifoldCFException.INTERRUPTED);
-        }
-      }
-
-      if (stack.size() == 0)
-      {
-        String className = key.getClassName();
-        ConfigParams configParams = key.getParams();
-
-        IConnectorManager connMgr = ConnectorManagerFactory.make(threadContext);
-        if (connMgr.isInstalled(className) == false)
-          return null;
-
-        try
-        {
-          Class theClass = ManifoldCF.findClass(className);
-          Class[] argumentClasses = new Class[0];
-          // Look for a constructor
-          Constructor c = theClass.getConstructor(argumentClasses);
-          Object[] arguments = new Object[0];
-          Object o = c.newInstance(arguments);
-          if (!(o instanceof IRepositoryConnector))
-            throw new ManifoldCFException("Class '"+className+"' does not implement IRepositoryConnector.");
-          IRepositoryConnector newrc = (IRepositoryConnector)o;
-          newrc.connect(configParams);
-          stack.add(newrc);
-        }
-        catch (InvocationTargetException e)
-        {
-          Throwable z = e.getTargetException();
-          if (z instanceof Error)
-            throw (Error)z;
-          else if (z instanceof RuntimeException)
-            throw (RuntimeException)z;
-          else
-            throw (ManifoldCFException)z;
-        }
-        catch (ClassNotFoundException e)
-        {
-          // If we see this exception, it COULD mean that the connector was uninstalled, and we happened to get here
-          // after that occurred.
-          // We return null because that is the signal that we cannot get a connector instance for that reason.
-          if (connMgr.isInstalled(className) == false)
-            return null;
-
-          throw new ManifoldCFException("No repository connector class '"+className+"' was found.",
-            e);
-        }
-        catch (NoSuchMethodException e)
-        {
-          throw new ManifoldCFException("No appropriate constructor for IRepositoryConnector implementation '"+
-            className+"'.  Need xxx(ConfigParams).",
-            e);
-        }
-        catch (SecurityException e)
-        {
-          throw new ManifoldCFException("Protected constructor for IRepositoryConnector implementation '"+className+"'",
-            e);
-        }
-        catch (IllegalAccessException e)
-        {
-          throw new ManifoldCFException("Unavailable constructor for IRepositoryConnector implementation '"+className+"'",
-            e);
-        }
-        catch (IllegalArgumentException e)
-        {
-          throw new ManifoldCFException("Shouldn't happen!!!",e);
-        }
-        catch (InstantiationException e)
-        {
-          throw new ManifoldCFException("InstantiationException for IRepositoryConnector implementation '"+className+"'",
-            e);
-        }
-        catch (ExceptionInInitializerError e)
-        {
-          throw new ManifoldCFException("ExceptionInInitializerError for IRepositoryConnector implementation '"+className+"'",
-            e);
-        }
-      }
-
-      // Since thread context set can fail, do that before we remove it from the pool.
-      IRepositoryConnector rc = (IRepositoryConnector)stack.get(stack.size()-1);
-      rc.setThreadContext(threadContext);
-      stack.remove(stack.size()-1);
-      numFree--;
-
-      return rc;
-    }
-
-    /** Release a repository connector to the pool.
-    *@param connector is the connector.
-    */
-    public synchronized void releaseConnector(IRepositoryConnector connector)
-      throws ManifoldCFException
-    {
-      if (connector == null)
-        return;
-
-      // Make sure connector knows it's released
-      connector.clearThreadContext();
-      // Append
-      stack.add(connector);
-      numFree++;
-      notifyAll();
-    }
-
-    /** Notify all free connectors.
-    */
-    public synchronized void pollAll(IThreadContext threadContext)
-      throws ManifoldCFException
-    {
-      int i = 0;
-      while (i < stack.size())
-      {
-        IConnector rc = (IConnector)stack.get(i++);
-        // Notify
-        rc.setThreadContext(threadContext);
-        try
-        {
-          rc.poll();
-        }
-        finally
-        {
-          rc.clearThreadContext();
-        }
-      }
-    }
-
-    /** Release all free connectors.
-    */
-    public synchronized void releaseAll(IThreadContext threadContext)
-      throws ManifoldCFException
-    {
-      while (stack.size() > 0)
-      {
-        // Disconnect
-        IConnector rc = (IConnector)stack.get(stack.size()-1);
-        rc.setThreadContext(threadContext);
-        try
-        {
-          rc.disconnect();
-          stack.remove(stack.size()-1);
-        }
-        finally
-        {
-          rc.clearThreadContext();
-        }
-      }
-    }
-
-    /** Print pool stats */
-    public synchronized void printStats()
-    {
-      System.out.println(" Class name = "+key.getClassName()+"; Number free = "+Integer.toString(numFree));
-    }
-  }
-
-
-  protected static class ConnectorTracker
-  {
-    protected IRepositoryConnector theConnector;
-    protected long checkoutTime;
-    protected Exception theTrace;
-
-    public ConnectorTracker(IRepositoryConnector theConnector)
-    {
-      this.theConnector = theConnector;
-      this.checkoutTime = System.currentTimeMillis();
-      this.theTrace = new Exception("Stack trace");
-    }
-
-    public boolean hasExpired(long currentTime)
-    {
-      return (checkoutTime + 300000L < currentTime);
-    }
-
-    public void printDetails()
-    {
-      Logging.threads.error("Connector instance may have been abandoned: "+theConnector.toString(),theTrace);
-    }
-  }
 }

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java Thu Dec  5 10:31:01 2013
@@ -42,6 +42,7 @@ public class JobManager implements IJobM
   protected final IDBInterface database;
   protected final IOutputConnectionManager outputMgr;
   protected final IRepositoryConnectionManager connectionMgr;
+  protected final IRepositoryConnectorPool repositoryConnectorPool;
   protected final ILockManager lockManager;
   protected final IThreadContext threadContext;
   protected final JobQueue jobQueue;
@@ -69,6 +70,7 @@ public class JobManager implements IJobM
     eventManager = new EventManager(database);
     outputMgr = OutputConnectionManagerFactory.make(threadContext);
     connectionMgr = RepositoryConnectionManagerFactory.make(threadContext);
+    repositoryConnectorPool = RepositoryConnectorPoolFactory.make(threadContext);
     lockManager = LockManagerFactory.make(threadContext);
   }
 
@@ -2630,17 +2632,11 @@ public class JobManager implements IJobM
     // at the connector factory level to make sure these requests are properly ordered.
 
     String[] orderingKeys = new String[connections.length];
-    String[] classNames = new String[connections.length];
-    ConfigParams[] configParams = new ConfigParams[connections.length];
-    int[] maxConnections = new int[connections.length];
     int k = 0;
     while (k < connections.length)
     {
       IRepositoryConnection connection = connections[k];
       orderingKeys[k] = connection.getName();
-      classNames[k] = connection.getClassName();
-      configParams[k] = connection.getConfigParams();
-      maxConnections[k] = connection.getMaxConnections();
       k++;
     }
     
@@ -2654,7 +2650,7 @@ public class JobManager implements IJobM
       try
       {
     
-        IRepositoryConnector[] connectors = RepositoryConnectorFactory.grabMultiple(threadContext,orderingKeys,classNames,configParams,maxConnections);
+        IRepositoryConnector[] connectors = repositoryConnectorPool.grabMultiple(orderingKeys,connections);
         try
         {
           // Hand the connectors off to the ThrottleLimit instance
@@ -2770,7 +2766,7 @@ public class JobManager implements IJobM
         }
         finally
         {
-          RepositoryConnectorFactory.releaseMultiple(connectors);
+          repositoryConnectorPool.releaseMultiple(connectors);
         }
       }
       finally

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=1548081&r1=1548080&r2=1548081&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 Thu Dec  5 10:31:01 2013
@@ -204,8 +204,7 @@ public class CrawlerAgent implements IAg
           break;
 
         // Calculate new priorities for all these documents
-        ManifoldCF.writeDocumentPriorities(threadContext,connectionManager,jobManager,docs,connectionMap,jobDescriptionMap,
-          rt,updateTime);
+        ManifoldCF.writeDocumentPriorities(threadContext,docs,connectionMap,jobDescriptionMap,rt,updateTime);
 
         Logging.threads.debug("Reprioritized "+Integer.toString(docs.length)+" not-yet-processed documents in "+new Long(System.currentTimeMillis()-startTime)+" ms");
       }
@@ -708,7 +707,7 @@ public class CrawlerAgent implements IAg
     }
 
     // Threads are down; release connectors
-    RepositoryConnectorFactory.closeAllConnectors(threadContext);
+    RepositoryConnectorPoolFactory.make(threadContext).flushUnusedConnectors();
     numWorkerThreads = 0;
     numDeleteThreads = 0;
     numExpireThreads = 0;

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/DocumentCleanupThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/DocumentCleanupThread.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/DocumentCleanupThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/DocumentCleanupThread.java Thu Dec  5 10:31:01 2013
@@ -82,6 +82,8 @@ public class DocumentCleanupThread exten
       IRepositoryConnectionManager connMgr = RepositoryConnectionManagerFactory.make(threadContext);
       ReprioritizationTracker rt = new ReprioritizationTracker(threadContext);
 
+      IRepositoryConnectorPool repositoryConnectorPool = RepositoryConnectorPoolFactory.make(threadContext);
+      
       // Loop
       while (true)
       {
@@ -144,7 +146,7 @@ public class DocumentCleanupThread exten
             }
 
             // Grab one connection for each connectionName.  If we fail, nothing is lost and retries are possible.
-            IRepositoryConnector connector = RepositoryConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());
+            IRepositoryConnector connector = repositoryConnectorPool.grab(connection);
             try
             {
 
@@ -247,7 +249,7 @@ public class DocumentCleanupThread exten
             finally
             {
               // Free up the reserved connector instance
-              RepositoryConnectorFactory.release(connector);
+              repositoryConnectorPool.release(connector);
             }
           }
           catch (ManifoldCFException e)

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ExpireThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ExpireThread.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ExpireThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ExpireThread.java Thu Dec  5 10:31:01 2013
@@ -72,6 +72,8 @@ public class ExpireThread extends Thread
       IRepositoryConnectionManager connMgr = RepositoryConnectionManagerFactory.make(threadContext);
       ReprioritizationTracker rt = new ReprioritizationTracker(threadContext);
 
+      IRepositoryConnectorPool repositoryConnectorPool = RepositoryConnectorPoolFactory.make(threadContext);
+      
       // Loop
       while (true)
       {
@@ -136,7 +138,7 @@ public class ExpireThread extends Thread
             }
 
             // Grab one connection for the connectionName.  If we fail, nothing is lost and retries are possible.
-            IRepositoryConnector connector = RepositoryConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());
+            IRepositoryConnector connector = repositoryConnectorPool.grab(connection);
             try
             {
 
@@ -250,7 +252,7 @@ public class ExpireThread extends Thread
             finally
             {
               // Free up the reserved connector instance
-              RepositoryConnectorFactory.release(connector);
+              repositoryConnectorPool.release(connector);
             }
           }
           catch (ManifoldCFException e)

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/IdleCleanupThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/IdleCleanupThread.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/IdleCleanupThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/IdleCleanupThread.java Thu Dec  5 10:31:01 2013
@@ -57,6 +57,8 @@ public class IdleCleanupThread extends T
       // Get the cache handle.
       ICacheManager cacheManager = CacheManagerFactory.make(threadContext);
       
+      IRepositoryConnectorPool repositoryConnectorPool = RepositoryConnectorPoolFactory.make(threadContext);
+      
       // Loop
       while (true)
       {
@@ -64,8 +66,7 @@ public class IdleCleanupThread extends T
         try
         {
           // Do the cleanup
-          RepositoryConnectorFactory.pollAllConnectors(threadContext);
-          OutputConnectorFactory.pollAllConnectors(threadContext);
+          repositoryConnectorPool.pollAllConnectors();
           cacheManager.expireObjects(System.currentTimeMillis());
           
           // Sleep for the retry interval.

Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobNotificationThread.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobNotificationThread.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobNotificationThread.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobNotificationThread.java Thu Dec  5 10:31:01 2013
@@ -61,6 +61,8 @@ public class JobNotificationThread exten
       IOutputConnectionManager connectionManager = OutputConnectionManagerFactory.make(threadContext);
       IRepositoryConnectionManager repositoryConnectionManager = RepositoryConnectionManagerFactory.make(threadContext);
 
+      IOutputConnectorPool outputConnectorPool = OutputConnectorPoolFactory.make(threadContext);
+      
       // Loop
       while (true)
       {
@@ -108,7 +110,7 @@ public class JobNotificationThread exten
               if (connection != null)
               {
                 // Grab an appropriate connection instance
-                IOutputConnector connector = OutputConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());
+                IOutputConnector connector = outputConnectorPool.grab(connection);
                 if (connector != null)
                 {
                   try
@@ -138,7 +140,7 @@ public class JobNotificationThread exten
                   }
                   finally
                   {
-                    OutputConnectorFactory.release(connector);
+                    outputConnectorPool.release(connector);
                   }
                 }
               }