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 [1/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...
Author: kwright
Date: Thu Dec 5 10:31:01 2013
New Revision: 1548081
URL: http://svn.apache.org/r1548081
Log:
Merge in connector-pool refactoring from CONNECTORS-781 branch.
Added:
manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IOutputConnectorPool.java
- copied unchanged from r1548079, manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/IOutputConnectorPool.java
manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/OutputConnectorPoolFactory.java
- copied unchanged from r1548079, manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/OutputConnectorPoolFactory.java
manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/
- copied from r1548079, manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/outputconnectorpool/
manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/IdleCleanupThread.java
- copied unchanged from r1548079, manifoldcf/branches/CONNECTORS-781/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/IdleCleanupThread.java
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/connectorpool/
- copied from r1548079, manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/connectorpool/
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/ConnectorFactory.java
- copied unchanged from r1548079, manifoldcf/branches/CONNECTORS-781/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/ConnectorFactory.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/
- copied from r1548079, manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/authorityconnectorpool/
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorPoolFactory.java
- copied unchanged from r1548079, manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorPoolFactory.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectorPool.java
- copied unchanged from r1548079, manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IAuthorityConnectorPool.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IMappingConnectorPool.java
- copied unchanged from r1548079, manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/IMappingConnectorPool.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorPoolFactory.java
- copied unchanged from r1548079, manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorPoolFactory.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/
- copied from r1548079, manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/mappingconnectorpool/
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IRepositoryConnectorPool.java
- copied unchanged from r1548079, manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IRepositoryConnectorPool.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/RepositoryConnectorPoolFactory.java
- copied unchanged from r1548079, manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/RepositoryConnectorPoolFactory.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repositoryconnectorpool/
- copied from r1548079, manifoldcf/branches/CONNECTORS-781/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/repositoryconnectorpool/
Modified:
manifoldcf/trunk/ (props changed)
manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/incrementalingest/IncrementalIngester.java
manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/OutputConnectorFactory.java
manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/AgentsDaemon.java
manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/ManifoldCF.java
manifoldcf/trunk/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/UserACLServlet.java
manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editjob.jsp
manifoldcf/trunk/framework/crawler-ui/src/main/webapp/execute.jsp
manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewauthority.jsp
manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewconnection.jsp
manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewjob.jsp
manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewmapper.jsp
manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewoutput.jsp
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/CheckAll.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorFactory.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/MappingConnectorFactory.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthCheckThread.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/AuthRequest.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/IdleCleanupThread.java
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/authorities/system/MappingRequest.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/system/MappingThread.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/RepositoryConnectorFactory.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.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/DocumentCleanupThread.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ExpireThread.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/IdleCleanupThread.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobNotificationThread.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/SeedingThread.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/SetPriorityThread.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/StartupThread.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/StufferThread.java
manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/WorkerThread.java
Propchange: manifoldcf/trunk/
------------------------------------------------------------------------------
Merged /manifoldcf/branches/CONNECTORS-781:r1547171-1548079
Modified: manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/incrementalingest/IncrementalIngester.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/incrementalingest/IncrementalIngester.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/incrementalingest/IncrementalIngester.java (original)
+++ manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/incrementalingest/IncrementalIngester.java Thu Dec 5 10:31:01 2013
@@ -79,7 +79,9 @@ public class IncrementalIngester extends
protected ILockManager lockManager;
// Output connection manager
protected IOutputConnectionManager connectionManager;
-
+ // Output connector pool manager
+ protected IOutputConnectorPool outputConnectorPool;
+
/** Constructor.
*/
public IncrementalIngester(IThreadContext threadContext, IDBInterface database)
@@ -89,6 +91,7 @@ public class IncrementalIngester extends
this.threadContext = threadContext;
lockManager = LockManagerFactory.make(threadContext);
connectionManager = OutputConnectionManagerFactory.make(threadContext);
+ outputConnectorPool = OutputConnectorPoolFactory.make(threadContext);
}
/** Install the incremental ingestion manager.
@@ -203,7 +206,7 @@ public class IncrementalIngester extends
throws ManifoldCFException, ServiceInterruption
{
IOutputConnection connection = connectionManager.load(outputConnectionName);
- IOutputConnector connector = OutputConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());
+ IOutputConnector connector = outputConnectorPool.grab(connection);
if (connector == null)
// The connector is not installed; treat this as a service interruption.
throw new ServiceInterruption("Output connector not installed",0L);
@@ -213,7 +216,7 @@ public class IncrementalIngester extends
}
finally
{
- OutputConnectorFactory.release(connector);
+ outputConnectorPool.release(connector);
}
}
@@ -228,7 +231,7 @@ public class IncrementalIngester extends
throws ManifoldCFException, ServiceInterruption
{
IOutputConnection connection = connectionManager.load(outputConnectionName);
- IOutputConnector connector = OutputConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());
+ IOutputConnector connector = outputConnectorPool.grab(connection);
if (connector == null)
// The connector is not installed; treat this as a service interruption.
throw new ServiceInterruption("Output connector not installed",0L);
@@ -238,7 +241,7 @@ public class IncrementalIngester extends
}
finally
{
- OutputConnectorFactory.release(connector);
+ outputConnectorPool.release(connector);
}
}
@@ -254,7 +257,7 @@ public class IncrementalIngester extends
throws ManifoldCFException, ServiceInterruption
{
IOutputConnection connection = connectionManager.load(outputConnectionName);
- IOutputConnector connector = OutputConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());
+ IOutputConnector connector = outputConnectorPool.grab(connection);
if (connector == null)
// The connector is not installed; treat this as a service interruption.
throw new ServiceInterruption("Output connector not installed",0L);
@@ -264,7 +267,7 @@ public class IncrementalIngester extends
}
finally
{
- OutputConnectorFactory.release(connector);
+ outputConnectorPool.release(connector);
}
}
@@ -280,7 +283,7 @@ public class IncrementalIngester extends
throws ManifoldCFException, ServiceInterruption
{
IOutputConnection connection = connectionManager.load(outputConnectionName);
- IOutputConnector connector = OutputConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());
+ IOutputConnector connector = outputConnectorPool.grab(connection);
if (connector == null)
// The connector is not installed; treat this as a service interruption.
throw new ServiceInterruption("Output connector not installed",0L);
@@ -290,7 +293,7 @@ public class IncrementalIngester extends
}
finally
{
- OutputConnectorFactory.release(connector);
+ outputConnectorPool.release(connector);
}
}
@@ -304,7 +307,7 @@ public class IncrementalIngester extends
throws ManifoldCFException, ServiceInterruption
{
IOutputConnection connection = connectionManager.load(outputConnectionName);
- IOutputConnector connector = OutputConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());
+ IOutputConnector connector = outputConnectorPool.grab(connection);
if (connector == null)
// The connector is not installed; treat this as a service interruption.
throw new ServiceInterruption("Output connector not installed",0L);
@@ -314,7 +317,7 @@ public class IncrementalIngester extends
}
finally
{
- OutputConnectorFactory.release(connector);
+ outputConnectorPool.release(connector);
}
}
@@ -1649,7 +1652,7 @@ public class IncrementalIngester extends
{
// Set indexing date
document.setIndexingDate(new Date());
- IOutputConnector connector = OutputConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());
+ IOutputConnector connector = outputConnectorPool.grab(connection);
if (connector == null)
// The connector is not installed; treat this as a service interruption.
throw new ServiceInterruption("Output connector not installed",0L);
@@ -1659,7 +1662,7 @@ public class IncrementalIngester extends
}
finally
{
- OutputConnectorFactory.release(connector);
+ outputConnectorPool.release(connector);
}
}
@@ -1668,7 +1671,7 @@ public class IncrementalIngester extends
protected void removeDocument(IOutputConnection connection, String documentURI, String outputDescription, IOutputRemoveActivity activities)
throws ManifoldCFException, ServiceInterruption
{
- IOutputConnector connector = OutputConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());
+ IOutputConnector connector = outputConnectorPool.grab(connection);
if (connector == null)
// The connector is not installed; treat this as a service interruption.
throw new ServiceInterruption("Output connector not installed",0L);
@@ -1678,7 +1681,7 @@ public class IncrementalIngester extends
}
finally
{
- OutputConnectorFactory.release(connector);
+ outputConnectorPool.release(connector);
}
}
Modified: manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/OutputConnectorFactory.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/OutputConnectorFactory.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/OutputConnectorFactory.java (original)
+++ manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/interfaces/OutputConnectorFactory.java Thu Dec 5 10:31:01 2013
@@ -27,18 +27,38 @@ import java.lang.reflect.*;
/** This is the factory class for IOutputConnector objects.
*/
-public class OutputConnectorFactory
+public class OutputConnectorFactory extends ConnectorFactory<IOutputConnector>
{
public static final String _rcsid = "@(#)$Id: OutputConnectorFactory.java 988245 2010-08-23 18:39:35Z kwright $";
- // Pool hash table.
- // Keyed by PoolKey; value is Pool
- protected static Map poolHash = new HashMap();
+ // Static factory
+ protected final static OutputConnectorFactory thisFactory = new OutputConnectorFactory();
- // private static HashMap checkedOutConnectors = new HashMap();
+ protected OutputConnectorFactory()
+ {
+ }
- private OutputConnectorFactory()
+ @Override
+ protected boolean isInstalled(IThreadContext tc, String className)
+ throws ManifoldCFException
{
+ IOutputConnectorManager connMgr = OutputConnectorManagerFactory.make(tc);
+ return connMgr.isInstalled(className);
+ }
+
+ /** Get the activities supported by this connector.
+ *@param className is the class name.
+ *@return the list of activities.
+ */
+ public String[] getThisActivitiesList(IThreadContext threadContext, String className)
+ throws ManifoldCFException
+ {
+ IOutputConnector connector = getThisConnector(threadContext, className);
+ if (connector == null)
+ return null;
+ String[] values = connector.getActivitiesList();
+ java.util.Arrays.sort(values);
+ return values;
}
/** Install connector.
@@ -47,8 +67,7 @@ public class OutputConnectorFactory
public static void install(IThreadContext threadContext, String className)
throws ManifoldCFException
{
- IOutputConnector connector = getConnectorNoCheck(className);
- connector.install(threadContext);
+ thisFactory.installThis(threadContext,className);
}
/** Uninstall connector.
@@ -57,8 +76,7 @@ public class OutputConnectorFactory
public static void deinstall(IThreadContext threadContext, String className)
throws ManifoldCFException
{
- IOutputConnector connector = getConnectorNoCheck(className);
- connector.deinstall(threadContext);
+ thisFactory.deinstallThis(threadContext,className);
}
/** Get the activities supported by this connector.
@@ -68,12 +86,7 @@ public class OutputConnectorFactory
public static String[] getActivitiesList(IThreadContext threadContext, String className)
throws ManifoldCFException
{
- IOutputConnector 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);
}
/** Output the configuration header section.
@@ -82,10 +95,7 @@ public class OutputConnectorFactory
IHTTPOutput out, Locale locale, ConfigParams parameters, ArrayList tabsArray)
throws ManifoldCFException, IOException
{
- IOutputConnector 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.
@@ -94,10 +104,7 @@ public class OutputConnectorFactory
IHTTPOutput out, Locale locale, ConfigParams parameters, String tabName)
throws ManifoldCFException, IOException
{
- IOutputConnector 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.
@@ -106,10 +113,7 @@ public class OutputConnectorFactory
IPostParameters variableContext, Locale locale, ConfigParams configParams)
throws ManifoldCFException
{
- IOutputConnector 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.
@@ -118,11 +122,7 @@ public class OutputConnectorFactory
IHTTPOutput out, Locale locale, ConfigParams configParams)
throws ManifoldCFException, IOException
{
- IOutputConnector 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 an output connector instance, without checking for installed connector.
@@ -132,567 +132,7 @@ public class OutputConnectorFactory
public static IOutputConnector 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 IOutputConnector))
- throw new ManifoldCFException("Class '"+className+"' does not implement IOutputConnector.");
- return (IOutputConnector)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 output connector class '"+className+"' was found.",
- e);
- }
- catch (NoSuchMethodException e)
- {
- throw new ManifoldCFException("No appropriate constructor for IOutputConnector implementation '"+
- className+"'. Need xxx().",
- e);
- }
- catch (SecurityException e)
- {
- throw new ManifoldCFException("Protected constructor for IOutputConnector implementation '"+className+"'",
- e);
- }
- catch (IllegalAccessException e)
- {
- throw new ManifoldCFException("Unavailable constructor for IOutputConnector implementation '"+className+"'",
- e);
- }
- catch (IllegalArgumentException e)
- {
- throw new ManifoldCFException("Shouldn't happen!!!",e);
- }
- catch (InstantiationException e)
- {
- throw new ManifoldCFException("InstantiationException for IOutputConnector implementation '"+className+"'",
- e);
- }
- catch (ExceptionInInitializerError e)
- {
- throw new ManifoldCFException("ExceptionInInitializerError for IOutputConnector implementation '"+className+"'",
- e);
- }
-
- }
-
- /** Get an output connector instance.
- *@param className is the class name.
- *@return the instance.
- */
- protected static IOutputConnector getConnector(IThreadContext threadContext, String className)
- throws ManifoldCFException
- {
- IOutputConnectorManager connMgr = OutputConnectorManagerFactory.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 IOutputConnector))
- throw new ManifoldCFException("Class '"+className+"' does not implement IOutputConnector.");
- return (IOutputConnector)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 output connector class '"+className+"' was found.",
- e);
- }
- catch (NoSuchMethodException e)
- {
- throw new ManifoldCFException("No appropriate constructor for IOutputConnector implementation '"+
- className+"'. Need xxx(ConfigParams).",
- e);
- }
- catch (SecurityException e)
- {
- throw new ManifoldCFException("Protected constructor for IOutputConnector implementation '"+className+"'",
- e);
- }
- catch (IllegalAccessException e)
- {
- throw new ManifoldCFException("Unavailable constructor for IOutputConnector implementation '"+className+"'",
- e);
- }
- catch (IllegalArgumentException e)
- {
- throw new ManifoldCFException("Shouldn't happen!!!",e);
- }
- catch (InstantiationException e)
- {
- throw new ManifoldCFException("InstantiationException for IOutputConnector implementation '"+className+"'",
- e);
- }
- catch (ExceptionInInitializerError e)
- {
- throw new ManifoldCFException("ExceptionInInitializerError for IOutputConnector implementation '"+className+"'",
- e);
- }
-
- }
-
- /** Get multiple output connectors, all at once. Do this in a particular order
- * so that any connector exhaustion will not cause a deadlock.
- */
- public static IOutputConnector[] grabMultiple(IThreadContext threadContext,
- String[] orderingKeys, String[] classNames, ConfigParams[] configInfos, int[] maxPoolSizes)
- throws ManifoldCFException
- {
- IOutputConnector[] rval = new IOutputConnector[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
- {
- IOutputConnector 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 an output 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 IOutputConnector 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);
- }
- }
-
- IOutputConnector rval = p.getConnector(threadContext);
-
- return rval;
-
- }
-
- /** Release multiple output connectors.
- */
- public static void releaseMultiple(IOutputConnector[] connectors)
- throws ManifoldCFException
- {
- int i = 0;
- ManifoldCFException currentException = null;
- while (i < connectors.length)
- {
- IOutputConnector c = connectors[i++];
- try
- {
- release(c);
- }
- catch (ManifoldCFException e)
- {
- if (currentException == null)
- currentException = e;
- }
- }
- if (currentException != null)
- throw currentException;
- }
-
- /** Release an output connector.
- *@param connector is the connector to release.
- */
- public static void release(IOutputConnector 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 output 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);
- }
- }
-
- // System.out.println("About to check if any output connector instances have been abandoned...");
- // checkConnectors(System.currentTimeMillis());
- }
-
- /** Clean up all open output 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);
- }
- }
- }
-
- /** 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 an output 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 IOutputConnector 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();
-
- IOutputConnectorManager connMgr = OutputConnectorManagerFactory.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 IOutputConnector))
- throw new ManifoldCFException("Class '"+className+"' does not implement IOutputConnector.");
- IOutputConnector newrc = (IOutputConnector)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 output connector class '"+className+"' was found.",
- e);
- }
- catch (NoSuchMethodException e)
- {
- throw new ManifoldCFException("No appropriate constructor for IOutputConnector implementation '"+
- className+"'. Need xxx(ConfigParams).",
- e);
- }
- catch (SecurityException e)
- {
- throw new ManifoldCFException("Protected constructor for IOutputConnector implementation '"+className+"'",
- e);
- }
- catch (IllegalAccessException e)
- {
- throw new ManifoldCFException("Unavailable constructor for IOutputConnector implementation '"+className+"'",
- e);
- }
- catch (IllegalArgumentException e)
- {
- throw new ManifoldCFException("Shouldn't happen!!!",e);
- }
- catch (InstantiationException e)
- {
- throw new ManifoldCFException("InstantiationException for IOutputConnector implementation '"+className+"'",
- e);
- }
- catch (ExceptionInInitializerError e)
- {
- throw new ManifoldCFException("ExceptionInInitializerError for IOutputConnector implementation '"+className+"'",
- e);
- }
- }
-
- // Since thread context set can fail, do that before we remove it from the pool.
- IOutputConnector rc = (IOutputConnector)stack.get(stack.size()-1);
- rc.setThreadContext(threadContext);
- stack.remove(stack.size()-1);
- numFree--;
-
- return rc;
- }
-
- /** Release an output connector to the pool.
- *@param connector is the connector.
- */
- public synchronized void releaseConnector(IOutputConnector 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();
- }
- }
- }
-
+ return thisFactory.getThisConnectorNoCheck(className);
}
}
Modified: manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/AgentsDaemon.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/AgentsDaemon.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/AgentsDaemon.java (original)
+++ manifoldcf/trunk/framework/agents/src/main/java/org/apache/manifoldcf/agents/system/AgentsDaemon.java Thu Dec 5 10:31:01 2013
@@ -36,6 +36,9 @@ public class AgentsDaemon
* also takes on process cleanup where necessary. */
protected AgentsThread agentsThread = null;
+ /** The idle cleanup thread. */
+ protected IdleCleanupThread idleCleanupThread = null;
+
/** Process ID for this agents daemon. */
protected final String processID;
@@ -124,8 +127,11 @@ public class AgentsDaemon
public void startAgents(IThreadContext threadContext)
throws ManifoldCFException
{
- // Create and start agents thread.
+ // Create idle cleanup thread.
+ idleCleanupThread = new IdleCleanupThread(processID);
agentsThread = new AgentsThread();
+ // Create and start agents thread.
+ idleCleanupThread.start();
agentsThread.start();
}
@@ -135,11 +141,17 @@ public class AgentsDaemon
throws ManifoldCFException
{
// Shut down agents background thread.
- while (agentsThread != null)
+ while (agentsThread != null || idleCleanupThread != null)
{
- agentsThread.interrupt();
- if (!agentsThread.isAlive())
+ if (agentsThread != null)
+ agentsThread.interrupt();
+ if (idleCleanupThread != null)
+ idleCleanupThread.interrupt();
+
+ if (agentsThread != null && !agentsThread.isAlive())
agentsThread = null;
+ if (idleCleanupThread != null && !idleCleanupThread.isAlive())
+ idleCleanupThread = null;
}
// Shut down running agents services directly.
@@ -160,6 +172,7 @@ public class AgentsDaemon
}
}
// Done.
+ OutputConnectorPoolFactory.make(threadContext).flushUnusedConnectors();
}
protected static String getAgentsClassServiceType(String agentClassName)
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=1548081&r1=1548080&r2=1548081&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 Thu Dec 5 10:31:01 2013
@@ -74,6 +74,16 @@ public class ManifoldCF extends org.apac
public static void localCleanup(IThreadContext threadContext)
{
+ // Close all pools
+ try
+ {
+ OutputConnectorPoolFactory.make(threadContext).closeAllConnectors();
+ }
+ catch (ManifoldCFException e)
+ {
+ if (Logging.agents != null)
+ Logging.agents.warn("Exception shutting down output connector pool: "+e.getMessage(),e);
+ }
}
/** Reset the environment.
Modified: manifoldcf/trunk/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/UserACLServlet.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/UserACLServlet.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/UserACLServlet.java (original)
+++ manifoldcf/trunk/framework/authority-servlet/src/main/java/org/apache/manifoldcf/authorityservlet/UserACLServlet.java Thu Dec 5 10:31:01 2013
@@ -231,8 +231,7 @@ public class UserACLServlet extends Http
identifyingString = thisConnection.getName();
// Create a request
- AuthRequest ar = new AuthRequest(
- thisConnection.getClassName(),identifyingString,thisConnection.getConfigParams(),thisConnection.getMaxConnections());
+ AuthRequest ar = new AuthRequest(thisConnection,identifyingString);
authRequests.put(thisConnection.getName(), ar);
// We create an auth thread if there are prerequisites to meet.
@@ -270,8 +269,7 @@ public class UserACLServlet extends Http
identifyingString = connectionName;
// Create a request
- MappingRequest mr = new MappingRequest(
- thisConnection.getClassName(),identifyingString,thisConnection.getConfigParams(),thisConnection.getMaxConnections());
+ MappingRequest mr = new MappingRequest(thisConnection,identifyingString);
mappingRequests.put(mapperDesc, mr);
// Either start up a thread, or just fire it off immediately.
Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editjob.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editjob.jsp?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editjob.jsp (original)
+++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/editjob.jsp Thu Dec 5 10:31:01 2013
@@ -36,6 +36,9 @@
IOutputConnectionManager outputMgr = OutputConnectionManagerFactory.make(threadContext);
IOutputConnection[] outputList = outputMgr.getAllConnections();
+ IOutputConnectorPool outputConnectorPool = OutputConnectorPoolFactory.make(threadContext);
+ IRepositoryConnectorPool repositoryConnectorPool = RepositoryConnectorPoolFactory.make(threadContext);
+
// Figure out tab name
String tabName = variableContext.getParameter("tabname");
if (tabName == null || tabName.length() == 0)
@@ -404,8 +407,7 @@
<%
if (outputConnection != null)
{
- IOutputConnector outputConnector = OutputConnectorFactory.grab(threadContext,outputConnection.getClassName(),outputConnection.getConfigParams(),
- outputConnection.getMaxConnections());
+ IOutputConnector outputConnector = outputConnectorPool.grab(outputConnection);
if (outputConnector != null)
{
try
@@ -414,7 +416,7 @@
}
finally
{
- OutputConnectorFactory.release(outputConnector);
+ outputConnectorPool.release(outputConnector);
}
}
}
@@ -423,8 +425,7 @@
<%
if (connection != null)
{
- IRepositoryConnector repositoryConnector = RepositoryConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),
- connection.getMaxConnections());
+ IRepositoryConnector repositoryConnector = repositoryConnectorPool.grab(connection);
if (repositoryConnector != null)
{
try
@@ -433,7 +434,7 @@
}
finally
{
- RepositoryConnectorFactory.release(repositoryConnector);
+ repositoryConnectorPool.release(repositoryConnector);
}
}
}
@@ -1272,8 +1273,7 @@
if (outputConnection != null)
{
- IOutputConnector outputConnector = OutputConnectorFactory.grab(threadContext,outputConnection.getClassName(),outputConnection.getConfigParams(),
- outputConnection.getMaxConnections());
+ IOutputConnector outputConnector = outputConnectorPool.grab(outputConnection);
if (outputConnector != null)
{
try
@@ -1282,7 +1282,7 @@
}
finally
{
- OutputConnectorFactory.release(outputConnector);
+ outputConnectorPool.release(outputConnector);
}
%>
<input type="hidden" name="outputpresent" value="true"/>
@@ -1292,8 +1292,7 @@
if (connection != null)
{
- IRepositoryConnector repositoryConnector = RepositoryConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),
- connection.getMaxConnections());
+ IRepositoryConnector repositoryConnector = repositoryConnectorPool.grab(connection);
if (repositoryConnector != null)
{
try
@@ -1302,7 +1301,7 @@
}
finally
{
- RepositoryConnectorFactory.release(repositoryConnector);
+ repositoryConnectorPool.release(repositoryConnector);
}
%>
<input type="hidden" name="connectionpresent" value="true"/>
Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/execute.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/execute.jsp?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/execute.jsp (original)
+++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/execute.jsp Thu Dec 5 10:31:01 2013
@@ -51,6 +51,9 @@
IMappingConnectionManager mappingConnManager = MappingConnectionManagerFactory.make(threadContext);
IOutputConnectionManager outputManager = OutputConnectionManagerFactory.make(threadContext);
+ IOutputConnectorPool outputConnectorPool = OutputConnectorPoolFactory.make(threadContext);
+ IRepositoryConnectorPool repositoryConnectorPool = RepositoryConnectorPoolFactory.make(threadContext);
+
String type = variableContext.getParameter("type");
String op = variableContext.getParameter("op");
if (type != null && op != null && type.equals("connection"))
@@ -1028,8 +1031,7 @@
if (outputPresent && outputConnection != null)
{
- IOutputConnector outputConnector = OutputConnectorFactory.grab(threadContext,
- outputConnection.getClassName(),outputConnection.getConfigParams(),outputConnection.getMaxConnections());
+ IOutputConnector outputConnector = outputConnectorPool.grab(outputConnection);
if (outputConnector != null)
{
try
@@ -1046,15 +1048,14 @@
}
finally
{
- OutputConnectorFactory.release(outputConnector);
+ outputConnectorPool.release(outputConnector);
}
}
}
if (connectionPresent && connection != null)
{
- IRepositoryConnector repositoryConnector = RepositoryConnectorFactory.grab(threadContext,
- connection.getClassName(),connection.getConfigParams(),connection.getMaxConnections());
+ IRepositoryConnector repositoryConnector = repositoryConnectorPool.grab(connection);
if (repositoryConnector != null)
{
try
@@ -1071,7 +1072,7 @@
}
finally
{
- RepositoryConnectorFactory.release(repositoryConnector);
+ repositoryConnectorPool.release(repositoryConnector);
}
}
}
Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewauthority.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewauthority.jsp?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewauthority.jsp (original)
+++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewauthority.jsp Thu Dec 5 10:31:01 2013
@@ -67,6 +67,7 @@
{
IAuthorityConnectionManager manager = AuthorityConnectionManagerFactory.make(threadContext);
IAuthorityConnectorManager connectorManager = AuthorityConnectorManagerFactory.make(threadContext);
+ IAuthorityConnectorPool authorityConnectorPool = AuthorityConnectorPoolFactory.make(threadContext);
String connectionName = variableContext.getParameter("connname");
IAuthorityConnection connection = manager.load(connectionName);
if (connection == null)
@@ -101,7 +102,7 @@
String connectionStatus;
try
{
- IAuthorityConnector c = AuthorityConnectorFactory.grab(threadContext,className,parameters,maxCount);
+ IAuthorityConnector c = authorityConnectorPool.grab(connection);
if (c == null)
{
connectionStatus = Messages.getString(pageContext.getRequest().getLocale(),"viewauthority.Connectorisnotinstalled");
@@ -114,7 +115,7 @@
}
finally
{
- AuthorityConnectorFactory.release(c);
+ authorityConnectorPool.release(c);
}
}
}
Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewconnection.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewconnection.jsp?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewconnection.jsp (original)
+++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewconnection.jsp Thu Dec 5 10:31:01 2013
@@ -78,6 +78,7 @@
IConnectorManager connectorManager = ConnectorManagerFactory.make(threadContext);
// Get the connection manager handle
IRepositoryConnectionManager connManager = RepositoryConnectionManagerFactory.make(threadContext);
+ IRepositoryConnectorPool repositoryConnectorPool = RepositoryConnectorPoolFactory.make(threadContext);
String connectionName = variableContext.getParameter("connname");
IRepositoryConnection connection = connManager.load(connectionName);
if (connection == null)
@@ -108,7 +109,7 @@
String connectionStatus;
try
{
- IRepositoryConnector c = RepositoryConnectorFactory.grab(threadContext,className,parameters,maxCount);
+ IRepositoryConnector c = repositoryConnectorPool.grab(connection);
if (c == null)
connectionStatus = Messages.getString(pageContext.getRequest().getLocale(),"viewconnection.Connectorisnotinstalled");
else
@@ -119,7 +120,7 @@
}
finally
{
- RepositoryConnectorFactory.release(c);
+ repositoryConnectorPool.release(c);
}
}
}
Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewjob.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewjob.jsp?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewjob.jsp (original)
+++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewjob.jsp Thu Dec 5 10:31:01 2013
@@ -70,6 +70,10 @@
IJobManager manager = JobManagerFactory.make(threadContext);
IOutputConnectionManager outputManager = OutputConnectionManagerFactory.make(threadContext);
IRepositoryConnectionManager connManager = RepositoryConnectionManagerFactory.make(threadContext);
+
+ IOutputConnectorPool outputConnectorPool = OutputConnectorPoolFactory.make(threadContext);
+ IRepositoryConnectorPool repositoryConnectorPool = RepositoryConnectorPoolFactory.make(threadContext);
+
String jobID = variableContext.getParameter("jobid");
IJobDescription job = manager.load(new Long(jobID));
if (job == null)
@@ -631,8 +635,7 @@
<%
if (outputConnection != null)
{
- IOutputConnector outputConnector = OutputConnectorFactory.grab(threadContext,outputConnection.getClassName(),outputConnection.getConfigParams(),
- outputConnection.getMaxConnections());
+ IOutputConnector outputConnector = outputConnectorPool.grab(outputConnection);
if (outputConnector != null)
{
try
@@ -641,7 +644,7 @@
}
finally
{
- OutputConnectorFactory.release(outputConnector);
+ outputConnectorPool.release(outputConnector);
}
}
}
@@ -656,9 +659,7 @@
<%
if (connection != null)
{
- IRepositoryConnector repositoryConnector = RepositoryConnectorFactory.grab(threadContext,connection.getClassName(),connection.getConfigParams(),
-
- connection.getMaxConnections());
+ IRepositoryConnector repositoryConnector = repositoryConnectorPool.grab(connection);
if (repositoryConnector != null)
{
try
@@ -667,7 +668,7 @@
}
finally
{
- RepositoryConnectorFactory.release(repositoryConnector);
+ repositoryConnectorPool.release(repositoryConnector);
}
}
}
Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewmapper.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewmapper.jsp?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewmapper.jsp (original)
+++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewmapper.jsp Thu Dec 5 10:31:01 2013
@@ -67,6 +67,7 @@
{
IMappingConnectionManager manager = MappingConnectionManagerFactory.make(threadContext);
IMappingConnectorManager connectorManager = MappingConnectorManagerFactory.make(threadContext);
+ IMappingConnectorPool mappingConnectorPool = MappingConnectorPoolFactory.make(threadContext);
String connectionName = variableContext.getParameter("connname");
IMappingConnection connection = manager.load(connectionName);
if (connection == null)
@@ -91,7 +92,7 @@
String connectionStatus;
try
{
- IMappingConnector c = MappingConnectorFactory.grab(threadContext,className,parameters,maxCount);
+ IMappingConnector c = mappingConnectorPool.grab(connection);
if (c == null)
{
connectionStatus = Messages.getString(pageContext.getRequest().getLocale(),"viewmapper.Connectorisnotinstalled");
@@ -104,7 +105,7 @@
}
finally
{
- MappingConnectorFactory.release(c);
+ mappingConnectorPool.release(c);
}
}
}
Modified: manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewoutput.jsp
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewoutput.jsp?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewoutput.jsp (original)
+++ manifoldcf/trunk/framework/crawler-ui/src/main/webapp/viewoutput.jsp Thu Dec 5 10:31:01 2013
@@ -78,6 +78,7 @@
IOutputConnectorManager connectorManager = OutputConnectorManagerFactory.make(threadContext);
// Get the connection manager handle
IOutputConnectionManager connManager = OutputConnectionManagerFactory.make(threadContext);
+ IOutputConnectorPool outputConnectorPool = OutputConnectorPoolFactory.make(threadContext);
String connectionName = variableContext.getParameter("connname");
IOutputConnection connection = connManager.load(connectionName);
if (connection == null)
@@ -104,7 +105,7 @@
String connectionStatus;
try
{
- IOutputConnector c = OutputConnectorFactory.grab(threadContext,className,parameters,maxCount);
+ IOutputConnector c = outputConnectorPool.grab(connection);
if (c == null)
connectionStatus = Messages.getString(pageContext.getRequest().getLocale(),"viewoutput.Connectorisnotinstalled");
else
@@ -115,7 +116,7 @@
}
finally
{
- OutputConnectorFactory.release(c);
+ outputConnectorPool.release(c);
}
}
}
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/CheckAll.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/CheckAll.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/CheckAll.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/CheckAll.java Thu Dec 5 10:31:01 2013
@@ -46,6 +46,7 @@ public class CheckAll
{
IThreadContext tc = ThreadContextFactory.make();
ManifoldCF.initializeEnvironment(tc);
+ IAuthorityConnectorPool authorityConnectorPool = AuthorityConnectorPoolFactory.make(tc);
// Now, get a list of the authority connections
IAuthorityConnectionManager mgr = AuthorityConnectionManagerFactory.make(tc);
IAuthorityConnection[] connections = mgr.getAllConnections();
@@ -70,7 +71,7 @@ public class CheckAll
String connectionStatus;
try
{
- IAuthorityConnector c = AuthorityConnectorFactory.grab(tc,className,parameters,maxCount);
+ IAuthorityConnector c = authorityConnectorPool.grab(connection);
if (c != null)
{
try
@@ -79,7 +80,7 @@ public class CheckAll
}
finally
{
- AuthorityConnectorFactory.release(c);
+ authorityConnectorPool.release(c);
}
}
else
Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorFactory.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorFactory.java?rev=1548081&r1=1548080&r2=1548081&view=diff
==============================================================================
--- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorFactory.java (original)
+++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/authorities/interfaces/AuthorityConnectorFactory.java Thu Dec 5 10:31:01 2013
@@ -26,14 +26,32 @@ import java.lang.reflect.*;
/** This class manages a pool of authority connectors.
*/
-public class AuthorityConnectorFactory
+public class AuthorityConnectorFactory extends ConnectorFactory<IAuthorityConnector>
{
- // Pool hash table.
- // Keyed by PoolKey; value is Pool
- protected static Map poolHash = new HashMap();
+ // Static factory
+ protected final static AuthorityConnectorFactory thisFactory = new AuthorityConnectorFactory();
+
+ protected AuthorityConnectorFactory()
+ {
+ }
- private AuthorityConnectorFactory()
+ @Override
+ protected boolean isInstalled(IThreadContext tc, String className)
+ throws ManifoldCFException
{
+ IAuthorityConnectorManager connMgr = AuthorityConnectorManagerFactory.make(tc);
+ return connMgr.isInstalled(className);
+ }
+
+ /** Get the default response from a connector. Called if the connection attempt fails.
+ */
+ public AuthorizationResponse getThisDefaultAuthorizationResponse(IThreadContext threadContext, String className, String userName)
+ throws ManifoldCFException
+ {
+ IAuthorityConnector connector = getThisConnector(threadContext,className);
+ if (connector == null)
+ return null;
+ return connector.getDefaultAuthorizationResponse(userName);
}
/** Install connector.
@@ -42,8 +60,7 @@ public class AuthorityConnectorFactory
public static void install(IThreadContext threadContext, String className)
throws ManifoldCFException
{
- IAuthorityConnector connector = getConnectorNoCheck(className);
- connector.install(threadContext);
+ thisFactory.installThis(threadContext,className);
}
/** Uninstall connector.
@@ -52,8 +69,7 @@ public class AuthorityConnectorFactory
public static void deinstall(IThreadContext threadContext, String className)
throws ManifoldCFException
{
- IAuthorityConnector connector = getConnectorNoCheck(className);
- connector.deinstall(threadContext);
+ thisFactory.deinstallThis(threadContext,className);
}
/** Get the default response from a connector. Called if the connection attempt fails.
@@ -61,10 +77,7 @@ public class AuthorityConnectorFactory
public static AuthorizationResponse getDefaultAuthorizationResponse(IThreadContext threadContext, String className, String userName)
throws ManifoldCFException
{
- IAuthorityConnector connector = getConnector(threadContext,className);
- if (connector == null)
- return null;
- return connector.getDefaultAuthorizationResponse(userName);
+ return thisFactory.getThisDefaultAuthorizationResponse(threadContext,className,userName);
}
/** Output the configuration header section.
@@ -72,10 +85,7 @@ public class AuthorityConnectorFactory
public static void outputConfigurationHeader(IThreadContext threadContext, String className, IHTTPOutput out, Locale locale, ConfigParams parameters, ArrayList tabsArray)
throws ManifoldCFException, IOException
{
- IAuthorityConnector 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.
@@ -83,10 +93,7 @@ public class AuthorityConnectorFactory
public static void outputConfigurationBody(IThreadContext threadContext, String className, IHTTPOutput out, Locale locale, ConfigParams parameters, String tabName)
throws ManifoldCFException, IOException
{
- IAuthorityConnector 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.
@@ -94,10 +101,7 @@ public class AuthorityConnectorFactory
public static String processConfigurationPost(IThreadContext threadContext, String className, IPostParameters variableContext, Locale locale, ConfigParams configParams)
throws ManifoldCFException
{
- IAuthorityConnector 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.
@@ -105,11 +109,7 @@ public class AuthorityConnectorFactory
public static void viewConfiguration(IThreadContext threadContext, String className, IHTTPOutput out, Locale locale, ConfigParams configParams)
throws ManifoldCFException, IOException
{
- IAuthorityConnector 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, but do NOT check if class is installed first!
@@ -119,477 +119,8 @@ public class AuthorityConnectorFactory
public static IAuthorityConnector 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 IAuthorityConnector))
- throw new ManifoldCFException("Class '"+className+"' does not implement IAuthorityConnector.");
- return (IAuthorityConnector)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 authority connector class '"+className+"' was found.",
- e);
- }
- catch (NoSuchMethodException e)
- {
- throw new ManifoldCFException("No appropriate constructor for IAuthorityConnector implementation '"+
- className+"'. Need xxx().",
- e);
- }
- catch (SecurityException e)
- {
- throw new ManifoldCFException("Protected constructor for IAuthorityConnector implementation '"+className+"'",
- e);
- }
- catch (IllegalAccessException e)
- {
- throw new ManifoldCFException("Unavailable constructor for IAuthorityConnector implementation '"+className+"'",
- e);
- }
- catch (IllegalArgumentException e)
- {
- throw new ManifoldCFException("Shouldn't happen!!!",e);
- }
- catch (InstantiationException e)
- {
- throw new ManifoldCFException("InstantiationException for IAuthorityConnector implementation '"+className+"'",
- e);
- }
- catch (ExceptionInInitializerError e)
- {
- throw new ManifoldCFException("ExceptionInInitializerError for IAuthorityConnector implementation '"+className+"'",
- e);
- }
-
- }
-
- /** Get a repository connector instance.
- *@param className is the class name.
- *@return the instance.
- */
- protected static IAuthorityConnector getConnector(IThreadContext threadContext, String className)
- throws ManifoldCFException
- {
- IAuthorityConnectorManager connMgr = AuthorityConnectorManagerFactory.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 IAuthorityConnector))
- throw new ManifoldCFException("Class '"+className+"' does not implement IAuthorityConnector.");
- return (IAuthorityConnector)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 authority is not registered.
- if (connMgr.isInstalled(className) == false)
- return null;
-
- throw new ManifoldCFException("No authority connector class '"+className+"' was found.",
- e);
- }
- catch (NoSuchMethodException e)
- {
- throw new ManifoldCFException("No appropriate constructor for IAuthorityConnector implementation '"+
- className+"'. Need xxx().",
- e);
- }
- catch (SecurityException e)
- {
- throw new ManifoldCFException("Protected constructor for IAuthorityConnector implementation '"+className+"'",
- e);
- }
- catch (IllegalAccessException e)
- {
- throw new ManifoldCFException("Unavailable constructor for IAuthorityConnector implementation '"+className+"'",
- e);
- }
- catch (IllegalArgumentException e)
- {
- throw new ManifoldCFException("Shouldn't happen!!!",e);
- }
- catch (InstantiationException e)
- {
- throw new ManifoldCFException("InstantiationException for IAuthorityConnector implementation '"+className+"'",
- e);
- }
- catch (ExceptionInInitializerError e)
- {
- throw new ManifoldCFException("ExceptionInInitializerError for IAuthorityConnector implementation '"+className+"'",
- e);
- }
-
- }
-
- /** 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 IAuthorityConnector grab(IThreadContext threadContext,
- String className, ConfigParams configInfo, int maxPoolSize)
- throws ManifoldCFException
- {
- // System.out.println("In AuthorityConnectorManager.grab()");
-
- // 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);
- }
- }
-
- IAuthorityConnector rval = p.getConnector(threadContext);
- // System.out.println("Leaving AuthorityConnectorManager.grab()");
- return rval;
- }
-
- /** Release a repository connector.
- *@param connector is the connector to release.
- */
- public static void release(IAuthorityConnector connector)
- throws ManifoldCFException
- {
- if (connector == null)
- return;
-
- // System.out.println("Releasing an authority connector");
- // 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 authority 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 authority 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 repository connector.
- * If none exists, construct it using the information in the pool key.
- *@return the connector.
- */
- public synchronized IAuthorityConnector 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();
-
- IAuthorityConnectorManager connMgr = AuthorityConnectorManagerFactory.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 IAuthorityConnector))
- throw new ManifoldCFException("Class '"+className+"' does not implement IAuthorityConnector.");
- IAuthorityConnector newrc = (IAuthorityConnector)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 authority is not registered.
- if (connMgr.isInstalled(className) == false)
- return null;
-
- throw new ManifoldCFException("No authority connector class '"+className+"' was found.",
- e);
- }
- catch (NoSuchMethodException e)
- {
- throw new ManifoldCFException("No appropriate constructor for IAuthorityConnector implementation '"+
- className+"'. Need xxx(ConfigParams).",
- e);
- }
- catch (SecurityException e)
- {
- throw new ManifoldCFException("Protected constructor for IAuthorityConnector implementation '"+className+"'",
- e);
- }
- catch (IllegalAccessException e)
- {
- throw new ManifoldCFException("Unavailable constructor for IAuthorityConnector implementation '"+className+"'",
- e);
- }
- catch (IllegalArgumentException e)
- {
- throw new ManifoldCFException("Shouldn't happen!!!",e);
- }
- catch (InstantiationException e)
- {
- throw new ManifoldCFException("InstantiationException for IAuthorityConnector implementation '"+className+"'",
- e);
- }
- catch (ExceptionInInitializerError e)
- {
- throw new ManifoldCFException("ExceptionInInitializerError for IAuthorityConnector implementation '"+className+"'",
- e);
- }
- }
-
- // Since thread context set can fail, do that before we remove it from the pool.
- IAuthorityConnector rc = (IAuthorityConnector)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(IAuthorityConnector 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();
- }
- }
- }
-
- }
-
-
-
}