You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2011/06/13 19:37:02 UTC

svn commit: r1135192 [1/2] - in /commons/proper/pool/trunk/src: java/org/apache/commons/pool2/impl/ test/org/apache/commons/pool2/ test/org/apache/commons/pool2/impl/ test/org/apache/commons/pool2/performance/

Author: markt
Date: Mon Jun 13 17:37:02 2011
New Revision: 1135192

URL: http://svn.apache.org/viewvc?rev=1135192&view=rev
Log:
Reduce the number of constructors for GenericObjectPool

Modified:
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolConfig.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolConfig.java
    commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolFactory.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestPoolUtils.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java
    commons/proper/pool/trunk/src/test/org/apache/commons/pool2/performance/PerformanceTest.java

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java?rev=1135192&r1=1135191&r2=1135192&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java Mon Jun 13 17:37:02 2011
@@ -20,7 +20,7 @@ package org.apache.commons.pool2.impl;
  * Provides the common configuration attributes used by object pool
  * configurations.
  */
-public abstract class BaseObjectPoolConfig {
+public abstract class BaseObjectPoolConfig implements Cloneable {
 
     /**
      * The default LIFO status. True means that borrowObject returns the most

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolConfig.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolConfig.java?rev=1135192&r1=1135191&r2=1135192&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolConfig.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolConfig.java Mon Jun 13 17:37:02 2011
@@ -24,8 +24,7 @@ import org.apache.commons.pool2.KeyedPoo
  * 
  * @since Pool 2.0
  */
-public class GenericKeyedObjectPoolConfig<K,T> extends BaseObjectPoolConfig
-        implements Cloneable {
+public class GenericKeyedObjectPoolConfig<K,T> extends BaseObjectPoolConfig {
 
     public static final int DEFAULT_MAX_TOTAL_PER_KEY = 8;
 

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java?rev=1135192&r1=1135191&r2=1135192&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java Mon Jun 13 17:37:02 2011
@@ -291,475 +291,32 @@ public class GenericObjectPool<T> extend
      * Create a new <tt>GenericObjectPool</tt> with default properties.
      */
     public GenericObjectPool() {
-        this(null, DEFAULT_MAX_ACTIVE, DEFAULT_WHEN_EXHAUSTED_ACTION,
-                DEFAULT_MAX_WAIT, DEFAULT_MAX_IDLE, DEFAULT_MIN_IDLE,
-                DEFAULT_TEST_ON_BORROW, DEFAULT_TEST_ON_RETURN,
-                DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
-                DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
-                DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
-                DEFAULT_TEST_WHILE_IDLE);
+        this(new GenericObjectPoolConfig<T>());
     }
 
-    /**
-     * Create a new <tt>GenericObjectPool</tt> using the specified factory.
-     * 
-     * @param factory
-     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
-     *            create, validate and destroy objects
-     */
-    public GenericObjectPool(PoolableObjectFactory<T> factory) {
-        this(factory, DEFAULT_MAX_ACTIVE, DEFAULT_WHEN_EXHAUSTED_ACTION,
-                DEFAULT_MAX_WAIT, DEFAULT_MAX_IDLE, DEFAULT_MIN_IDLE,
-                DEFAULT_TEST_ON_BORROW, DEFAULT_TEST_ON_RETURN,
-                DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
-                DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
-                DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
-                DEFAULT_TEST_WHILE_IDLE);
-    }
-
-    /**
-     * Create a new <tt>GenericObjectPool</tt> using the specified values.
-     * 
-     * @param factory
-     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
-     *            create, validate and destroy objects
-     * @param config
-     *            a non-<tt>null</tt> {@link GenericObjectPool.Config}
-     *            describing my configuration
-     */
-    public GenericObjectPool(PoolableObjectFactory<T> factory,
-            GenericObjectPool.Config config) {
-        this(factory, config.maxActive, config.whenExhaustedAction,
-                config.maxWait, config.maxIdle, config.minIdle,
-                config.testOnBorrow, config.testOnReturn,
-                config.timeBetweenEvictionRunsMillis,
-                config.numTestsPerEvictionRun,
-                config.minEvictableIdleTimeMillis, config.testWhileIdle,
-                config.softMinEvictableIdleTimeMillis, config.lifo);
-    }
-
-    /**
-     * Create a new <tt>GenericObjectPool</tt> using the specified values.
-     * 
-     * @param factory
-     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
-     *            create, validate and destroy objects
-     * @param maxActive
-     *            the maximum number of objects that can be borrowed from me at
-     *            one time (see {@link #setMaxActive})
-     */
-    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive) {
-        this(factory, maxActive, DEFAULT_WHEN_EXHAUSTED_ACTION,
-                DEFAULT_MAX_WAIT, DEFAULT_MAX_IDLE, DEFAULT_MIN_IDLE,
-                DEFAULT_TEST_ON_BORROW, DEFAULT_TEST_ON_RETURN,
-                DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
-                DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
-                DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
-                DEFAULT_TEST_WHILE_IDLE);
-    }
-
-    /**
-     * Create a new <tt>GenericObjectPool</tt> using the specified values.
-     * 
-     * @param factory
-     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
-     *            create, validate and destroy objects
-     * @param maxActive
-     *            the maximum number of objects that can be borrowed from me at
-     *            one time (see {@link #setMaxActive})
-     * @param whenExhaustedAction
-     *            the action to take when the pool is exhausted (see
-     *            {@link #getWhenExhaustedAction})
-     * @param maxWait
-     *            the maximum amount of time to wait for an idle object when the
-     *            pool is exhausted an and <i>whenExhaustedAction</i> is
-     *            {@link WhenExhaustedAction#BLOCK} (otherwise ignored) (see
-     *            {@link #getMaxWait})
-     */
-    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive,
-            WhenExhaustedAction whenExhaustedAction, long maxWait) {
-        this(factory, maxActive, whenExhaustedAction, maxWait,
-                DEFAULT_MAX_IDLE, DEFAULT_MIN_IDLE, DEFAULT_TEST_ON_BORROW,
-                DEFAULT_TEST_ON_RETURN,
-                DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
-                DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
-                DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
-                DEFAULT_TEST_WHILE_IDLE);
-    }
-
-    /**
-     * Create a new <tt>GenericObjectPool</tt> using the specified values.
-     * 
-     * @param factory
-     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
-     *            create, validate and destroy objects
-     * @param maxActive
-     *            the maximum number of objects that can be borrowed at one time
-     *            (see {@link #setMaxActive})
-     * @param whenExhaustedAction
-     *            the action to take when the pool is exhausted (see
-     *            {@link #getWhenExhaustedAction})
-     * @param maxWait
-     *            the maximum amount of time to wait for an idle object when the
-     *            pool is exhausted an and <i>whenExhaustedAction</i> is
-     *            {@link WhenExhaustedAction#BLOCK} (otherwise ignored) (see
-     *            {@link #getMaxWait})
-     * @param testOnBorrow
-     *            whether or not to validate objects before they are returned by
-     *            the {@link #borrowObject} method (see {@link #getTestOnBorrow}
-     *            )
-     * @param testOnReturn
-     *            whether or not to validate objects after they are returned to
-     *            the {@link #returnObject} method (see {@link #getTestOnReturn}
-     *            )
-     */
-    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive,
-            WhenExhaustedAction whenExhaustedAction, long maxWait,
-            boolean testOnBorrow, boolean testOnReturn) {
-        this(factory, maxActive, whenExhaustedAction, maxWait,
-                DEFAULT_MAX_IDLE, DEFAULT_MIN_IDLE, testOnBorrow, testOnReturn,
-                DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
-                DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
-                DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
-                DEFAULT_TEST_WHILE_IDLE);
-    }
-
-    /**
-     * Create a new <tt>GenericObjectPool</tt> using the specified values.
-     * 
-     * @param factory
-     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
-     *            create, validate and destroy objects
-     * @param maxActive
-     *            the maximum number of objects that can be borrowed at one time
-     *            (see {@link #setMaxActive})
-     * @param whenExhaustedAction
-     *            the action to take when the pool is exhausted (see
-     *            {@link #getWhenExhaustedAction})
-     * @param maxWait
-     *            the maximum amount of time to wait for an idle object when the
-     *            pool is exhausted and <i>whenExhaustedAction</i> is
-     *            {@link WhenExhaustedAction#BLOCK} (otherwise ignored) (see
-     *            {@link #getMaxWait})
-     * @param maxIdle
-     *            the maximum number of idle objects in my pool (see
-     *            {@link #getMaxIdle})
-     */
-    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive,
-            WhenExhaustedAction whenExhaustedAction, long maxWait,
-            int maxIdle) {
-        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
-                DEFAULT_MIN_IDLE, DEFAULT_TEST_ON_BORROW,
-                DEFAULT_TEST_ON_RETURN,
-                DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
-                DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
-                DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
-                DEFAULT_TEST_WHILE_IDLE);
-    }
-
-    /**
-     * Create a new <tt>GenericObjectPool</tt> using the specified values.
-     * 
-     * @param factory
-     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
-     *            create, validate and destroy objects
-     * @param maxActive
-     *            the maximum number of objects that can be borrowed at one time
-     *            (see {@link #setMaxActive})
-     * @param whenExhaustedAction
-     *            the action to take when the pool is exhausted (see
-     *            {@link #getWhenExhaustedAction})
-     * @param maxWait
-     *            the maximum amount of time to wait for an idle object when the
-     *            pool is exhausted and <i>whenExhaustedAction</i> is
-     *            {@link WhenExhaustedAction#BLOCK} (otherwise ignored) (see
-     *            {@link #getMaxWait})
-     * @param maxIdle
-     *            the maximum number of idle objects in my pool (see
-     *            {@link #getMaxIdle})
-     * @param testOnBorrow
-     *            whether or not to validate objects before they are returned by
-     *            the {@link #borrowObject} method (see {@link #getTestOnBorrow}
-     *            )
-     * @param testOnReturn
-     *            whether or not to validate objects after they are returned to
-     *            the {@link #returnObject} method (see {@link #getTestOnReturn}
-     *            )
-     */
-    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive,
-            WhenExhaustedAction whenExhaustedAction, long maxWait, int maxIdle,
-            boolean testOnBorrow, boolean testOnReturn) {
-        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
-                DEFAULT_MIN_IDLE, testOnBorrow, testOnReturn,
-                DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
-                DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
-                DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
-                DEFAULT_TEST_WHILE_IDLE);
-    }
-
-    /**
-     * Create a new <tt>GenericObjectPool</tt> using the specified values.
-     * 
-     * @param factory
-     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
-     *            create, validate and destroy objects
-     * @param maxActive
-     *            the maximum number of objects that can be borrowed at one time
-     *            (see {@link #setMaxActive})
-     * @param whenExhaustedAction
-     *            the action to take when the pool is exhausted (see
-     *            {@link #setWhenExhaustedAction})
-     * @param maxWait
-     *            the maximum amount of time to wait for an idle object when the
-     *            pool is exhausted and <i>whenExhaustedAction</i> is
-     *            {@link WhenExhaustedAction#BLOCK} (otherwise ignored) (see
-     *            {@link #setMaxWait})
-     * @param maxIdle
-     *            the maximum number of idle objects in my pool (see
-     *            {@link #setMaxIdle})
-     * @param testOnBorrow
-     *            whether or not to validate objects before they are returned by
-     *            the {@link #borrowObject} method (see {@link #setTestOnBorrow}
-     *            )
-     * @param testOnReturn
-     *            whether or not to validate objects after they are returned to
-     *            the {@link #returnObject} method (see {@link #setTestOnReturn}
-     *            )
-     * @param timeBetweenEvictionRunsMillis
-     *            the amount of time (in milliseconds) to sleep between
-     *            examining idle objects for eviction (see
-     *            {@link #setTimeBetweenEvictionRunsMillis})
-     * @param numTestsPerEvictionRun
-     *            the number of idle objects to examine per run within the idle
-     *            object eviction thread (if any) (see
-     *            {@link #setNumTestsPerEvictionRun})
-     * @param minEvictableIdleTimeMillis
-     *            the minimum number of milliseconds an object can sit idle in
-     *            the pool before it is eligible for eviction (see
-     *            {@link #setMinEvictableIdleTimeMillis})
-     * @param testWhileIdle
-     *            whether or not to validate objects in the idle object eviction
-     *            thread, if any (see {@link #setTestWhileIdle})
-     */
-    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive,
-            WhenExhaustedAction whenExhaustedAction, long maxWait, int maxIdle,
-            boolean testOnBorrow, boolean testOnReturn,
-            long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun,
-            long minEvictableIdleTimeMillis, boolean testWhileIdle) {
-        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
-                DEFAULT_MIN_IDLE, testOnBorrow, testOnReturn,
-                timeBetweenEvictionRunsMillis, numTestsPerEvictionRun,
-                minEvictableIdleTimeMillis, testWhileIdle);
-    }
-
-    /**
-     * Create a new <tt>GenericObjectPool</tt> using the specified values.
-     * 
-     * @param factory
-     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
-     *            create, validate and destroy objects
-     * @param maxActive
-     *            the maximum number of objects that can be borrowed at one time
-     *            (see {@link #setMaxActive})
-     * @param whenExhaustedAction
-     *            the action to take when the pool is exhausted (see
-     *            {@link #setWhenExhaustedAction})
-     * @param maxWait
-     *            the maximum amount of time to wait for an idle object when the
-     *            pool is exhausted and <i>whenExhaustedAction</i> is
-     *            {@link WhenExhaustedAction#BLOCK} (otherwise ignored) (see
-     *            {@link #setMaxWait})
-     * @param maxIdle
-     *            the maximum number of idle objects in my pool (see
-     *            {@link #setMaxIdle})
-     * @param minIdle
-     *            the minimum number of idle objects in my pool (see
-     *            {@link #setMinIdle})
-     * @param testOnBorrow
-     *            whether or not to validate objects before they are returned by
-     *            the {@link #borrowObject} method (see {@link #setTestOnBorrow}
-     *            )
-     * @param testOnReturn
-     *            whether or not to validate objects after they are returned to
-     *            the {@link #returnObject} method (see {@link #setTestOnReturn}
-     *            )
-     * @param timeBetweenEvictionRunsMillis
-     *            the amount of time (in milliseconds) to sleep between
-     *            examining idle objects for eviction (see
-     *            {@link #setTimeBetweenEvictionRunsMillis})
-     * @param numTestsPerEvictionRun
-     *            the number of idle objects to examine per run within the idle
-     *            object eviction thread (if any) (see
-     *            {@link #setNumTestsPerEvictionRun})
-     * @param minEvictableIdleTimeMillis
-     *            the minimum number of milliseconds an object can sit idle in
-     *            the pool before it is eligible for eviction (see
-     *            {@link #setMinEvictableIdleTimeMillis})
-     * @param testWhileIdle
-     *            whether or not to validate objects in the idle object eviction
-     *            thread, if any (see {@link #setTestWhileIdle})
-     */
-    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive,
-            WhenExhaustedAction whenExhaustedAction, long maxWait, int maxIdle,
-            int minIdle, boolean testOnBorrow, boolean testOnReturn,
-            long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun,
-            long minEvictableIdleTimeMillis, boolean testWhileIdle) {
-        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
-                minIdle, testOnBorrow, testOnReturn,
-                timeBetweenEvictionRunsMillis, numTestsPerEvictionRun,
-                minEvictableIdleTimeMillis, testWhileIdle,
-                DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
-    }
-
-    /**
-     * Create a new <tt>GenericObjectPool</tt> using the specified values.
-     * 
-     * @param factory
-     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
-     *            create, validate and destroy objects
-     * @param maxActive
-     *            the maximum number of objects that can be borrowed at one time
-     *            (see {@link #setMaxActive})
-     * @param whenExhaustedAction
-     *            the action to take when the pool is exhausted (see
-     *            {@link #setWhenExhaustedAction})
-     * @param maxWait
-     *            the maximum amount of time to wait for an idle object when the
-     *            pool is exhausted and <i>whenExhaustedAction</i> is
-     *            {@link WhenExhaustedAction#BLOCK} (otherwise ignored) (see
-     *            {@link #setMaxWait})
-     * @param maxIdle
-     *            the maximum number of idle objects in my pool (see
-     *            {@link #setMaxIdle})
-     * @param minIdle
-     *            the minimum number of idle objects in my pool (see
-     *            {@link #setMinIdle})
-     * @param testOnBorrow
-     *            whether or not to validate objects before they are returned by
-     *            the {@link #borrowObject} method (see {@link #setTestOnBorrow}
-     *            )
-     * @param testOnReturn
-     *            whether or not to validate objects after they are returned to
-     *            the {@link #returnObject} method (see {@link #setTestOnReturn}
-     *            )
-     * @param timeBetweenEvictionRunsMillis
-     *            the amount of time (in milliseconds) to sleep between
-     *            examining idle objects for eviction (see
-     *            {@link #setTimeBetweenEvictionRunsMillis})
-     * @param numTestsPerEvictionRun
-     *            the number of idle objects to examine per run within the idle
-     *            object eviction thread (if any) (see
-     *            {@link #setNumTestsPerEvictionRun})
-     * @param minEvictableIdleTimeMillis
-     *            the minimum number of milliseconds an object can sit idle in
-     *            the pool before it is eligible for eviction (see
-     *            {@link #setMinEvictableIdleTimeMillis})
-     * @param testWhileIdle
-     *            whether or not to validate objects in the idle object eviction
-     *            thread, if any (see {@link #setTestWhileIdle})
-     * @param softMinEvictableIdleTimeMillis
-     *            the minimum number of milliseconds an object can sit idle in
-     *            the pool before it is eligible for eviction with the extra
-     *            condition that at least "minIdle" amount of object remain in
-     *            the pool. (see {@link #setSoftMinEvictableIdleTimeMillis})
-     * @since Pool 1.3
-     */
-    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive,
-            WhenExhaustedAction whenExhaustedAction, long maxWait, int maxIdle,
-            int minIdle, boolean testOnBorrow, boolean testOnReturn,
-            long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun,
-            long minEvictableIdleTimeMillis, boolean testWhileIdle,
-            long softMinEvictableIdleTimeMillis) {
-        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
-                minIdle, testOnBorrow, testOnReturn,
-                timeBetweenEvictionRunsMillis, numTestsPerEvictionRun,
-                minEvictableIdleTimeMillis, testWhileIdle,
-                softMinEvictableIdleTimeMillis, DEFAULT_LIFO);
-    }
-
-    /**
-     * Create a new <tt>GenericObjectPool</tt> using the specified values.
-     * 
-     * @param factory
-     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
-     *            create, validate and destroy objects
-     * @param maxActive
-     *            the maximum number of objects that can be borrowed at one time
-     *            (see {@link #setMaxActive})
-     * @param whenExhaustedAction
-     *            the action to take when the pool is exhausted (see
-     *            {@link #setWhenExhaustedAction})
-     * @param maxWait
-     *            the maximum amount of time to wait for an idle object when the
-     *            pool is exhausted and <i>whenExhaustedAction</i> is
-     *            {@link WhenExhaustedAction#BLOCK} (otherwise ignored) (see
-     *            {@link #setMaxWait})
-     * @param maxIdle
-     *            the maximum number of idle objects in my pool (see
-     *            {@link #setMaxIdle})
-     * @param minIdle
-     *            the minimum number of idle objects in my pool (see
-     *            {@link #setMinIdle})
-     * @param testOnBorrow
-     *            whether or not to validate objects before they are returned by
-     *            the {@link #borrowObject} method (see {@link #setTestOnBorrow}
-     *            )
-     * @param testOnReturn
-     *            whether or not to validate objects after they are returned to
-     *            the {@link #returnObject} method (see {@link #setTestOnReturn}
-     *            )
-     * @param timeBetweenEvictionRunsMillis
-     *            the amount of time (in milliseconds) to sleep between
-     *            examining idle objects for eviction (see
-     *            {@link #setTimeBetweenEvictionRunsMillis})
-     * @param numTestsPerEvictionRun
-     *            the number of idle objects to examine per run within the idle
-     *            object eviction thread (if any) (see
-     *            {@link #setNumTestsPerEvictionRun})
-     * @param minEvictableIdleTimeMillis
-     *            the minimum number of milliseconds an object can sit idle in
-     *            the pool before it is eligible for eviction (see
-     *            {@link #setMinEvictableIdleTimeMillis})
-     * @param testWhileIdle
-     *            whether or not to validate objects in the idle object eviction
-     *            thread, if any (see {@link #setTestWhileIdle})
-     * @param softMinEvictableIdleTimeMillis
-     *            the minimum number of milliseconds an object can sit idle in
-     *            the pool before it is eligible for eviction with the extra
-     *            condition that at least "minIdle" amount of object remain in
-     *            the pool. (see {@link #setSoftMinEvictableIdleTimeMillis})
-     * @param lifo
-     *            whether or not objects are returned in last-in-first-out order
-     *            from the idle object pool (see {@link #setLifo})
-     * @since Pool 1.4
-     */
-    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive,
-            WhenExhaustedAction whenExhaustedAction, long maxWait, int maxIdle,
-            int minIdle, boolean testOnBorrow, boolean testOnReturn,
-            long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun,
-            long minEvictableIdleTimeMillis, boolean testWhileIdle,
-            long softMinEvictableIdleTimeMillis, boolean lifo) {
-        _factory = factory;
-        _maxActive = maxActive;
-        _lifo = lifo;
-        _whenExhaustedAction = whenExhaustedAction;
-        _maxWait = maxWait;
-        _maxIdle = maxIdle;
-        _minIdle = minIdle;
-        _testOnBorrow = testOnBorrow;
-        _testOnReturn = testOnReturn;
-        _timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
-        _numTestsPerEvictionRun = numTestsPerEvictionRun;
-        _minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
-        _softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis;
-        _testWhileIdle = testWhileIdle;
-
-        _idleObjects = new LinkedBlockingDeque<PooledObject<T>>();
-        _allObjects = new ConcurrentHashMap<T, PooledObject<T>>();
+    public GenericObjectPool(GenericObjectPoolConfig<T> config) {
+        this._factory = config.getFactory();
+        this._lifo = config.getLifo();
+        this._maxActive = config.getMaxTotal();
+        this._maxIdle = config.getMaxIdle();
+        this._maxWait = config.getMaxWait();
+        this._minEvictableIdleTimeMillis =
+                config.getMinEvictableIdleTimeMillis();
+        this._minIdle = config.getMinIdle();
+        this._numTestsPerEvictionRun = config.getNumTestsPerEvictionRun();
+        this._softMinEvictableIdleTimeMillis =
+                config.getSoftMinEvictableIdleTimeMillis();
+        this._testOnBorrow = config.getTestOnBorrow();
+        this._testOnReturn = config.getTestOnReturn();
+        this._testWhileIdle = config.getTestWhileIdle();
+        this._timeBetweenEvictionRunsMillis =
+                config.getTimeBetweenEvictionRunsMillis();
+        this._whenExhaustedAction = config.getWhenExhaustedAction();
 
         startEvictor(_timeBetweenEvictionRunsMillis);
     }
 
+
     // --- public methods ---------------------------------------------
 
     // --- configuration methods --------------------------------------
@@ -2011,7 +1568,8 @@ public class GenericObjectPool<T> extend
      * {@link #_allObjects} will always be less than or equal to {@link
      * #_maxActive}.
      */
-    private Map<T, PooledObject<T>> _allObjects = null;
+    private final Map<T, PooledObject<T>> _allObjects =
+        new ConcurrentHashMap<T, PooledObject<T>>();
 
     /**
      * The combined count of the currently created objects and those in the
@@ -2020,10 +1578,11 @@ public class GenericObjectPool<T> extend
      * {@link #create(boolean)} will ensure that there are never more than
      * {@link #_maxActive} objects created at any one time.
      */
-    private AtomicLong createCount = new AtomicLong(0);
+    private final AtomicLong createCount = new AtomicLong(0);
 
     /** The queue of idle objects */
-    private LinkedBlockingDeque<PooledObject<T>> _idleObjects = null;
+    private final LinkedBlockingDeque<PooledObject<T>> _idleObjects =
+        new LinkedBlockingDeque<PooledObject<T>>();
 
     /** An iterator for {@link #_idleObjects} that is used by the evictor. */
     private Iterator<PooledObject<T>> _evictionIterator = null;

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolConfig.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolConfig.java?rev=1135192&r1=1135191&r2=1135192&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolConfig.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolConfig.java Mon Jun 13 17:37:02 2011
@@ -24,7 +24,7 @@ import org.apache.commons.pool2.Poolable
  * 
  * @since Pool 2.0
  */
-public class GenericObjectPoolConfig extends BaseObjectPoolConfig {
+public class GenericObjectPoolConfig<T> extends BaseObjectPoolConfig {
 
     /**
      * The default value for {@link #getSoftMinEvictableIdleTimeMillis}.
@@ -37,20 +37,35 @@ public class GenericObjectPoolConfig ext
      */
     public static final int DEFAULT_MAX_TOTAL = 8;
 
+    /**
+     * The default cap on the number of "sleeping" instances in the pool.
+     */
+    public static final int DEFAULT_MAX_IDLE = 8;
+
+    /**
+     * The default minimum number of "sleeping" instances in the pool before
+     * before the evictor thread (if active) spawns new objects.
+     */
+    public static final int DEFAULT_MIN_IDLE = 0;
 
-    private PoolableObjectFactory<?> factory = null;
+    
+    private PoolableObjectFactory<T> factory = null;
 
     private long softMinEvictableIdleTimeMillis =
         DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
 
     private int maxTotal = DEFAULT_MAX_TOTAL;
 
+    private int maxIdle = DEFAULT_MAX_IDLE;
+    
+    private int minIdle = DEFAULT_MIN_IDLE;
 
-    public PoolableObjectFactory<?> getFactory() {
+
+    public PoolableObjectFactory<T> getFactory() {
         return factory;
     }
 
-    public void setFactory(PoolableObjectFactory<?> factory) {
+    public void setFactory(PoolableObjectFactory<T> factory) {
         this.factory = factory;
     }
 
@@ -72,4 +87,32 @@ public class GenericObjectPoolConfig ext
     public void setMaxTotal(int maxTotal) {
         this.maxTotal = maxTotal;
     }
+
+
+    public int getMaxIdle() {
+        return maxIdle;
+    }
+
+    public void setMaxIdle(int maxIdle) {
+        this.maxIdle = maxIdle;
+    }
+
+        
+    public int getMinIdle() {
+        return minIdle;
+    }
+
+    public void setMinIdle(int minIdle) {
+        this.minIdle = minIdle;
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public GenericObjectPoolConfig<T> clone() {
+        try {
+            return (GenericObjectPoolConfig<T>) super.clone();
+        } catch (CloneNotSupportedException e) {
+            throw new AssertionError(); // Can't happen
+        }
+    }
 }

Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolFactory.java?rev=1135192&r1=1135191&r2=1135192&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolFactory.java (original)
+++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolFactory.java Mon Jun 13 17:37:02 2011
@@ -19,678 +19,62 @@ package org.apache.commons.pool2.impl;
 
 import org.apache.commons.pool2.ObjectPool;
 import org.apache.commons.pool2.ObjectPoolFactory;
-import org.apache.commons.pool2.PoolableObjectFactory;
 
 /**
- * A factory for creating {@link GenericObjectPool} instances.
- * 
- * @see GenericObjectPool
- * @see ObjectPoolFactory
- * @param <T>
- *            Type of element pooled in the built pool.
- * @author Rodney Waldhoff
- * @version $Revision$ $Date: 2011-05-11 14:56:24 +0100 (Wed, 11 May
- *          2011) $
+ * A factory for creating {@link GenericObjectPool} instances from a provided
+ * {@link GenericObjectPoolConfig configuration}.
+ *
+ * @param <T> Type of element pooled in the built pool.
+ *
  * @since Pool 1.0
  */
-public class GenericObjectPoolFactory<T> implements ObjectPoolFactory<T> {
-    /**
-     * Create a new GenericObjectPoolFactory.
-     * 
-     * @param factory
-     *            the PoolableObjectFactory used by created pools.
-     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory)
-     */
-    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory) {
-        this(factory, GenericObjectPool.DEFAULT_MAX_ACTIVE,
-                GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION,
-                GenericObjectPool.DEFAULT_MAX_WAIT,
-                GenericObjectPool.DEFAULT_MAX_IDLE,
-                GenericObjectPool.DEFAULT_MIN_IDLE,
-                GenericObjectPool.DEFAULT_TEST_ON_BORROW,
-                GenericObjectPool.DEFAULT_TEST_ON_RETURN,
-                GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
-                GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
-                GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
-                GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
-    }
 
-    /**
-     * Create a new GenericObjectPoolFactory.
-     * 
-     * @param factory
-     *            the PoolableObjectFactory used by created pools.
-     * @param config
-     *            a non-<code>null</code> GenericObjectPool.Config describing
-     *            the configuration.
-     * @throws NullPointerException
-     *             when config is <code>null</code>.
-     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory,
-     *      GenericObjectPool.Config)
-     */
-    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
-            GenericObjectPool.Config config) throws NullPointerException {
-        this(factory, config.maxActive, config.whenExhaustedAction,
-                config.maxWait, config.maxIdle, config.minIdle,
-                config.testOnBorrow, config.testOnReturn,
-                config.timeBetweenEvictionRunsMillis,
-                config.numTestsPerEvictionRun,
-                config.minEvictableIdleTimeMillis, config.testWhileIdle,
-                config.softMinEvictableIdleTimeMillis, config.lifo);
-    }
-
-    /**
-     * Create a new GenericObjectPoolFactory.
-     * 
-     * @param factory
-     *            the PoolableObjectFactory used by created pools.
-     * @param maxActive
-     *            maximum number of objects that can be borrowed from created
-     *            pools at one time.
-     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int)
-     */
-    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
-            int maxActive) {
-        this(factory, maxActive,
-                GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION,
-                GenericObjectPool.DEFAULT_MAX_WAIT,
-                GenericObjectPool.DEFAULT_MAX_IDLE,
-                GenericObjectPool.DEFAULT_MIN_IDLE,
-                GenericObjectPool.DEFAULT_TEST_ON_BORROW,
-                GenericObjectPool.DEFAULT_TEST_ON_RETURN,
-                GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
-                GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
-                GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
-                GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
-    }
-
-    /**
-     * Create a new GenericObjectPoolFactory.
-     * 
-     * @param factory
-     *            the PoolableObjectFactory used by created pools.
-     * @param maxActive
-     *            maximum number of objects that can be borrowed from created
-     *            pools at one time.
-     * @param whenExhaustedAction
-     *            the action to take when the pool is exhausted.
-     * @param maxWait
-     *            the maximum amount of time to wait for an idle object when the
-     *            pool is exhausted.
-     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int,
-     *      byte, long)
-     */
-    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
-            int maxActive, WhenExhaustedAction whenExhaustedAction,
-            long maxWait) {
-        this(factory, maxActive, whenExhaustedAction, maxWait,
-                GenericObjectPool.DEFAULT_MAX_IDLE,
-                GenericObjectPool.DEFAULT_MIN_IDLE,
-                GenericObjectPool.DEFAULT_TEST_ON_BORROW,
-                GenericObjectPool.DEFAULT_TEST_ON_RETURN,
-                GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
-                GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
-                GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
-                GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
-    }
+public class GenericObjectPoolFactory<T> implements ObjectPoolFactory<T> {
 
-    /**
-     * Create a new GenericObjectPoolFactory.
-     * 
-     * @param factory
-     *            the PoolableObjectFactory used by created pools.
-     * @param maxActive
-     *            maximum number of objects that can be borrowed from created
-     *            pools at one time.
-     * @param whenExhaustedAction
-     *            the action to take when the pool is exhausted.
-     * @param maxWait
-     *            the maximum amount of time to wait for an idle object when the
-     *            pool is exhausted.
-     * @param testOnBorrow
-     *            whether to validate objects before they are returned by the
-     *            borrowObject.
-     * @param testOnReturn
-     *            whether to validate objects after they are returned to the
-     *            returnObject.
-     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int,
-     *      byte, long, boolean, boolean)
-     */
-    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
-            int maxActive, WhenExhaustedAction whenExhaustedAction,
-            long maxWait, boolean testOnBorrow, boolean testOnReturn) {
-        this(factory, maxActive, whenExhaustedAction, maxWait,
-                GenericObjectPool.DEFAULT_MAX_IDLE,
-                GenericObjectPool.DEFAULT_MIN_IDLE, testOnBorrow, testOnReturn,
-                GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
-                GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
-                GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
-                GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
-    }
+    private GenericObjectPoolConfig<T> config;
 
-    /**
-     * Create a new GenericObjectPoolFactory.
-     * 
-     * @param factory
-     *            the PoolableObjectFactory used by created pools.
-     * @param maxActive
-     *            maximum number of objects that can be borrowed from created
-     *            pools at one time.
-     * @param whenExhaustedAction
-     *            the action to take when the pool is exhausted.
-     * @param maxWait
-     *            the maximum amount of time to wait for an idle object when the
-     *            pool is exhausted.
-     * @param maxIdle
-     *            the maximum number of idle objects in my pool.
-     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int,
-     *      byte, long, int)
-     */
-    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
-            int maxActive, WhenExhaustedAction whenExhaustedAction,
-            long maxWait, int maxIdle) {
-        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
-                GenericObjectPool.DEFAULT_MIN_IDLE,
-                GenericObjectPool.DEFAULT_TEST_ON_BORROW,
-                GenericObjectPool.DEFAULT_TEST_ON_RETURN,
-                GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
-                GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
-                GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
-                GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
-    }
 
     /**
      * Create a new GenericObjectPoolFactory.
      * 
-     * @param factory
-     *            the PoolableObjectFactory used by created pools.
-     * @param maxActive
-     *            maximum number of objects that can be borrowed from created
-     *            pools at one time.
-     * @param whenExhaustedAction
-     *            the action to take when the pool is exhausted.
-     * @param maxWait
-     *            the maximum amount of time to wait for an idle object when the
-     *            pool is exhausted.
-     * @param maxIdle
-     *            the maximum number of idle objects in my pool.
-     * @param testOnBorrow
-     *            whether to validate objects before they are returned by the
-     *            borrowObject.
-     * @param testOnReturn
-     *            whether to validate objects after they are returned to the
-     *            returnObject.
-     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int,
-     *      byte, long, int, boolean, boolean)
+     * @param config    The configuration that will be used for all pools
+     *                  created by this factory. Note that the configuration is
+     *                  passed by value. Subsequent changes to config will not
+     *                  be reflected in this factory or the pools it creates.
      */
-    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
-            int maxActive, WhenExhaustedAction whenExhaustedAction,
-            long maxWait, int maxIdle, boolean testOnBorrow,
-            boolean testOnReturn) {
-        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
-                GenericObjectPool.DEFAULT_MIN_IDLE, testOnBorrow, testOnReturn,
-                GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
-                GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
-                GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
-                GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
+    public GenericObjectPoolFactory(GenericObjectPoolConfig<T> config) {
+        this.config = config.clone();
     }
 
+    
     /**
-     * Create a new GenericObjectPoolFactory.
-     * 
-     * @param factory
-     *            the PoolableObjectFactory used by created pools.
-     * @param maxActive
-     *            maximum number of objects that can be borrowed from created
-     *            pools at one time.
-     * @param whenExhaustedAction
-     *            the action to take when the pool is exhausted.
-     * @param maxWait
-     *            the maximum amount of time to wait for an idle object when the
-     *            pool is exhausted.
-     * @param maxIdle
-     *            the maximum number of idle objects in my pool.
-     * @param testOnBorrow
-     *            whether to validate objects before they are returned by the
-     *            borrowObject.
-     * @param testOnReturn
-     *            whether to validate objects after they are returned to the
-     *            returnObject.
-     * @param timeBetweenEvictionRunsMillis
-     *            the number of milliseconds to sleep between examining idle
-     *            objects for eviction.
-     * @param numTestsPerEvictionRun
-     *            the number of idle objects to examine per run within the idle
-     *            object eviction thread.
-     * @param minEvictableIdleTimeMillis
-     *            the minimum number of milliseconds an object can sit idle in
-     *            the pool before it is eligible for eviction.
-     * @param testWhileIdle
-     *            whether or not to validate objects in the idle object eviction
-     *            thread.
-     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int,
-     *      byte, long, int, boolean, boolean, long, int, long, boolean)
+     * Obtain the configuration currently used by the factory allowing the
+     * current settings to be viewed and changed.
+     *  
+     * @return  The config object currently used by the factory
      */
-    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
-            int maxActive, WhenExhaustedAction whenExhaustedAction,
-            long maxWait, int maxIdle, boolean testOnBorrow,
-            boolean testOnReturn, long timeBetweenEvictionRunsMillis,
-            int numTestsPerEvictionRun, long minEvictableIdleTimeMillis,
-            boolean testWhileIdle) {
-        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
-                GenericObjectPool.DEFAULT_MIN_IDLE, testOnBorrow, testOnReturn,
-                timeBetweenEvictionRunsMillis, numTestsPerEvictionRun,
-                minEvictableIdleTimeMillis, testWhileIdle,
-                GenericObjectPool.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
+    public GenericObjectPoolConfig<T> getConfig() {
+        return config;
     }
 
-    /**
-     * Create a new GenericObjectPoolFactory.
-     * 
-     * @param factory
-     *            the PoolableObjectFactory used by created pools.
-     * @param maxActive
-     *            maximum number of objects that can be borrowed from created
-     *            pools at one time.
-     * @param whenExhaustedAction
-     *            the action to take when the pool is exhausted.
-     * @param maxWait
-     *            the maximum amount of time to wait for an idle object when the
-     *            pool is exhausted.
-     * @param maxIdle
-     *            the maximum number of idle objects in my pool.
-     * @param minIdle
-     *            the minimum number of idle objects in my pool.
-     * @param testOnBorrow
-     *            whether to validate objects before they are returned by the
-     *            borrowObject.
-     * @param testOnReturn
-     *            whether to validate objects after they are returned to the
-     *            returnObject.
-     * @param timeBetweenEvictionRunsMillis
-     *            the number of milliseconds to sleep between examining idle
-     *            objects for eviction.
-     * @param numTestsPerEvictionRun
-     *            the number of idle objects to examine per run within the idle
-     *            object eviction thread.
-     * @param minEvictableIdleTimeMillis
-     *            the minimum number of milliseconds an object can sit idle in
-     *            the pool before it is eligible for eviction.
-     * @param testWhileIdle
-     *            whether or not to validate objects in the idle object eviction
-     *            thread.
-     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int,
-     *      byte, long, int, int, boolean, boolean, long, int, long, boolean)
-     */
-    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
-            int maxActive, WhenExhaustedAction whenExhaustedAction,
-            long maxWait, int maxIdle, int minIdle, boolean testOnBorrow,
-            boolean testOnReturn, long timeBetweenEvictionRunsMillis,
-            int numTestsPerEvictionRun, long minEvictableIdleTimeMillis,
-            boolean testWhileIdle) {
-        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
-                minIdle, testOnBorrow, testOnReturn,
-                timeBetweenEvictionRunsMillis, numTestsPerEvictionRun,
-                minEvictableIdleTimeMillis, testWhileIdle,
-                GenericObjectPool.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
-    }
 
     /**
-     * Create a new GenericObjectPoolFactory.
-     * 
-     * @param factory
-     *            the PoolableObjectFactory used by created pools.
-     * @param maxActive
-     *            maximum number of objects that can be borrowed from created
-     *            pools at one time.
-     * @param whenExhaustedAction
-     *            the action to take when the pool is exhausted.
-     * @param maxWait
-     *            the maximum amount of time to wait for an idle object when the
-     *            pool is exhausted.
-     * @param maxIdle
-     *            the maximum number of idle objects in my pool.
-     * @param minIdle
-     *            the minimum number of idle objects in my pool.
-     * @param testOnBorrow
-     *            whether to validate objects before they are returned by the
-     *            borrowObject.
-     * @param testOnReturn
-     *            whether to validate objects after they are returned to the
-     *            returnObject.
-     * @param timeBetweenEvictionRunsMillis
-     *            the number of milliseconds to sleep between examining idle
-     *            objects for eviction.
-     * @param numTestsPerEvictionRun
-     *            the number of idle objects to examine per run within the idle
-     *            object eviction thread.
-     * @param minEvictableIdleTimeMillis
-     *            the minimum number of milliseconds an object can sit idle in
-     *            the pool before it is eligible for eviction.
-     * @param testWhileIdle
-     *            whether or not to validate objects in the idle object eviction
-     *            thread.
-     * @param softMinEvictableIdleTimeMillis
-     *            the minimum number of milliseconds an object can sit idle in
-     *            the pool before it is eligible for eviction with the extra
-     *            condition that at least "minIdle" amount of object remain in
-     *            the pool.
-     * @since Pool 1.3
-     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int,
-     *      byte, long, int, int, boolean, boolean, long, int, long, boolean,
-     *      long)
+     * Replace the configuration settings used by this factory.
+     *  
+     * @param config    The new settings which will be passed by value
      */
-    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
-            int maxActive, WhenExhaustedAction whenExhaustedAction,
-            long maxWait, int maxIdle, int minIdle, boolean testOnBorrow,
-            boolean testOnReturn, long timeBetweenEvictionRunsMillis,
-            int numTestsPerEvictionRun, long minEvictableIdleTimeMillis,
-            boolean testWhileIdle, long softMinEvictableIdleTimeMillis) {
-        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
-                minIdle, testOnBorrow, testOnReturn,
-                timeBetweenEvictionRunsMillis, numTestsPerEvictionRun,
-                minEvictableIdleTimeMillis, testWhileIdle,
-                softMinEvictableIdleTimeMillis, GenericObjectPool.DEFAULT_LIFO);
+    public void setConfig(GenericObjectPoolConfig<T> config) {
+        this.config = config.clone();
     }
 
+    
     /**
-     * Create a new GenericObjectPoolFactory.
+     * Create a new GenericKeyedObjectPool with the currently configured
+     * properties.
      * 
-     * @param factory
-     *            the PoolableObjectFactory used by created pools.
-     * @param maxActive
-     *            maximum number of objects that can be borrowed from created
-     *            pools at one time.
-     * @param whenExhaustedAction
-     *            the action to take when the pool is exhausted.
-     * @param maxWait
-     *            the maximum amount of time to wait for an idle object when the
-     *            pool is exhausted.
-     * @param maxIdle
-     *            the maximum number of idle objects in my pool.
-     * @param minIdle
-     *            the minimum number of idle objects in my pool.
-     * @param testOnBorrow
-     *            whether to validate objects before they are returned by the
-     *            borrowObject.
-     * @param testOnReturn
-     *            whether to validate objects after they are returned to the
-     *            returnObject.
-     * @param timeBetweenEvictionRunsMillis
-     *            the number of milliseconds to sleep between examining idle
-     *            objects for eviction.
-     * @param numTestsPerEvictionRun
-     *            the number of idle objects to examine per run within the idle
-     *            object eviction thread.
-     * @param minEvictableIdleTimeMillis
-     *            the minimum number of milliseconds an object can sit idle in
-     *            the pool before it is eligible for eviction.
-     * @param testWhileIdle
-     *            whether or not to validate objects in the idle object eviction
-     *            thread.
-     * @param softMinEvictableIdleTimeMillis
-     *            the minimum number of milliseconds an object can sit idle in
-     *            the pool before it is eligible for eviction with the extra
-     *            condition that at least "minIdle" amount of object remain in
-     *            the pool.
-     * @param lifo
-     *            whether or not objects are returned in last-in-first-out order
-     *            from the idle object pool.
-     * @since Pool 1.4
-     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int,
-     *      byte, long, int, int, boolean, boolean, long, int, long, boolean,
-     *      long, boolean)
-     */
-    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
-            int maxActive, WhenExhaustedAction whenExhaustedAction,
-            long maxWait, int maxIdle, int minIdle, boolean testOnBorrow,
-            boolean testOnReturn, long timeBetweenEvictionRunsMillis,
-            int numTestsPerEvictionRun, long minEvictableIdleTimeMillis,
-            boolean testWhileIdle, long softMinEvictableIdleTimeMillis,
-            boolean lifo) {
-        _maxIdle = maxIdle;
-        _minIdle = minIdle;
-        _maxActive = maxActive;
-        _maxWait = maxWait;
-        _whenExhaustedAction = whenExhaustedAction;
-        _testOnBorrow = testOnBorrow;
-        _testOnReturn = testOnReturn;
-        _testWhileIdle = testWhileIdle;
-        _timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
-        _numTestsPerEvictionRun = numTestsPerEvictionRun;
-        _minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
-        _softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis;
-        _lifo = lifo;
-        _factory = factory;
-    }
-
-    /**
-     * {@inheritDoc}
+     * @return A pool configured with the current property settings
      */
     public ObjectPool<T> createPool() {
-        return new GenericObjectPool<T>(_factory, _maxActive,
-                _whenExhaustedAction, _maxWait, _maxIdle, _minIdle,
-                _testOnBorrow, _testOnReturn, _timeBetweenEvictionRunsMillis,
-                _numTestsPerEvictionRun, _minEvictableIdleTimeMillis,
-                _testWhileIdle, _softMinEvictableIdleTimeMillis, _lifo);
-    }
-
-    /**
-     * @return the {@link GenericObjectPool#getMaxIdle() maxIdle} setting for
-     *         pools created by this factory.
-     * @since 1.5.5
-     */
-    public int getMaxIdle() {
-        return _maxIdle;
-    }
-
-    /**
-     * @return the {@link GenericObjectPool#getMinIdle() minIdle} setting for
-     *         pools created by this factory.
-     * @since 1.5.5
-     */
-    public int getMinIdle() {
-        return _minIdle;
+        return new GenericObjectPool<T>(config);
     }
-
-    /**
-     * @return the {@link GenericObjectPool#getMaxActive() maxActive} setting
-     *         for pools created by this factory.
-     * @since 1.5.5
-     */
-    public int getMaxActive() {
-        return _maxActive;
-    }
-
-    /**
-     * @return the {@link GenericObjectPool#getMaxWait() maxWait} setting for
-     *         pools created by this factory.
-     * @since 1.5.5
-     */
-    public long getMaxWait() {
-        return _maxWait;
-    }
-
-    /**
-     * @return the {@link GenericObjectPool#getWhenExhaustedAction()
-     *         whenExhaustedAction} setting for pools created by this factory.
-     * @since 1.5.5
-     */
-    public WhenExhaustedAction getWhenExhaustedAction() {
-        return _whenExhaustedAction;
-    }
-
-    /**
-     * @return the {@link GenericObjectPool#getTestOnBorrow() testOnBorrow}
-     *         setting for pools created by this factory.
-     * @since 1.5.5
-     */
-    public boolean getTestOnBorrow() {
-        return _testOnBorrow;
-    }
-
-    /**
-     * @return the {@link GenericObjectPool#getTestOnReturn() testOnReturn}
-     *         setting for pools created by this factory.
-     * @since 1.5.5
-     */
-    public boolean getTestOnReturn() {
-        return _testOnReturn;
-    }
-
-    /**
-     * @return the {@link GenericObjectPool#getTestWhileIdle() testWhileIdle}
-     *         setting for pools created by this factory.
-     * @since 1.5.5
-     */
-    public boolean getTestWhileIdle() {
-        return _testWhileIdle;
-    }
-
-    /**
-     * @return the {@link GenericObjectPool#getTimeBetweenEvictionRunsMillis()
-     *         timeBetweenEvictionRunsMillis} setting for pools created by this
-     *         factory.
-     * @since 1.5.5
-     */
-    public long getTimeBetweenEvictionRunsMillis() {
-        return _timeBetweenEvictionRunsMillis;
-    }
-
-    /**
-     * @return the {@link GenericObjectPool#getNumTestsPerEvictionRun()
-     *         numTestsPerEvictionRun} setting for pools created by this
-     *         factory.
-     * @since 1.5.5
-     */
-    public int getNumTestsPerEvictionRun() {
-        return _numTestsPerEvictionRun;
-    }
-
-    /**
-     * @return the {@link GenericObjectPool#getMinEvictableIdleTimeMillis()
-     *         minEvictableIdleTimeMillis} setting for pools created by this
-     *         factory.
-     * @since 1.5.5
-     */
-    public long getMinEvictableIdleTimeMillis() {
-        return _minEvictableIdleTimeMillis;
-    }
-
-    /**
-     * @return the {@link GenericObjectPool#getSoftMinEvictableIdleTimeMillis()
-     *         softMinEvicatableIdleTimeMillis} setting for pools created by
-     *         this factory.
-     * @since 1.5.5
-     */
-    public long getSoftMinEvictableIdleTimeMillis() {
-        return _softMinEvictableIdleTimeMillis;
-    }
-
-    /**
-     * @return the {@link GenericObjectPool#getLifo() lifo} setting for pools
-     *         created by this factory.
-     * @since 1.5.5
-     */
-    public boolean getLifo() {
-        return _lifo;
-    }
-
-    /**
-     * @return the {@link PoolableObjectFactory} used by pools created by this
-     *         factory
-     */
-    public PoolableObjectFactory<T> getFactory() {
-        return _factory;
-    }
-
-    /**
-     * The {@link GenericObjectPool#getMaxIdle() maxIdle} setting for pools
-     * created by this factory.
-     */
-    private int _maxIdle = GenericObjectPool.DEFAULT_MAX_IDLE;
-
-    /**
-     * The {@link GenericObjectPool#getMinIdle() minIdle} setting for pools
-     * created by this factory.
-     */
-    private int _minIdle = GenericObjectPool.DEFAULT_MIN_IDLE;
-
-    /**
-     * The {@link GenericObjectPool#getMaxActive() maxActive} setting for pools
-     * created by this factory.
-     */
-    private int _maxActive = GenericObjectPool.DEFAULT_MAX_ACTIVE;
-
-    /**
-     * The {@link GenericObjectPool#getMaxWait() maxWait} setting for pools
-     * created by this factory.
-     */
-    private long _maxWait = GenericObjectPool.DEFAULT_MAX_WAIT;
-
-    /**
-     * The {@link GenericObjectPool#getWhenExhaustedAction()
-     * whenExhaustedAction} setting for pools created by this factory.
-     */
-    private WhenExhaustedAction _whenExhaustedAction =
-        GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION;
-
-    /**
-     * The {@link GenericObjectPool#getTestOnBorrow() testOnBorrow} setting for
-     * pools created by this factory.
-     */
-    private boolean _testOnBorrow = GenericObjectPool.DEFAULT_TEST_ON_BORROW;
-
-    /**
-     * The {@link GenericObjectPool#getTestOnReturn() testOnReturn} setting for
-     * pools created by this factory.
-     */
-    private boolean _testOnReturn = GenericObjectPool.DEFAULT_TEST_ON_RETURN;
-
-    /**
-     * The {@link GenericObjectPool#getTestWhileIdle() testWhileIdle} setting
-     * for pools created by this factory.
-     */
-    private boolean _testWhileIdle = GenericObjectPool.DEFAULT_TEST_WHILE_IDLE;
-
-    /**
-     * The {@link GenericObjectPool#getTimeBetweenEvictionRunsMillis()
-     * timeBetweenEvictionRunsMillis} setting for pools created by this factory.
-     */
-    private long _timeBetweenEvictionRunsMillis =
-        GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS;
-
-    /**
-     * The {@link GenericObjectPool#getNumTestsPerEvictionRun()
-     * numTestsPerEvictionRun} setting for pools created by this factory.
-     */
-    private int _numTestsPerEvictionRun =
-        GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN;
-
-    /**
-     * The {@link GenericObjectPool#getMinEvictableIdleTimeMillis()
-     * minEvictableIdleTimeMillis} setting for pools created by this factory.
-     */
-    private long _minEvictableIdleTimeMillis =
-        GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
-
-    /**
-     * The {@link GenericObjectPool#getSoftMinEvictableIdleTimeMillis()
-     * softMinEvictableIdleTimeMillis} setting for pools created by this
-     * factory.
-     */
-    private long _softMinEvictableIdleTimeMillis =
-        GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
-
-    /**
-     * The {@link GenericObjectPool#getLifo() lifo} setting for pools created by
-     * this factory.
-     */
-    private boolean _lifo = GenericObjectPool.DEFAULT_LIFO;
-
-    /**
-     * The {@link PoolableObjectFactory} used by pools created by this factory.
-     */
-    private PoolableObjectFactory<T> _factory = null;
-
 }

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestPoolUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestPoolUtils.java?rev=1135192&r1=1135191&r2=1135192&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestPoolUtils.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestPoolUtils.java Mon Jun 13 17:37:02 2011
@@ -80,7 +80,8 @@ public class TestPoolUtils {
 
         // Test that the minIdle check doesn't add too many idle objects
         final PoolableObjectFactory<Object> pof = createProxy(PoolableObjectFactory.class, calledMethods);
-        final ObjectPool<Object> op = new GenericObjectPool(pof);
+        final ObjectPool<Object> op = new GenericObjectPool();
+        op.setFactory(pof);
         PoolUtils.checkMinIdle(op, 2, 100);
         Thread.sleep(400);
         assertEquals(2, op.getNumIdle());

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java?rev=1135192&r1=1135191&r2=1135192&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java Mon Jun 13 17:37:02 2011
@@ -47,7 +47,8 @@ public class TestGenericObjectPool exten
 
     @Override
     protected ObjectPool<Object> makeEmptyPool(int mincap) {
-       GenericObjectPool<Object> pool = new GenericObjectPool<Object>(new SimpleFactory());
+       GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
+       pool.setFactory(new SimpleFactory());
        pool.setMaxActive(mincap);
        pool.setMaxIdle(mincap);
        return pool;
@@ -55,7 +56,9 @@ public class TestGenericObjectPool exten
 
     @Override
     protected ObjectPool<Object> makeEmptyPool(final PoolableObjectFactory<Object> factory) {
-        return new GenericObjectPool<Object>(factory);
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
+        pool.setFactory(factory);
+        return pool;
     }
 
     @Override
@@ -65,7 +68,8 @@ public class TestGenericObjectPool exten
 
     @Before
     public void setUp() throws Exception {
-        pool = new GenericObjectPool<Object>(new SimpleFactory());
+        pool = new GenericObjectPool<Object>();
+        pool.setFactory(new SimpleFactory());
     }
 
     @After
@@ -166,7 +170,8 @@ public class TestGenericObjectPool exten
         SimpleFactory factory = new SimpleFactory();
         factory.setMakeLatency(300);
         factory.setMaxActive(2);
-        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
+        pool.setFactory(factory);
         pool.setMaxActive(2);
         pool.setMinIdle(1);
         pool.borrowObject(); // numActive = 1, numIdle = 0
@@ -195,7 +200,8 @@ public class TestGenericObjectPool exten
     public void checkEvict(boolean lifo) throws Exception {
         // yea this is hairy but it tests all the code paths in GOP.evict()
         final SimpleFactory factory = new SimpleFactory();
-        final GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
+        final GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
+        pool.setFactory(factory);
         pool.setSoftMinEvictableIdleTimeMillis(10);
         pool.setMinIdle(2);
         pool.setTestWhileIdle(true);
@@ -232,7 +238,8 @@ public class TestGenericObjectPool exten
     
     private void checkEvictionOrder(boolean lifo) throws Exception {
         SimpleFactory factory = new SimpleFactory();
-        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
+        pool.setFactory(factory);
         pool.setNumTestsPerEvictionRun(2);
         pool.setMinEvictableIdleTimeMillis(100);
         pool.setLifo(lifo);
@@ -250,7 +257,8 @@ public class TestGenericObjectPool exten
         
         // Two eviction runs in sequence
         factory = new SimpleFactory();
-        pool = new GenericObjectPool<Object>(factory);
+        pool = new GenericObjectPool<Object>();
+        pool.setFactory(factory);
         pool.setNumTestsPerEvictionRun(2);
         pool.setMinEvictableIdleTimeMillis(100);
         pool.setLifo(lifo);
@@ -275,7 +283,8 @@ public class TestGenericObjectPool exten
     
     private void checkEvictorVisiting(boolean lifo) throws Exception {
         VisitTrackerFactory<Object> factory = new VisitTrackerFactory<Object>();
-        GenericObjectPool<VisitTracker<Object>> pool = new GenericObjectPool<VisitTracker<Object>>(factory);
+        GenericObjectPool<VisitTracker<Object>> pool = new GenericObjectPool<VisitTracker<Object>>();
+        pool.setFactory(factory);
         pool.setNumTestsPerEvictionRun(2);
         pool.setMinEvictableIdleTimeMillis(-1);
         pool.setTestWhileIdle(true);
@@ -307,7 +316,8 @@ public class TestGenericObjectPool exten
         } 
 
         factory = new VisitTrackerFactory<Object>();
-        pool = new GenericObjectPool<VisitTracker<Object>>(factory);
+        pool = new GenericObjectPool<VisitTracker<Object>>();
+        pool.setFactory(factory);
         pool.setNumTestsPerEvictionRun(3);
         pool.setMinEvictableIdleTimeMillis(-1);
         pool.setTestWhileIdle(true);
@@ -351,7 +361,8 @@ public class TestGenericObjectPool exten
         for (int i = 0; i < 4; i++) {
             pool.setNumTestsPerEvictionRun(smallPrimes[i]);
             for (int j = 0; j < 5; j++) {
-                pool = new GenericObjectPool<VisitTracker<Object>>(factory);
+                pool = new GenericObjectPool<VisitTracker<Object>>();
+                pool.setFactory(factory);
                 pool.setNumTestsPerEvictionRun(3);
                 pool.setMinEvictableIdleTimeMillis(-1);
                 pool.setTestWhileIdle(true);
@@ -393,7 +404,8 @@ public class TestGenericObjectPool exten
     @Test
     public void testExceptionOnPassivateDuringReturn() throws Exception {
         SimpleFactory factory = new SimpleFactory();        
-        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
+        pool.setFactory(factory);
         Object obj = pool.borrowObject();
         factory.setThrowExceptionOnPassivate(true);
         pool.returnObject(obj);
@@ -405,7 +417,8 @@ public class TestGenericObjectPool exten
     public void testExceptionOnDestroyDuringBorrow() throws Exception {
         SimpleFactory factory = new SimpleFactory(); 
         factory.setThrowExceptionOnDestroy(true);
-        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
+        pool.setFactory(factory);
         pool.setTestOnBorrow(true);
         pool.borrowObject();
         factory.setValid(false); // Make validation fail on next borrow attempt
@@ -423,7 +436,8 @@ public class TestGenericObjectPool exten
     public void testExceptionOnDestroyDuringReturn() throws Exception {
         SimpleFactory factory = new SimpleFactory(); 
         factory.setThrowExceptionOnDestroy(true);
-        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
+        pool.setFactory(factory);
         pool.setTestOnReturn(true);
         Object obj1 = pool.borrowObject();
         pool.borrowObject();
@@ -436,7 +450,8 @@ public class TestGenericObjectPool exten
     @Test
     public void testExceptionOnActivateDuringBorrow() throws Exception {
         SimpleFactory factory = new SimpleFactory(); 
-        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
+        pool.setFactory(factory);
         Object obj1 = pool.borrowObject();
         Object obj2 = pool.borrowObject();
         pool.returnObject(obj1);
@@ -740,99 +755,10 @@ public class TestGenericObjectPool exten
             assertConfiguration(new GenericObjectPool.Config(),pool);
         }
         {
-            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(new SimpleFactory());
+            GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
+            pool.setFactory(new SimpleFactory());
             assertConfiguration(new GenericObjectPool.Config(),pool);
         }
-        {
-            GenericObjectPool.Config expected = new GenericObjectPool.Config();
-            expected.maxActive = 2;
-            expected.maxIdle = 3;
-            expected.maxWait = 5L;
-            expected.minEvictableIdleTimeMillis = 7L;
-            expected.numTestsPerEvictionRun = 9;
-            expected.testOnBorrow = true;
-            expected.testOnReturn = true;
-            expected.testWhileIdle = true;
-            expected.timeBetweenEvictionRunsMillis = 11L;
-            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
-            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected);
-            assertConfiguration(expected,pool);
-        }
-        {
-            GenericObjectPool.Config expected = new GenericObjectPool.Config();
-            expected.maxActive = 2;
-            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive);
-            assertConfiguration(expected,pool);
-        }
-        {
-            GenericObjectPool.Config expected = new GenericObjectPool.Config();
-            expected.maxActive = 2;
-            expected.maxWait = 5L;
-            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
-            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait);
-            assertConfiguration(expected,pool);
-        }
-        {
-            GenericObjectPool.Config expected = new GenericObjectPool.Config();
-            expected.maxActive = 2;
-            expected.maxWait = 5L;
-            expected.testOnBorrow = true;
-            expected.testOnReturn = true;
-            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
-            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait,expected.testOnBorrow,expected.testOnReturn);
-            assertConfiguration(expected,pool);
-        }
-        {
-            GenericObjectPool.Config expected = new GenericObjectPool.Config();
-            expected.maxActive = 2;
-            expected.maxIdle = 3;
-            expected.maxWait = 5L;
-            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
-            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait,expected.maxIdle);
-            assertConfiguration(expected,pool);
-        }
-        {
-            GenericObjectPool.Config expected = new GenericObjectPool.Config();
-            expected.maxActive = 2;
-            expected.maxIdle = 3;
-            expected.maxWait = 5L;
-            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
-            expected.testOnBorrow = true;
-            expected.testOnReturn = true;
-            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait,expected.maxIdle,expected.testOnBorrow,expected.testOnReturn);
-            assertConfiguration(expected,pool);
-        }
-        {
-            GenericObjectPool.Config expected = new GenericObjectPool.Config();
-            expected.maxActive = 2;
-            expected.maxIdle = 3;
-            expected.maxWait = 5L;
-            expected.minEvictableIdleTimeMillis = 7L;
-            expected.numTestsPerEvictionRun = 9;
-            expected.testOnBorrow = true;
-            expected.testOnReturn = true;
-            expected.testWhileIdle = true;
-            expected.timeBetweenEvictionRunsMillis = 11L;
-            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
-            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive, expected.whenExhaustedAction, expected.maxWait, expected.maxIdle, expected.testOnBorrow, expected.testOnReturn, expected.timeBetweenEvictionRunsMillis, expected.numTestsPerEvictionRun, expected.minEvictableIdleTimeMillis, expected.testWhileIdle);
-            assertConfiguration(expected,pool);
-        }
-        {
-            GenericObjectPool.Config expected = new GenericObjectPool.Config();
-            expected.maxActive = 2;
-            expected.maxIdle = 3;
-            expected.minIdle = 1;
-            expected.maxWait = 5L;
-            expected.minEvictableIdleTimeMillis = 7L;
-            expected.numTestsPerEvictionRun = 9;
-            expected.testOnBorrow = true;
-            expected.testOnReturn = true;
-            expected.testWhileIdle = true;
-            expected.timeBetweenEvictionRunsMillis = 11L;
-            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
-            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive, expected.whenExhaustedAction, expected.maxWait, expected.maxIdle, expected.minIdle, expected.testOnBorrow, expected.testOnReturn, expected.timeBetweenEvictionRunsMillis, expected.numTestsPerEvictionRun, expected.minEvictableIdleTimeMillis, expected.testWhileIdle);
-            assertConfiguration(expected,pool);
-        }
     }
 
     @Test
@@ -856,7 +782,8 @@ public class TestGenericObjectPool exten
 
     @Test
     public void testDebugInfo() throws Exception {
-        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(new SimpleFactory());
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
+        pool.setFactory(new SimpleFactory());
         pool.setMaxIdle(3);
         assertNotNull(pool.debugInfo());
         Object obj = pool.borrowObject();
@@ -996,7 +923,8 @@ public class TestGenericObjectPool exten
             }
         }
         
-        GenericObjectPool<TimeTest> pool = new GenericObjectPool<TimeTest>(new TimeTest());
+        GenericObjectPool<TimeTest> pool = new GenericObjectPool<TimeTest>();
+        pool.setFactory(new TimeTest());
         
         pool.setMaxIdle(5);
         pool.setMaxActive(5);
@@ -1155,7 +1083,8 @@ public class TestGenericObjectPool exten
         factory.setDestroyLatency(100);  // Destroy takes 100 ms
         factory.setMaxActive(maxActive); // (makes - destroys) bound
         factory.setValidationEnabled(true);
-        pool = new GenericObjectPool(factory);
+        pool = new GenericObjectPool<Object>();
+        pool.setFactory(factory);
         pool.setMaxActive(maxActive);
         pool.setMaxIdle(-1);
         pool.setTestOnReturn(true);
@@ -1710,7 +1639,8 @@ public class TestGenericObjectPool exten
         final long holdTime = 2 * maxWait; // how long to hold connection
         final int threads = 10; // number of threads to grab the object initially
         SimpleFactory factory = new SimpleFactory();
-        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
+        pool.setFactory(factory);
         pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK);
         pool.setMaxWait(maxWait);
         pool.setMaxActive(threads);
@@ -1763,7 +1693,8 @@ public class TestGenericObjectPool exten
     @Test
     public void testMakeConcurrentWithReturn() throws Exception {
         SimpleFactory factory = new SimpleFactory();
-        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory); 
+        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(); 
+        pool.setFactory(factory);
         pool.setTestOnBorrow(true);
         factory.setValid(true);
         // Borrow and return an instance, with a short wait

Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java?rev=1135192&r1=1135191&r2=1135192&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java Mon Jun 13 17:37:02 2011
@@ -19,8 +19,6 @@ package org.apache.commons.pool2.impl;
 
 import static junit.framework.Assert.*;
 
-import java.util.NoSuchElementException;
-
 import org.apache.commons.pool2.MethodCallPoolableObjectFactory;
 import org.apache.commons.pool2.ObjectPoolFactory;
 import org.apache.commons.pool2.PoolableObjectFactory;
@@ -38,32 +36,40 @@ import org.junit.Test;
 public class TestGenericObjectPoolFactory extends TestObjectPoolFactory {
 
     @Override
-    protected ObjectPoolFactory<Object> makeFactory(final PoolableObjectFactory<Object> objectFactory) throws UnsupportedOperationException {
-        return new GenericObjectPoolFactory<Object>(objectFactory);
+    protected ObjectPoolFactory<Object> makeFactory(
+            final PoolableObjectFactory<Object> objectFactory)
+            throws UnsupportedOperationException {
+        
+        GenericObjectPoolConfig<Object> config =
+            new GenericObjectPoolConfig<Object>();
+        config.setFactory(objectFactory);
+        return new GenericObjectPoolFactory<Object>(config);
     }
 
     @Test
     public void testConstructors() throws Exception {
-        GenericObjectPoolFactory<Object> factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory());
-        GenericObjectPool<Object> pool;
-        factory.createPool().close();
-
-        final GenericObjectPool.Config config = new GenericObjectPool.Config();
-        config.maxActive = 1;
-        config.maxIdle = 2;
-        config.maxWait = 3;
-        config.minIdle = 4;
-        config.minEvictableIdleTimeMillis = 5;
-        config.numTestsPerEvictionRun = 6;
-        config.softMinEvictableIdleTimeMillis = 7;
-        config.testOnBorrow = true;
-        config.testOnReturn = false;
-        config.testWhileIdle = true;
-        config.lifo = false;
-        config.timeBetweenEvictionRunsMillis = 8;
-        config.whenExhaustedAction = WhenExhaustedAction.FAIL;
-        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), config);
-        pool = (GenericObjectPool<Object>)factory.createPool();
+        final GenericObjectPoolConfig<Object> config =
+            new GenericObjectPoolConfig<Object>();
+        config.setMaxTotal(1);
+        config.setMaxIdle(2);
+        config.setMaxWait(3);
+        config.setMinIdle(4);
+        config.setMinEvictableIdleTimeMillis(5);
+        config.setNumTestsPerEvictionRun(6);
+        config.setSoftMinEvictableIdleTimeMillis(7);
+        config.setTestOnBorrow(true);
+        config.setTestOnReturn(false);
+        config.setTestWhileIdle(true);
+        config.setLifo(false);
+        config.setTimeBetweenEvictionRunsMillis(8);
+        config.setWhenExhaustedAction(WhenExhaustedAction.FAIL);
+        config.setFactory(new MethodCallPoolableObjectFactory());
+
+        GenericObjectPoolFactory<Object> factory =
+            new GenericObjectPoolFactory<Object>(config);
+        GenericObjectPool<Object> pool =
+            (GenericObjectPool<Object>) factory.createPool();
+
         assertEquals(1, pool.getMaxActive());
         assertEquals(2, pool.getMaxIdle());
         assertEquals(3, pool.getMaxWait());
@@ -79,115 +85,5 @@ public class TestGenericObjectPoolFactor
         assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
         pool.borrowObject();
         pool.close();
-
-
-        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1);
-        pool = (GenericObjectPool<Object>)factory.createPool();
-        assertEquals(1, pool.getMaxActive());
-        pool.borrowObject();
-        pool.close();
-
-
-        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.BLOCK, 125);
-        pool = (GenericObjectPool<Object>)factory.createPool();
-        assertEquals(1, pool.getMaxActive());
-        assertEquals(WhenExhaustedAction.BLOCK, pool.getWhenExhaustedAction());
-        assertEquals(125, pool.getMaxWait());
-        pool.borrowObject();
-        long startTime = System.currentTimeMillis();
-        try {
-            pool.borrowObject();
-            fail();
-        } catch (NoSuchElementException nsee) {
-            // expected
-        }
-        long delay = System.currentTimeMillis() - startTime;
-        assertTrue("delay: " + delay, delay > 100);
-        pool.close();
-
-
-        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, true, false);
-        pool = (GenericObjectPool<Object>)factory.createPool();
-        assertEquals(1, pool.getMaxActive());
-        assertEquals(2, pool.getMaxWait());
-        assertEquals(true, pool.getTestOnBorrow());
-        assertEquals(false, pool.getTestOnReturn());
-        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
-        pool.borrowObject();
-        pool.close();
-
-
-        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3);
-        pool = (GenericObjectPool<Object>)factory.createPool();
-        assertEquals(1, pool.getMaxActive());
-        assertEquals(2, pool.getMaxWait());
-        assertEquals(3, pool.getMaxIdle());
-        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
-        pool.borrowObject();
-        pool.close();
-
-
-        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3, true, false);
-        pool = (GenericObjectPool<Object>)factory.createPool();
-        assertEquals(1, pool.getMaxActive());
-        assertEquals(2, pool.getMaxWait());
-        assertEquals(3, pool.getMaxIdle());
-        assertEquals(true, pool.getTestOnBorrow());
-        assertEquals(false, pool.getTestOnReturn());
-        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
-        pool.borrowObject();
-        pool.close();
-
-
-        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3, true, false, 4, 5, 6, false);
-        pool = (GenericObjectPool<Object>)factory.createPool();
-        assertEquals(1, pool.getMaxActive());
-        assertEquals(2, pool.getMaxWait());
-        assertEquals(3, pool.getMaxIdle());
-        assertEquals(4, pool.getTimeBetweenEvictionRunsMillis());
-        assertEquals(5, pool.getNumTestsPerEvictionRun());
-        assertEquals(6, pool.getMinEvictableIdleTimeMillis());
-        assertEquals(true, pool.getTestOnBorrow());
-        assertEquals(false, pool.getTestOnReturn());
-        assertEquals(false, pool.getTestWhileIdle());
-        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
-        pool.borrowObject();
-        pool.close();
-
-
-        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3, 4, true, false, 5, 6, 7, true);
-        pool = (GenericObjectPool<Object>)factory.createPool();
-        assertEquals(1, pool.getMaxActive());
-        assertEquals(2, pool.getMaxWait());
-        assertEquals(3, pool.getMaxIdle());
-        assertEquals(4, pool.getMinIdle());
-        assertEquals(5, pool.getTimeBetweenEvictionRunsMillis());
-        assertEquals(6, pool.getNumTestsPerEvictionRun());
-        assertEquals(7, pool.getMinEvictableIdleTimeMillis());
-        assertEquals(true, pool.getTestOnBorrow());
-        assertEquals(false, pool.getTestOnReturn());
-        assertEquals(true, pool.getTestWhileIdle());
-        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
-        pool.borrowObject();
-        pool.close();
-
-
-        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3, 4, true, false, 5, 6, 7, true, 8, false);
-        pool = (GenericObjectPool<Object>)factory.createPool();
-        assertEquals(1, pool.getMaxActive());
-        assertEquals(2, pool.getMaxWait());
-        assertEquals(3, pool.getMaxIdle());
-        assertEquals(4, pool.getMinIdle());
-        assertEquals(5, pool.getTimeBetweenEvictionRunsMillis());
-        assertEquals(6, pool.getNumTestsPerEvictionRun());
-        assertEquals(7, pool.getMinEvictableIdleTimeMillis());
-        assertEquals(8, pool.getSoftMinEvictableIdleTimeMillis());
-        assertEquals(true, pool.getTestOnBorrow());
-        assertEquals(false, pool.getTestOnReturn());
-        assertEquals(true, pool.getTestWhileIdle());
-        assertEquals(false, pool.getLifo());
-        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
-        pool.borrowObject();
-        pool.close();
     }
 }



Re: svn commit: r1135192 [1/2] - in /commons/proper/pool/trunk/src: java/org/apache/commons/pool2/impl/ test/org/apache/commons/pool2/ test/org/apache/commons/pool2/impl/ test/org/apache/commons/pool2/performance/

Posted by Phil Steitz <ph...@gmail.com>.
On 6/13/11 10:37 AM, markt@apache.org wrote:
> Author: markt
> Date: Mon Jun 13 17:37:02 2011
> New Revision: 1135192
>
> URL: http://svn.apache.org/viewvc?rev=1135192&view=rev
> Log:
> Reduce the number of constructors for GenericObjectPool

Oh no!  No more counting parameters :-(  No more horizontal
scrolling :-(

Thanks, Mark!!

Phil
> Modified:
>     commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java
>     commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolConfig.java
>     commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java
>     commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolConfig.java
>     commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolFactory.java
>     commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestPoolUtils.java
>     commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java
>     commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java
>     commons/proper/pool/trunk/src/test/org/apache/commons/pool2/performance/PerformanceTest.java
>
> Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java
> URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java?rev=1135192&r1=1135191&r2=1135192&view=diff
> ==============================================================================
> --- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java (original)
> +++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/BaseObjectPoolConfig.java Mon Jun 13 17:37:02 2011
> @@ -20,7 +20,7 @@ package org.apache.commons.pool2.impl;
>   * Provides the common configuration attributes used by object pool
>   * configurations.
>   */
> -public abstract class BaseObjectPoolConfig {
> +public abstract class BaseObjectPoolConfig implements Cloneable {
>  
>      /**
>       * The default LIFO status. True means that borrowObject returns the most
>
> Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolConfig.java
> URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolConfig.java?rev=1135192&r1=1135191&r2=1135192&view=diff
> ==============================================================================
> --- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolConfig.java (original)
> +++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericKeyedObjectPoolConfig.java Mon Jun 13 17:37:02 2011
> @@ -24,8 +24,7 @@ import org.apache.commons.pool2.KeyedPoo
>   * 
>   * @since Pool 2.0
>   */
> -public class GenericKeyedObjectPoolConfig<K,T> extends BaseObjectPoolConfig
> -        implements Cloneable {
> +public class GenericKeyedObjectPoolConfig<K,T> extends BaseObjectPoolConfig {
>  
>      public static final int DEFAULT_MAX_TOTAL_PER_KEY = 8;
>  
>
> Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java
> URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java?rev=1135192&r1=1135191&r2=1135192&view=diff
> ==============================================================================
> --- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java (original)
> +++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java Mon Jun 13 17:37:02 2011
> @@ -291,475 +291,32 @@ public class GenericObjectPool<T> extend
>       * Create a new <tt>GenericObjectPool</tt> with default properties.
>       */
>      public GenericObjectPool() {
> -        this(null, DEFAULT_MAX_ACTIVE, DEFAULT_WHEN_EXHAUSTED_ACTION,
> -                DEFAULT_MAX_WAIT, DEFAULT_MAX_IDLE, DEFAULT_MIN_IDLE,
> -                DEFAULT_TEST_ON_BORROW, DEFAULT_TEST_ON_RETURN,
> -                DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
> -                DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
> -                DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
> -                DEFAULT_TEST_WHILE_IDLE);
> +        this(new GenericObjectPoolConfig<T>());
>      }
>  
> -    /**
> -     * Create a new <tt>GenericObjectPool</tt> using the specified factory.
> -     * 
> -     * @param factory
> -     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
> -     *            create, validate and destroy objects
> -     */
> -    public GenericObjectPool(PoolableObjectFactory<T> factory) {
> -        this(factory, DEFAULT_MAX_ACTIVE, DEFAULT_WHEN_EXHAUSTED_ACTION,
> -                DEFAULT_MAX_WAIT, DEFAULT_MAX_IDLE, DEFAULT_MIN_IDLE,
> -                DEFAULT_TEST_ON_BORROW, DEFAULT_TEST_ON_RETURN,
> -                DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
> -                DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
> -                DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
> -                DEFAULT_TEST_WHILE_IDLE);
> -    }
> -
> -    /**
> -     * Create a new <tt>GenericObjectPool</tt> using the specified values.
> -     * 
> -     * @param factory
> -     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
> -     *            create, validate and destroy objects
> -     * @param config
> -     *            a non-<tt>null</tt> {@link GenericObjectPool.Config}
> -     *            describing my configuration
> -     */
> -    public GenericObjectPool(PoolableObjectFactory<T> factory,
> -            GenericObjectPool.Config config) {
> -        this(factory, config.maxActive, config.whenExhaustedAction,
> -                config.maxWait, config.maxIdle, config.minIdle,
> -                config.testOnBorrow, config.testOnReturn,
> -                config.timeBetweenEvictionRunsMillis,
> -                config.numTestsPerEvictionRun,
> -                config.minEvictableIdleTimeMillis, config.testWhileIdle,
> -                config.softMinEvictableIdleTimeMillis, config.lifo);
> -    }
> -
> -    /**
> -     * Create a new <tt>GenericObjectPool</tt> using the specified values.
> -     * 
> -     * @param factory
> -     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
> -     *            create, validate and destroy objects
> -     * @param maxActive
> -     *            the maximum number of objects that can be borrowed from me at
> -     *            one time (see {@link #setMaxActive})
> -     */
> -    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive) {
> -        this(factory, maxActive, DEFAULT_WHEN_EXHAUSTED_ACTION,
> -                DEFAULT_MAX_WAIT, DEFAULT_MAX_IDLE, DEFAULT_MIN_IDLE,
> -                DEFAULT_TEST_ON_BORROW, DEFAULT_TEST_ON_RETURN,
> -                DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
> -                DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
> -                DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
> -                DEFAULT_TEST_WHILE_IDLE);
> -    }
> -
> -    /**
> -     * Create a new <tt>GenericObjectPool</tt> using the specified values.
> -     * 
> -     * @param factory
> -     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
> -     *            create, validate and destroy objects
> -     * @param maxActive
> -     *            the maximum number of objects that can be borrowed from me at
> -     *            one time (see {@link #setMaxActive})
> -     * @param whenExhaustedAction
> -     *            the action to take when the pool is exhausted (see
> -     *            {@link #getWhenExhaustedAction})
> -     * @param maxWait
> -     *            the maximum amount of time to wait for an idle object when the
> -     *            pool is exhausted an and <i>whenExhaustedAction</i> is
> -     *            {@link WhenExhaustedAction#BLOCK} (otherwise ignored) (see
> -     *            {@link #getMaxWait})
> -     */
> -    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive,
> -            WhenExhaustedAction whenExhaustedAction, long maxWait) {
> -        this(factory, maxActive, whenExhaustedAction, maxWait,
> -                DEFAULT_MAX_IDLE, DEFAULT_MIN_IDLE, DEFAULT_TEST_ON_BORROW,
> -                DEFAULT_TEST_ON_RETURN,
> -                DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
> -                DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
> -                DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
> -                DEFAULT_TEST_WHILE_IDLE);
> -    }
> -
> -    /**
> -     * Create a new <tt>GenericObjectPool</tt> using the specified values.
> -     * 
> -     * @param factory
> -     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
> -     *            create, validate and destroy objects
> -     * @param maxActive
> -     *            the maximum number of objects that can be borrowed at one time
> -     *            (see {@link #setMaxActive})
> -     * @param whenExhaustedAction
> -     *            the action to take when the pool is exhausted (see
> -     *            {@link #getWhenExhaustedAction})
> -     * @param maxWait
> -     *            the maximum amount of time to wait for an idle object when the
> -     *            pool is exhausted an and <i>whenExhaustedAction</i> is
> -     *            {@link WhenExhaustedAction#BLOCK} (otherwise ignored) (see
> -     *            {@link #getMaxWait})
> -     * @param testOnBorrow
> -     *            whether or not to validate objects before they are returned by
> -     *            the {@link #borrowObject} method (see {@link #getTestOnBorrow}
> -     *            )
> -     * @param testOnReturn
> -     *            whether or not to validate objects after they are returned to
> -     *            the {@link #returnObject} method (see {@link #getTestOnReturn}
> -     *            )
> -     */
> -    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive,
> -            WhenExhaustedAction whenExhaustedAction, long maxWait,
> -            boolean testOnBorrow, boolean testOnReturn) {
> -        this(factory, maxActive, whenExhaustedAction, maxWait,
> -                DEFAULT_MAX_IDLE, DEFAULT_MIN_IDLE, testOnBorrow, testOnReturn,
> -                DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
> -                DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
> -                DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
> -                DEFAULT_TEST_WHILE_IDLE);
> -    }
> -
> -    /**
> -     * Create a new <tt>GenericObjectPool</tt> using the specified values.
> -     * 
> -     * @param factory
> -     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
> -     *            create, validate and destroy objects
> -     * @param maxActive
> -     *            the maximum number of objects that can be borrowed at one time
> -     *            (see {@link #setMaxActive})
> -     * @param whenExhaustedAction
> -     *            the action to take when the pool is exhausted (see
> -     *            {@link #getWhenExhaustedAction})
> -     * @param maxWait
> -     *            the maximum amount of time to wait for an idle object when the
> -     *            pool is exhausted and <i>whenExhaustedAction</i> is
> -     *            {@link WhenExhaustedAction#BLOCK} (otherwise ignored) (see
> -     *            {@link #getMaxWait})
> -     * @param maxIdle
> -     *            the maximum number of idle objects in my pool (see
> -     *            {@link #getMaxIdle})
> -     */
> -    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive,
> -            WhenExhaustedAction whenExhaustedAction, long maxWait,
> -            int maxIdle) {
> -        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
> -                DEFAULT_MIN_IDLE, DEFAULT_TEST_ON_BORROW,
> -                DEFAULT_TEST_ON_RETURN,
> -                DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
> -                DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
> -                DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
> -                DEFAULT_TEST_WHILE_IDLE);
> -    }
> -
> -    /**
> -     * Create a new <tt>GenericObjectPool</tt> using the specified values.
> -     * 
> -     * @param factory
> -     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
> -     *            create, validate and destroy objects
> -     * @param maxActive
> -     *            the maximum number of objects that can be borrowed at one time
> -     *            (see {@link #setMaxActive})
> -     * @param whenExhaustedAction
> -     *            the action to take when the pool is exhausted (see
> -     *            {@link #getWhenExhaustedAction})
> -     * @param maxWait
> -     *            the maximum amount of time to wait for an idle object when the
> -     *            pool is exhausted and <i>whenExhaustedAction</i> is
> -     *            {@link WhenExhaustedAction#BLOCK} (otherwise ignored) (see
> -     *            {@link #getMaxWait})
> -     * @param maxIdle
> -     *            the maximum number of idle objects in my pool (see
> -     *            {@link #getMaxIdle})
> -     * @param testOnBorrow
> -     *            whether or not to validate objects before they are returned by
> -     *            the {@link #borrowObject} method (see {@link #getTestOnBorrow}
> -     *            )
> -     * @param testOnReturn
> -     *            whether or not to validate objects after they are returned to
> -     *            the {@link #returnObject} method (see {@link #getTestOnReturn}
> -     *            )
> -     */
> -    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive,
> -            WhenExhaustedAction whenExhaustedAction, long maxWait, int maxIdle,
> -            boolean testOnBorrow, boolean testOnReturn) {
> -        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
> -                DEFAULT_MIN_IDLE, testOnBorrow, testOnReturn,
> -                DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
> -                DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
> -                DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
> -                DEFAULT_TEST_WHILE_IDLE);
> -    }
> -
> -    /**
> -     * Create a new <tt>GenericObjectPool</tt> using the specified values.
> -     * 
> -     * @param factory
> -     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
> -     *            create, validate and destroy objects
> -     * @param maxActive
> -     *            the maximum number of objects that can be borrowed at one time
> -     *            (see {@link #setMaxActive})
> -     * @param whenExhaustedAction
> -     *            the action to take when the pool is exhausted (see
> -     *            {@link #setWhenExhaustedAction})
> -     * @param maxWait
> -     *            the maximum amount of time to wait for an idle object when the
> -     *            pool is exhausted and <i>whenExhaustedAction</i> is
> -     *            {@link WhenExhaustedAction#BLOCK} (otherwise ignored) (see
> -     *            {@link #setMaxWait})
> -     * @param maxIdle
> -     *            the maximum number of idle objects in my pool (see
> -     *            {@link #setMaxIdle})
> -     * @param testOnBorrow
> -     *            whether or not to validate objects before they are returned by
> -     *            the {@link #borrowObject} method (see {@link #setTestOnBorrow}
> -     *            )
> -     * @param testOnReturn
> -     *            whether or not to validate objects after they are returned to
> -     *            the {@link #returnObject} method (see {@link #setTestOnReturn}
> -     *            )
> -     * @param timeBetweenEvictionRunsMillis
> -     *            the amount of time (in milliseconds) to sleep between
> -     *            examining idle objects for eviction (see
> -     *            {@link #setTimeBetweenEvictionRunsMillis})
> -     * @param numTestsPerEvictionRun
> -     *            the number of idle objects to examine per run within the idle
> -     *            object eviction thread (if any) (see
> -     *            {@link #setNumTestsPerEvictionRun})
> -     * @param minEvictableIdleTimeMillis
> -     *            the minimum number of milliseconds an object can sit idle in
> -     *            the pool before it is eligible for eviction (see
> -     *            {@link #setMinEvictableIdleTimeMillis})
> -     * @param testWhileIdle
> -     *            whether or not to validate objects in the idle object eviction
> -     *            thread, if any (see {@link #setTestWhileIdle})
> -     */
> -    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive,
> -            WhenExhaustedAction whenExhaustedAction, long maxWait, int maxIdle,
> -            boolean testOnBorrow, boolean testOnReturn,
> -            long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun,
> -            long minEvictableIdleTimeMillis, boolean testWhileIdle) {
> -        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
> -                DEFAULT_MIN_IDLE, testOnBorrow, testOnReturn,
> -                timeBetweenEvictionRunsMillis, numTestsPerEvictionRun,
> -                minEvictableIdleTimeMillis, testWhileIdle);
> -    }
> -
> -    /**
> -     * Create a new <tt>GenericObjectPool</tt> using the specified values.
> -     * 
> -     * @param factory
> -     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
> -     *            create, validate and destroy objects
> -     * @param maxActive
> -     *            the maximum number of objects that can be borrowed at one time
> -     *            (see {@link #setMaxActive})
> -     * @param whenExhaustedAction
> -     *            the action to take when the pool is exhausted (see
> -     *            {@link #setWhenExhaustedAction})
> -     * @param maxWait
> -     *            the maximum amount of time to wait for an idle object when the
> -     *            pool is exhausted and <i>whenExhaustedAction</i> is
> -     *            {@link WhenExhaustedAction#BLOCK} (otherwise ignored) (see
> -     *            {@link #setMaxWait})
> -     * @param maxIdle
> -     *            the maximum number of idle objects in my pool (see
> -     *            {@link #setMaxIdle})
> -     * @param minIdle
> -     *            the minimum number of idle objects in my pool (see
> -     *            {@link #setMinIdle})
> -     * @param testOnBorrow
> -     *            whether or not to validate objects before they are returned by
> -     *            the {@link #borrowObject} method (see {@link #setTestOnBorrow}
> -     *            )
> -     * @param testOnReturn
> -     *            whether or not to validate objects after they are returned to
> -     *            the {@link #returnObject} method (see {@link #setTestOnReturn}
> -     *            )
> -     * @param timeBetweenEvictionRunsMillis
> -     *            the amount of time (in milliseconds) to sleep between
> -     *            examining idle objects for eviction (see
> -     *            {@link #setTimeBetweenEvictionRunsMillis})
> -     * @param numTestsPerEvictionRun
> -     *            the number of idle objects to examine per run within the idle
> -     *            object eviction thread (if any) (see
> -     *            {@link #setNumTestsPerEvictionRun})
> -     * @param minEvictableIdleTimeMillis
> -     *            the minimum number of milliseconds an object can sit idle in
> -     *            the pool before it is eligible for eviction (see
> -     *            {@link #setMinEvictableIdleTimeMillis})
> -     * @param testWhileIdle
> -     *            whether or not to validate objects in the idle object eviction
> -     *            thread, if any (see {@link #setTestWhileIdle})
> -     */
> -    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive,
> -            WhenExhaustedAction whenExhaustedAction, long maxWait, int maxIdle,
> -            int minIdle, boolean testOnBorrow, boolean testOnReturn,
> -            long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun,
> -            long minEvictableIdleTimeMillis, boolean testWhileIdle) {
> -        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
> -                minIdle, testOnBorrow, testOnReturn,
> -                timeBetweenEvictionRunsMillis, numTestsPerEvictionRun,
> -                minEvictableIdleTimeMillis, testWhileIdle,
> -                DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
> -    }
> -
> -    /**
> -     * Create a new <tt>GenericObjectPool</tt> using the specified values.
> -     * 
> -     * @param factory
> -     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
> -     *            create, validate and destroy objects
> -     * @param maxActive
> -     *            the maximum number of objects that can be borrowed at one time
> -     *            (see {@link #setMaxActive})
> -     * @param whenExhaustedAction
> -     *            the action to take when the pool is exhausted (see
> -     *            {@link #setWhenExhaustedAction})
> -     * @param maxWait
> -     *            the maximum amount of time to wait for an idle object when the
> -     *            pool is exhausted and <i>whenExhaustedAction</i> is
> -     *            {@link WhenExhaustedAction#BLOCK} (otherwise ignored) (see
> -     *            {@link #setMaxWait})
> -     * @param maxIdle
> -     *            the maximum number of idle objects in my pool (see
> -     *            {@link #setMaxIdle})
> -     * @param minIdle
> -     *            the minimum number of idle objects in my pool (see
> -     *            {@link #setMinIdle})
> -     * @param testOnBorrow
> -     *            whether or not to validate objects before they are returned by
> -     *            the {@link #borrowObject} method (see {@link #setTestOnBorrow}
> -     *            )
> -     * @param testOnReturn
> -     *            whether or not to validate objects after they are returned to
> -     *            the {@link #returnObject} method (see {@link #setTestOnReturn}
> -     *            )
> -     * @param timeBetweenEvictionRunsMillis
> -     *            the amount of time (in milliseconds) to sleep between
> -     *            examining idle objects for eviction (see
> -     *            {@link #setTimeBetweenEvictionRunsMillis})
> -     * @param numTestsPerEvictionRun
> -     *            the number of idle objects to examine per run within the idle
> -     *            object eviction thread (if any) (see
> -     *            {@link #setNumTestsPerEvictionRun})
> -     * @param minEvictableIdleTimeMillis
> -     *            the minimum number of milliseconds an object can sit idle in
> -     *            the pool before it is eligible for eviction (see
> -     *            {@link #setMinEvictableIdleTimeMillis})
> -     * @param testWhileIdle
> -     *            whether or not to validate objects in the idle object eviction
> -     *            thread, if any (see {@link #setTestWhileIdle})
> -     * @param softMinEvictableIdleTimeMillis
> -     *            the minimum number of milliseconds an object can sit idle in
> -     *            the pool before it is eligible for eviction with the extra
> -     *            condition that at least "minIdle" amount of object remain in
> -     *            the pool. (see {@link #setSoftMinEvictableIdleTimeMillis})
> -     * @since Pool 1.3
> -     */
> -    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive,
> -            WhenExhaustedAction whenExhaustedAction, long maxWait, int maxIdle,
> -            int minIdle, boolean testOnBorrow, boolean testOnReturn,
> -            long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun,
> -            long minEvictableIdleTimeMillis, boolean testWhileIdle,
> -            long softMinEvictableIdleTimeMillis) {
> -        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
> -                minIdle, testOnBorrow, testOnReturn,
> -                timeBetweenEvictionRunsMillis, numTestsPerEvictionRun,
> -                minEvictableIdleTimeMillis, testWhileIdle,
> -                softMinEvictableIdleTimeMillis, DEFAULT_LIFO);
> -    }
> -
> -    /**
> -     * Create a new <tt>GenericObjectPool</tt> using the specified values.
> -     * 
> -     * @param factory
> -     *            the (possibly <tt>null</tt>)PoolableObjectFactory to use to
> -     *            create, validate and destroy objects
> -     * @param maxActive
> -     *            the maximum number of objects that can be borrowed at one time
> -     *            (see {@link #setMaxActive})
> -     * @param whenExhaustedAction
> -     *            the action to take when the pool is exhausted (see
> -     *            {@link #setWhenExhaustedAction})
> -     * @param maxWait
> -     *            the maximum amount of time to wait for an idle object when the
> -     *            pool is exhausted and <i>whenExhaustedAction</i> is
> -     *            {@link WhenExhaustedAction#BLOCK} (otherwise ignored) (see
> -     *            {@link #setMaxWait})
> -     * @param maxIdle
> -     *            the maximum number of idle objects in my pool (see
> -     *            {@link #setMaxIdle})
> -     * @param minIdle
> -     *            the minimum number of idle objects in my pool (see
> -     *            {@link #setMinIdle})
> -     * @param testOnBorrow
> -     *            whether or not to validate objects before they are returned by
> -     *            the {@link #borrowObject} method (see {@link #setTestOnBorrow}
> -     *            )
> -     * @param testOnReturn
> -     *            whether or not to validate objects after they are returned to
> -     *            the {@link #returnObject} method (see {@link #setTestOnReturn}
> -     *            )
> -     * @param timeBetweenEvictionRunsMillis
> -     *            the amount of time (in milliseconds) to sleep between
> -     *            examining idle objects for eviction (see
> -     *            {@link #setTimeBetweenEvictionRunsMillis})
> -     * @param numTestsPerEvictionRun
> -     *            the number of idle objects to examine per run within the idle
> -     *            object eviction thread (if any) (see
> -     *            {@link #setNumTestsPerEvictionRun})
> -     * @param minEvictableIdleTimeMillis
> -     *            the minimum number of milliseconds an object can sit idle in
> -     *            the pool before it is eligible for eviction (see
> -     *            {@link #setMinEvictableIdleTimeMillis})
> -     * @param testWhileIdle
> -     *            whether or not to validate objects in the idle object eviction
> -     *            thread, if any (see {@link #setTestWhileIdle})
> -     * @param softMinEvictableIdleTimeMillis
> -     *            the minimum number of milliseconds an object can sit idle in
> -     *            the pool before it is eligible for eviction with the extra
> -     *            condition that at least "minIdle" amount of object remain in
> -     *            the pool. (see {@link #setSoftMinEvictableIdleTimeMillis})
> -     * @param lifo
> -     *            whether or not objects are returned in last-in-first-out order
> -     *            from the idle object pool (see {@link #setLifo})
> -     * @since Pool 1.4
> -     */
> -    public GenericObjectPool(PoolableObjectFactory<T> factory, int maxActive,
> -            WhenExhaustedAction whenExhaustedAction, long maxWait, int maxIdle,
> -            int minIdle, boolean testOnBorrow, boolean testOnReturn,
> -            long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun,
> -            long minEvictableIdleTimeMillis, boolean testWhileIdle,
> -            long softMinEvictableIdleTimeMillis, boolean lifo) {
> -        _factory = factory;
> -        _maxActive = maxActive;
> -        _lifo = lifo;
> -        _whenExhaustedAction = whenExhaustedAction;
> -        _maxWait = maxWait;
> -        _maxIdle = maxIdle;
> -        _minIdle = minIdle;
> -        _testOnBorrow = testOnBorrow;
> -        _testOnReturn = testOnReturn;
> -        _timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
> -        _numTestsPerEvictionRun = numTestsPerEvictionRun;
> -        _minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
> -        _softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis;
> -        _testWhileIdle = testWhileIdle;
> -
> -        _idleObjects = new LinkedBlockingDeque<PooledObject<T>>();
> -        _allObjects = new ConcurrentHashMap<T, PooledObject<T>>();
> +    public GenericObjectPool(GenericObjectPoolConfig<T> config) {
> +        this._factory = config.getFactory();
> +        this._lifo = config.getLifo();
> +        this._maxActive = config.getMaxTotal();
> +        this._maxIdle = config.getMaxIdle();
> +        this._maxWait = config.getMaxWait();
> +        this._minEvictableIdleTimeMillis =
> +                config.getMinEvictableIdleTimeMillis();
> +        this._minIdle = config.getMinIdle();
> +        this._numTestsPerEvictionRun = config.getNumTestsPerEvictionRun();
> +        this._softMinEvictableIdleTimeMillis =
> +                config.getSoftMinEvictableIdleTimeMillis();
> +        this._testOnBorrow = config.getTestOnBorrow();
> +        this._testOnReturn = config.getTestOnReturn();
> +        this._testWhileIdle = config.getTestWhileIdle();
> +        this._timeBetweenEvictionRunsMillis =
> +                config.getTimeBetweenEvictionRunsMillis();
> +        this._whenExhaustedAction = config.getWhenExhaustedAction();
>  
>          startEvictor(_timeBetweenEvictionRunsMillis);
>      }
>  
> +
>      // --- public methods ---------------------------------------------
>  
>      // --- configuration methods --------------------------------------
> @@ -2011,7 +1568,8 @@ public class GenericObjectPool<T> extend
>       * {@link #_allObjects} will always be less than or equal to {@link
>       * #_maxActive}.
>       */
> -    private Map<T, PooledObject<T>> _allObjects = null;
> +    private final Map<T, PooledObject<T>> _allObjects =
> +        new ConcurrentHashMap<T, PooledObject<T>>();
>  
>      /**
>       * The combined count of the currently created objects and those in the
> @@ -2020,10 +1578,11 @@ public class GenericObjectPool<T> extend
>       * {@link #create(boolean)} will ensure that there are never more than
>       * {@link #_maxActive} objects created at any one time.
>       */
> -    private AtomicLong createCount = new AtomicLong(0);
> +    private final AtomicLong createCount = new AtomicLong(0);
>  
>      /** The queue of idle objects */
> -    private LinkedBlockingDeque<PooledObject<T>> _idleObjects = null;
> +    private final LinkedBlockingDeque<PooledObject<T>> _idleObjects =
> +        new LinkedBlockingDeque<PooledObject<T>>();
>  
>      /** An iterator for {@link #_idleObjects} that is used by the evictor. */
>      private Iterator<PooledObject<T>> _evictionIterator = null;
>
> Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolConfig.java
> URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolConfig.java?rev=1135192&r1=1135191&r2=1135192&view=diff
> ==============================================================================
> --- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolConfig.java (original)
> +++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolConfig.java Mon Jun 13 17:37:02 2011
> @@ -24,7 +24,7 @@ import org.apache.commons.pool2.Poolable
>   * 
>   * @since Pool 2.0
>   */
> -public class GenericObjectPoolConfig extends BaseObjectPoolConfig {
> +public class GenericObjectPoolConfig<T> extends BaseObjectPoolConfig {
>  
>      /**
>       * The default value for {@link #getSoftMinEvictableIdleTimeMillis}.
> @@ -37,20 +37,35 @@ public class GenericObjectPoolConfig ext
>       */
>      public static final int DEFAULT_MAX_TOTAL = 8;
>  
> +    /**
> +     * The default cap on the number of "sleeping" instances in the pool.
> +     */
> +    public static final int DEFAULT_MAX_IDLE = 8;
> +
> +    /**
> +     * The default minimum number of "sleeping" instances in the pool before
> +     * before the evictor thread (if active) spawns new objects.
> +     */
> +    public static final int DEFAULT_MIN_IDLE = 0;
>  
> -    private PoolableObjectFactory<?> factory = null;
> +    
> +    private PoolableObjectFactory<T> factory = null;
>  
>      private long softMinEvictableIdleTimeMillis =
>          DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
>  
>      private int maxTotal = DEFAULT_MAX_TOTAL;
>  
> +    private int maxIdle = DEFAULT_MAX_IDLE;
> +    
> +    private int minIdle = DEFAULT_MIN_IDLE;
>  
> -    public PoolableObjectFactory<?> getFactory() {
> +
> +    public PoolableObjectFactory<T> getFactory() {
>          return factory;
>      }
>  
> -    public void setFactory(PoolableObjectFactory<?> factory) {
> +    public void setFactory(PoolableObjectFactory<T> factory) {
>          this.factory = factory;
>      }
>  
> @@ -72,4 +87,32 @@ public class GenericObjectPoolConfig ext
>      public void setMaxTotal(int maxTotal) {
>          this.maxTotal = maxTotal;
>      }
> +
> +
> +    public int getMaxIdle() {
> +        return maxIdle;
> +    }
> +
> +    public void setMaxIdle(int maxIdle) {
> +        this.maxIdle = maxIdle;
> +    }
> +
> +        
> +    public int getMinIdle() {
> +        return minIdle;
> +    }
> +
> +    public void setMinIdle(int minIdle) {
> +        this.minIdle = minIdle;
> +    }
> +
> +    @SuppressWarnings("unchecked")
> +    @Override
> +    public GenericObjectPoolConfig<T> clone() {
> +        try {
> +            return (GenericObjectPoolConfig<T>) super.clone();
> +        } catch (CloneNotSupportedException e) {
> +            throw new AssertionError(); // Can't happen
> +        }
> +    }
>  }
>
> Modified: commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolFactory.java
> URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolFactory.java?rev=1135192&r1=1135191&r2=1135192&view=diff
> ==============================================================================
> --- commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolFactory.java (original)
> +++ commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPoolFactory.java Mon Jun 13 17:37:02 2011
> @@ -19,678 +19,62 @@ package org.apache.commons.pool2.impl;
>  
>  import org.apache.commons.pool2.ObjectPool;
>  import org.apache.commons.pool2.ObjectPoolFactory;
> -import org.apache.commons.pool2.PoolableObjectFactory;
>  
>  /**
> - * A factory for creating {@link GenericObjectPool} instances.
> - * 
> - * @see GenericObjectPool
> - * @see ObjectPoolFactory
> - * @param <T>
> - *            Type of element pooled in the built pool.
> - * @author Rodney Waldhoff
> - * @version $Revision$ $Date: 2011-05-11 14:56:24 +0100 (Wed, 11 May
> - *          2011) $
> + * A factory for creating {@link GenericObjectPool} instances from a provided
> + * {@link GenericObjectPoolConfig configuration}.
> + *
> + * @param <T> Type of element pooled in the built pool.
> + *
>   * @since Pool 1.0
>   */
> -public class GenericObjectPoolFactory<T> implements ObjectPoolFactory<T> {
> -    /**
> -     * Create a new GenericObjectPoolFactory.
> -     * 
> -     * @param factory
> -     *            the PoolableObjectFactory used by created pools.
> -     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory)
> -     */
> -    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory) {
> -        this(factory, GenericObjectPool.DEFAULT_MAX_ACTIVE,
> -                GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION,
> -                GenericObjectPool.DEFAULT_MAX_WAIT,
> -                GenericObjectPool.DEFAULT_MAX_IDLE,
> -                GenericObjectPool.DEFAULT_MIN_IDLE,
> -                GenericObjectPool.DEFAULT_TEST_ON_BORROW,
> -                GenericObjectPool.DEFAULT_TEST_ON_RETURN,
> -                GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
> -                GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
> -                GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
> -                GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
> -    }
>  
> -    /**
> -     * Create a new GenericObjectPoolFactory.
> -     * 
> -     * @param factory
> -     *            the PoolableObjectFactory used by created pools.
> -     * @param config
> -     *            a non-<code>null</code> GenericObjectPool.Config describing
> -     *            the configuration.
> -     * @throws NullPointerException
> -     *             when config is <code>null</code>.
> -     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory,
> -     *      GenericObjectPool.Config)
> -     */
> -    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
> -            GenericObjectPool.Config config) throws NullPointerException {
> -        this(factory, config.maxActive, config.whenExhaustedAction,
> -                config.maxWait, config.maxIdle, config.minIdle,
> -                config.testOnBorrow, config.testOnReturn,
> -                config.timeBetweenEvictionRunsMillis,
> -                config.numTestsPerEvictionRun,
> -                config.minEvictableIdleTimeMillis, config.testWhileIdle,
> -                config.softMinEvictableIdleTimeMillis, config.lifo);
> -    }
> -
> -    /**
> -     * Create a new GenericObjectPoolFactory.
> -     * 
> -     * @param factory
> -     *            the PoolableObjectFactory used by created pools.
> -     * @param maxActive
> -     *            maximum number of objects that can be borrowed from created
> -     *            pools at one time.
> -     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int)
> -     */
> -    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
> -            int maxActive) {
> -        this(factory, maxActive,
> -                GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION,
> -                GenericObjectPool.DEFAULT_MAX_WAIT,
> -                GenericObjectPool.DEFAULT_MAX_IDLE,
> -                GenericObjectPool.DEFAULT_MIN_IDLE,
> -                GenericObjectPool.DEFAULT_TEST_ON_BORROW,
> -                GenericObjectPool.DEFAULT_TEST_ON_RETURN,
> -                GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
> -                GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
> -                GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
> -                GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
> -    }
> -
> -    /**
> -     * Create a new GenericObjectPoolFactory.
> -     * 
> -     * @param factory
> -     *            the PoolableObjectFactory used by created pools.
> -     * @param maxActive
> -     *            maximum number of objects that can be borrowed from created
> -     *            pools at one time.
> -     * @param whenExhaustedAction
> -     *            the action to take when the pool is exhausted.
> -     * @param maxWait
> -     *            the maximum amount of time to wait for an idle object when the
> -     *            pool is exhausted.
> -     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int,
> -     *      byte, long)
> -     */
> -    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
> -            int maxActive, WhenExhaustedAction whenExhaustedAction,
> -            long maxWait) {
> -        this(factory, maxActive, whenExhaustedAction, maxWait,
> -                GenericObjectPool.DEFAULT_MAX_IDLE,
> -                GenericObjectPool.DEFAULT_MIN_IDLE,
> -                GenericObjectPool.DEFAULT_TEST_ON_BORROW,
> -                GenericObjectPool.DEFAULT_TEST_ON_RETURN,
> -                GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
> -                GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
> -                GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
> -                GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
> -    }
> +public class GenericObjectPoolFactory<T> implements ObjectPoolFactory<T> {
>  
> -    /**
> -     * Create a new GenericObjectPoolFactory.
> -     * 
> -     * @param factory
> -     *            the PoolableObjectFactory used by created pools.
> -     * @param maxActive
> -     *            maximum number of objects that can be borrowed from created
> -     *            pools at one time.
> -     * @param whenExhaustedAction
> -     *            the action to take when the pool is exhausted.
> -     * @param maxWait
> -     *            the maximum amount of time to wait for an idle object when the
> -     *            pool is exhausted.
> -     * @param testOnBorrow
> -     *            whether to validate objects before they are returned by the
> -     *            borrowObject.
> -     * @param testOnReturn
> -     *            whether to validate objects after they are returned to the
> -     *            returnObject.
> -     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int,
> -     *      byte, long, boolean, boolean)
> -     */
> -    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
> -            int maxActive, WhenExhaustedAction whenExhaustedAction,
> -            long maxWait, boolean testOnBorrow, boolean testOnReturn) {
> -        this(factory, maxActive, whenExhaustedAction, maxWait,
> -                GenericObjectPool.DEFAULT_MAX_IDLE,
> -                GenericObjectPool.DEFAULT_MIN_IDLE, testOnBorrow, testOnReturn,
> -                GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
> -                GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
> -                GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
> -                GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
> -    }
> +    private GenericObjectPoolConfig<T> config;
>  
> -    /**
> -     * Create a new GenericObjectPoolFactory.
> -     * 
> -     * @param factory
> -     *            the PoolableObjectFactory used by created pools.
> -     * @param maxActive
> -     *            maximum number of objects that can be borrowed from created
> -     *            pools at one time.
> -     * @param whenExhaustedAction
> -     *            the action to take when the pool is exhausted.
> -     * @param maxWait
> -     *            the maximum amount of time to wait for an idle object when the
> -     *            pool is exhausted.
> -     * @param maxIdle
> -     *            the maximum number of idle objects in my pool.
> -     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int,
> -     *      byte, long, int)
> -     */
> -    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
> -            int maxActive, WhenExhaustedAction whenExhaustedAction,
> -            long maxWait, int maxIdle) {
> -        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
> -                GenericObjectPool.DEFAULT_MIN_IDLE,
> -                GenericObjectPool.DEFAULT_TEST_ON_BORROW,
> -                GenericObjectPool.DEFAULT_TEST_ON_RETURN,
> -                GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
> -                GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
> -                GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
> -                GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
> -    }
>  
>      /**
>       * Create a new GenericObjectPoolFactory.
>       * 
> -     * @param factory
> -     *            the PoolableObjectFactory used by created pools.
> -     * @param maxActive
> -     *            maximum number of objects that can be borrowed from created
> -     *            pools at one time.
> -     * @param whenExhaustedAction
> -     *            the action to take when the pool is exhausted.
> -     * @param maxWait
> -     *            the maximum amount of time to wait for an idle object when the
> -     *            pool is exhausted.
> -     * @param maxIdle
> -     *            the maximum number of idle objects in my pool.
> -     * @param testOnBorrow
> -     *            whether to validate objects before they are returned by the
> -     *            borrowObject.
> -     * @param testOnReturn
> -     *            whether to validate objects after they are returned to the
> -     *            returnObject.
> -     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int,
> -     *      byte, long, int, boolean, boolean)
> +     * @param config    The configuration that will be used for all pools
> +     *                  created by this factory. Note that the configuration is
> +     *                  passed by value. Subsequent changes to config will not
> +     *                  be reflected in this factory or the pools it creates.
>       */
> -    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
> -            int maxActive, WhenExhaustedAction whenExhaustedAction,
> -            long maxWait, int maxIdle, boolean testOnBorrow,
> -            boolean testOnReturn) {
> -        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
> -                GenericObjectPool.DEFAULT_MIN_IDLE, testOnBorrow, testOnReturn,
> -                GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
> -                GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN,
> -                GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
> -                GenericObjectPool.DEFAULT_TEST_WHILE_IDLE);
> +    public GenericObjectPoolFactory(GenericObjectPoolConfig<T> config) {
> +        this.config = config.clone();
>      }
>  
> +    
>      /**
> -     * Create a new GenericObjectPoolFactory.
> -     * 
> -     * @param factory
> -     *            the PoolableObjectFactory used by created pools.
> -     * @param maxActive
> -     *            maximum number of objects that can be borrowed from created
> -     *            pools at one time.
> -     * @param whenExhaustedAction
> -     *            the action to take when the pool is exhausted.
> -     * @param maxWait
> -     *            the maximum amount of time to wait for an idle object when the
> -     *            pool is exhausted.
> -     * @param maxIdle
> -     *            the maximum number of idle objects in my pool.
> -     * @param testOnBorrow
> -     *            whether to validate objects before they are returned by the
> -     *            borrowObject.
> -     * @param testOnReturn
> -     *            whether to validate objects after they are returned to the
> -     *            returnObject.
> -     * @param timeBetweenEvictionRunsMillis
> -     *            the number of milliseconds to sleep between examining idle
> -     *            objects for eviction.
> -     * @param numTestsPerEvictionRun
> -     *            the number of idle objects to examine per run within the idle
> -     *            object eviction thread.
> -     * @param minEvictableIdleTimeMillis
> -     *            the minimum number of milliseconds an object can sit idle in
> -     *            the pool before it is eligible for eviction.
> -     * @param testWhileIdle
> -     *            whether or not to validate objects in the idle object eviction
> -     *            thread.
> -     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int,
> -     *      byte, long, int, boolean, boolean, long, int, long, boolean)
> +     * Obtain the configuration currently used by the factory allowing the
> +     * current settings to be viewed and changed.
> +     *  
> +     * @return  The config object currently used by the factory
>       */
> -    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
> -            int maxActive, WhenExhaustedAction whenExhaustedAction,
> -            long maxWait, int maxIdle, boolean testOnBorrow,
> -            boolean testOnReturn, long timeBetweenEvictionRunsMillis,
> -            int numTestsPerEvictionRun, long minEvictableIdleTimeMillis,
> -            boolean testWhileIdle) {
> -        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
> -                GenericObjectPool.DEFAULT_MIN_IDLE, testOnBorrow, testOnReturn,
> -                timeBetweenEvictionRunsMillis, numTestsPerEvictionRun,
> -                minEvictableIdleTimeMillis, testWhileIdle,
> -                GenericObjectPool.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
> +    public GenericObjectPoolConfig<T> getConfig() {
> +        return config;
>      }
>  
> -    /**
> -     * Create a new GenericObjectPoolFactory.
> -     * 
> -     * @param factory
> -     *            the PoolableObjectFactory used by created pools.
> -     * @param maxActive
> -     *            maximum number of objects that can be borrowed from created
> -     *            pools at one time.
> -     * @param whenExhaustedAction
> -     *            the action to take when the pool is exhausted.
> -     * @param maxWait
> -     *            the maximum amount of time to wait for an idle object when the
> -     *            pool is exhausted.
> -     * @param maxIdle
> -     *            the maximum number of idle objects in my pool.
> -     * @param minIdle
> -     *            the minimum number of idle objects in my pool.
> -     * @param testOnBorrow
> -     *            whether to validate objects before they are returned by the
> -     *            borrowObject.
> -     * @param testOnReturn
> -     *            whether to validate objects after they are returned to the
> -     *            returnObject.
> -     * @param timeBetweenEvictionRunsMillis
> -     *            the number of milliseconds to sleep between examining idle
> -     *            objects for eviction.
> -     * @param numTestsPerEvictionRun
> -     *            the number of idle objects to examine per run within the idle
> -     *            object eviction thread.
> -     * @param minEvictableIdleTimeMillis
> -     *            the minimum number of milliseconds an object can sit idle in
> -     *            the pool before it is eligible for eviction.
> -     * @param testWhileIdle
> -     *            whether or not to validate objects in the idle object eviction
> -     *            thread.
> -     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int,
> -     *      byte, long, int, int, boolean, boolean, long, int, long, boolean)
> -     */
> -    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
> -            int maxActive, WhenExhaustedAction whenExhaustedAction,
> -            long maxWait, int maxIdle, int minIdle, boolean testOnBorrow,
> -            boolean testOnReturn, long timeBetweenEvictionRunsMillis,
> -            int numTestsPerEvictionRun, long minEvictableIdleTimeMillis,
> -            boolean testWhileIdle) {
> -        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
> -                minIdle, testOnBorrow, testOnReturn,
> -                timeBetweenEvictionRunsMillis, numTestsPerEvictionRun,
> -                minEvictableIdleTimeMillis, testWhileIdle,
> -                GenericObjectPool.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
> -    }
>  
>      /**
> -     * Create a new GenericObjectPoolFactory.
> -     * 
> -     * @param factory
> -     *            the PoolableObjectFactory used by created pools.
> -     * @param maxActive
> -     *            maximum number of objects that can be borrowed from created
> -     *            pools at one time.
> -     * @param whenExhaustedAction
> -     *            the action to take when the pool is exhausted.
> -     * @param maxWait
> -     *            the maximum amount of time to wait for an idle object when the
> -     *            pool is exhausted.
> -     * @param maxIdle
> -     *            the maximum number of idle objects in my pool.
> -     * @param minIdle
> -     *            the minimum number of idle objects in my pool.
> -     * @param testOnBorrow
> -     *            whether to validate objects before they are returned by the
> -     *            borrowObject.
> -     * @param testOnReturn
> -     *            whether to validate objects after they are returned to the
> -     *            returnObject.
> -     * @param timeBetweenEvictionRunsMillis
> -     *            the number of milliseconds to sleep between examining idle
> -     *            objects for eviction.
> -     * @param numTestsPerEvictionRun
> -     *            the number of idle objects to examine per run within the idle
> -     *            object eviction thread.
> -     * @param minEvictableIdleTimeMillis
> -     *            the minimum number of milliseconds an object can sit idle in
> -     *            the pool before it is eligible for eviction.
> -     * @param testWhileIdle
> -     *            whether or not to validate objects in the idle object eviction
> -     *            thread.
> -     * @param softMinEvictableIdleTimeMillis
> -     *            the minimum number of milliseconds an object can sit idle in
> -     *            the pool before it is eligible for eviction with the extra
> -     *            condition that at least "minIdle" amount of object remain in
> -     *            the pool.
> -     * @since Pool 1.3
> -     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int,
> -     *      byte, long, int, int, boolean, boolean, long, int, long, boolean,
> -     *      long)
> +     * Replace the configuration settings used by this factory.
> +     *  
> +     * @param config    The new settings which will be passed by value
>       */
> -    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
> -            int maxActive, WhenExhaustedAction whenExhaustedAction,
> -            long maxWait, int maxIdle, int minIdle, boolean testOnBorrow,
> -            boolean testOnReturn, long timeBetweenEvictionRunsMillis,
> -            int numTestsPerEvictionRun, long minEvictableIdleTimeMillis,
> -            boolean testWhileIdle, long softMinEvictableIdleTimeMillis) {
> -        this(factory, maxActive, whenExhaustedAction, maxWait, maxIdle,
> -                minIdle, testOnBorrow, testOnReturn,
> -                timeBetweenEvictionRunsMillis, numTestsPerEvictionRun,
> -                minEvictableIdleTimeMillis, testWhileIdle,
> -                softMinEvictableIdleTimeMillis, GenericObjectPool.DEFAULT_LIFO);
> +    public void setConfig(GenericObjectPoolConfig<T> config) {
> +        this.config = config.clone();
>      }
>  
> +    
>      /**
> -     * Create a new GenericObjectPoolFactory.
> +     * Create a new GenericKeyedObjectPool with the currently configured
> +     * properties.
>       * 
> -     * @param factory
> -     *            the PoolableObjectFactory used by created pools.
> -     * @param maxActive
> -     *            maximum number of objects that can be borrowed from created
> -     *            pools at one time.
> -     * @param whenExhaustedAction
> -     *            the action to take when the pool is exhausted.
> -     * @param maxWait
> -     *            the maximum amount of time to wait for an idle object when the
> -     *            pool is exhausted.
> -     * @param maxIdle
> -     *            the maximum number of idle objects in my pool.
> -     * @param minIdle
> -     *            the minimum number of idle objects in my pool.
> -     * @param testOnBorrow
> -     *            whether to validate objects before they are returned by the
> -     *            borrowObject.
> -     * @param testOnReturn
> -     *            whether to validate objects after they are returned to the
> -     *            returnObject.
> -     * @param timeBetweenEvictionRunsMillis
> -     *            the number of milliseconds to sleep between examining idle
> -     *            objects for eviction.
> -     * @param numTestsPerEvictionRun
> -     *            the number of idle objects to examine per run within the idle
> -     *            object eviction thread.
> -     * @param minEvictableIdleTimeMillis
> -     *            the minimum number of milliseconds an object can sit idle in
> -     *            the pool before it is eligible for eviction.
> -     * @param testWhileIdle
> -     *            whether or not to validate objects in the idle object eviction
> -     *            thread.
> -     * @param softMinEvictableIdleTimeMillis
> -     *            the minimum number of milliseconds an object can sit idle in
> -     *            the pool before it is eligible for eviction with the extra
> -     *            condition that at least "minIdle" amount of object remain in
> -     *            the pool.
> -     * @param lifo
> -     *            whether or not objects are returned in last-in-first-out order
> -     *            from the idle object pool.
> -     * @since Pool 1.4
> -     * @see GenericObjectPool#GenericObjectPool(PoolableObjectFactory, int,
> -     *      byte, long, int, int, boolean, boolean, long, int, long, boolean,
> -     *      long, boolean)
> -     */
> -    public GenericObjectPoolFactory(PoolableObjectFactory<T> factory,
> -            int maxActive, WhenExhaustedAction whenExhaustedAction,
> -            long maxWait, int maxIdle, int minIdle, boolean testOnBorrow,
> -            boolean testOnReturn, long timeBetweenEvictionRunsMillis,
> -            int numTestsPerEvictionRun, long minEvictableIdleTimeMillis,
> -            boolean testWhileIdle, long softMinEvictableIdleTimeMillis,
> -            boolean lifo) {
> -        _maxIdle = maxIdle;
> -        _minIdle = minIdle;
> -        _maxActive = maxActive;
> -        _maxWait = maxWait;
> -        _whenExhaustedAction = whenExhaustedAction;
> -        _testOnBorrow = testOnBorrow;
> -        _testOnReturn = testOnReturn;
> -        _testWhileIdle = testWhileIdle;
> -        _timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
> -        _numTestsPerEvictionRun = numTestsPerEvictionRun;
> -        _minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
> -        _softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis;
> -        _lifo = lifo;
> -        _factory = factory;
> -    }
> -
> -    /**
> -     * {@inheritDoc}
> +     * @return A pool configured with the current property settings
>       */
>      public ObjectPool<T> createPool() {
> -        return new GenericObjectPool<T>(_factory, _maxActive,
> -                _whenExhaustedAction, _maxWait, _maxIdle, _minIdle,
> -                _testOnBorrow, _testOnReturn, _timeBetweenEvictionRunsMillis,
> -                _numTestsPerEvictionRun, _minEvictableIdleTimeMillis,
> -                _testWhileIdle, _softMinEvictableIdleTimeMillis, _lifo);
> -    }
> -
> -    /**
> -     * @return the {@link GenericObjectPool#getMaxIdle() maxIdle} setting for
> -     *         pools created by this factory.
> -     * @since 1.5.5
> -     */
> -    public int getMaxIdle() {
> -        return _maxIdle;
> -    }
> -
> -    /**
> -     * @return the {@link GenericObjectPool#getMinIdle() minIdle} setting for
> -     *         pools created by this factory.
> -     * @since 1.5.5
> -     */
> -    public int getMinIdle() {
> -        return _minIdle;
> +        return new GenericObjectPool<T>(config);
>      }
> -
> -    /**
> -     * @return the {@link GenericObjectPool#getMaxActive() maxActive} setting
> -     *         for pools created by this factory.
> -     * @since 1.5.5
> -     */
> -    public int getMaxActive() {
> -        return _maxActive;
> -    }
> -
> -    /**
> -     * @return the {@link GenericObjectPool#getMaxWait() maxWait} setting for
> -     *         pools created by this factory.
> -     * @since 1.5.5
> -     */
> -    public long getMaxWait() {
> -        return _maxWait;
> -    }
> -
> -    /**
> -     * @return the {@link GenericObjectPool#getWhenExhaustedAction()
> -     *         whenExhaustedAction} setting for pools created by this factory.
> -     * @since 1.5.5
> -     */
> -    public WhenExhaustedAction getWhenExhaustedAction() {
> -        return _whenExhaustedAction;
> -    }
> -
> -    /**
> -     * @return the {@link GenericObjectPool#getTestOnBorrow() testOnBorrow}
> -     *         setting for pools created by this factory.
> -     * @since 1.5.5
> -     */
> -    public boolean getTestOnBorrow() {
> -        return _testOnBorrow;
> -    }
> -
> -    /**
> -     * @return the {@link GenericObjectPool#getTestOnReturn() testOnReturn}
> -     *         setting for pools created by this factory.
> -     * @since 1.5.5
> -     */
> -    public boolean getTestOnReturn() {
> -        return _testOnReturn;
> -    }
> -
> -    /**
> -     * @return the {@link GenericObjectPool#getTestWhileIdle() testWhileIdle}
> -     *         setting for pools created by this factory.
> -     * @since 1.5.5
> -     */
> -    public boolean getTestWhileIdle() {
> -        return _testWhileIdle;
> -    }
> -
> -    /**
> -     * @return the {@link GenericObjectPool#getTimeBetweenEvictionRunsMillis()
> -     *         timeBetweenEvictionRunsMillis} setting for pools created by this
> -     *         factory.
> -     * @since 1.5.5
> -     */
> -    public long getTimeBetweenEvictionRunsMillis() {
> -        return _timeBetweenEvictionRunsMillis;
> -    }
> -
> -    /**
> -     * @return the {@link GenericObjectPool#getNumTestsPerEvictionRun()
> -     *         numTestsPerEvictionRun} setting for pools created by this
> -     *         factory.
> -     * @since 1.5.5
> -     */
> -    public int getNumTestsPerEvictionRun() {
> -        return _numTestsPerEvictionRun;
> -    }
> -
> -    /**
> -     * @return the {@link GenericObjectPool#getMinEvictableIdleTimeMillis()
> -     *         minEvictableIdleTimeMillis} setting for pools created by this
> -     *         factory.
> -     * @since 1.5.5
> -     */
> -    public long getMinEvictableIdleTimeMillis() {
> -        return _minEvictableIdleTimeMillis;
> -    }
> -
> -    /**
> -     * @return the {@link GenericObjectPool#getSoftMinEvictableIdleTimeMillis()
> -     *         softMinEvicatableIdleTimeMillis} setting for pools created by
> -     *         this factory.
> -     * @since 1.5.5
> -     */
> -    public long getSoftMinEvictableIdleTimeMillis() {
> -        return _softMinEvictableIdleTimeMillis;
> -    }
> -
> -    /**
> -     * @return the {@link GenericObjectPool#getLifo() lifo} setting for pools
> -     *         created by this factory.
> -     * @since 1.5.5
> -     */
> -    public boolean getLifo() {
> -        return _lifo;
> -    }
> -
> -    /**
> -     * @return the {@link PoolableObjectFactory} used by pools created by this
> -     *         factory
> -     */
> -    public PoolableObjectFactory<T> getFactory() {
> -        return _factory;
> -    }
> -
> -    /**
> -     * The {@link GenericObjectPool#getMaxIdle() maxIdle} setting for pools
> -     * created by this factory.
> -     */
> -    private int _maxIdle = GenericObjectPool.DEFAULT_MAX_IDLE;
> -
> -    /**
> -     * The {@link GenericObjectPool#getMinIdle() minIdle} setting for pools
> -     * created by this factory.
> -     */
> -    private int _minIdle = GenericObjectPool.DEFAULT_MIN_IDLE;
> -
> -    /**
> -     * The {@link GenericObjectPool#getMaxActive() maxActive} setting for pools
> -     * created by this factory.
> -     */
> -    private int _maxActive = GenericObjectPool.DEFAULT_MAX_ACTIVE;
> -
> -    /**
> -     * The {@link GenericObjectPool#getMaxWait() maxWait} setting for pools
> -     * created by this factory.
> -     */
> -    private long _maxWait = GenericObjectPool.DEFAULT_MAX_WAIT;
> -
> -    /**
> -     * The {@link GenericObjectPool#getWhenExhaustedAction()
> -     * whenExhaustedAction} setting for pools created by this factory.
> -     */
> -    private WhenExhaustedAction _whenExhaustedAction =
> -        GenericObjectPool.DEFAULT_WHEN_EXHAUSTED_ACTION;
> -
> -    /**
> -     * The {@link GenericObjectPool#getTestOnBorrow() testOnBorrow} setting for
> -     * pools created by this factory.
> -     */
> -    private boolean _testOnBorrow = GenericObjectPool.DEFAULT_TEST_ON_BORROW;
> -
> -    /**
> -     * The {@link GenericObjectPool#getTestOnReturn() testOnReturn} setting for
> -     * pools created by this factory.
> -     */
> -    private boolean _testOnReturn = GenericObjectPool.DEFAULT_TEST_ON_RETURN;
> -
> -    /**
> -     * The {@link GenericObjectPool#getTestWhileIdle() testWhileIdle} setting
> -     * for pools created by this factory.
> -     */
> -    private boolean _testWhileIdle = GenericObjectPool.DEFAULT_TEST_WHILE_IDLE;
> -
> -    /**
> -     * The {@link GenericObjectPool#getTimeBetweenEvictionRunsMillis()
> -     * timeBetweenEvictionRunsMillis} setting for pools created by this factory.
> -     */
> -    private long _timeBetweenEvictionRunsMillis =
> -        GenericObjectPool.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS;
> -
> -    /**
> -     * The {@link GenericObjectPool#getNumTestsPerEvictionRun()
> -     * numTestsPerEvictionRun} setting for pools created by this factory.
> -     */
> -    private int _numTestsPerEvictionRun =
> -        GenericObjectPool.DEFAULT_NUM_TESTS_PER_EVICTION_RUN;
> -
> -    /**
> -     * The {@link GenericObjectPool#getMinEvictableIdleTimeMillis()
> -     * minEvictableIdleTimeMillis} setting for pools created by this factory.
> -     */
> -    private long _minEvictableIdleTimeMillis =
> -        GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
> -
> -    /**
> -     * The {@link GenericObjectPool#getSoftMinEvictableIdleTimeMillis()
> -     * softMinEvictableIdleTimeMillis} setting for pools created by this
> -     * factory.
> -     */
> -    private long _softMinEvictableIdleTimeMillis =
> -        GenericObjectPool.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS;
> -
> -    /**
> -     * The {@link GenericObjectPool#getLifo() lifo} setting for pools created by
> -     * this factory.
> -     */
> -    private boolean _lifo = GenericObjectPool.DEFAULT_LIFO;
> -
> -    /**
> -     * The {@link PoolableObjectFactory} used by pools created by this factory.
> -     */
> -    private PoolableObjectFactory<T> _factory = null;
> -
>  }
>
> Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestPoolUtils.java
> URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestPoolUtils.java?rev=1135192&r1=1135191&r2=1135192&view=diff
> ==============================================================================
> --- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestPoolUtils.java (original)
> +++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/TestPoolUtils.java Mon Jun 13 17:37:02 2011
> @@ -80,7 +80,8 @@ public class TestPoolUtils {
>  
>          // Test that the minIdle check doesn't add too many idle objects
>          final PoolableObjectFactory<Object> pof = createProxy(PoolableObjectFactory.class, calledMethods);
> -        final ObjectPool<Object> op = new GenericObjectPool(pof);
> +        final ObjectPool<Object> op = new GenericObjectPool();
> +        op.setFactory(pof);
>          PoolUtils.checkMinIdle(op, 2, 100);
>          Thread.sleep(400);
>          assertEquals(2, op.getNumIdle());
>
> Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java
> URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java?rev=1135192&r1=1135191&r2=1135192&view=diff
> ==============================================================================
> --- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java (original)
> +++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPool.java Mon Jun 13 17:37:02 2011
> @@ -47,7 +47,8 @@ public class TestGenericObjectPool exten
>  
>      @Override
>      protected ObjectPool<Object> makeEmptyPool(int mincap) {
> -       GenericObjectPool<Object> pool = new GenericObjectPool<Object>(new SimpleFactory());
> +       GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
> +       pool.setFactory(new SimpleFactory());
>         pool.setMaxActive(mincap);
>         pool.setMaxIdle(mincap);
>         return pool;
> @@ -55,7 +56,9 @@ public class TestGenericObjectPool exten
>  
>      @Override
>      protected ObjectPool<Object> makeEmptyPool(final PoolableObjectFactory<Object> factory) {
> -        return new GenericObjectPool<Object>(factory);
> +        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
> +        pool.setFactory(factory);
> +        return pool;
>      }
>  
>      @Override
> @@ -65,7 +68,8 @@ public class TestGenericObjectPool exten
>  
>      @Before
>      public void setUp() throws Exception {
> -        pool = new GenericObjectPool<Object>(new SimpleFactory());
> +        pool = new GenericObjectPool<Object>();
> +        pool.setFactory(new SimpleFactory());
>      }
>  
>      @After
> @@ -166,7 +170,8 @@ public class TestGenericObjectPool exten
>          SimpleFactory factory = new SimpleFactory();
>          factory.setMakeLatency(300);
>          factory.setMaxActive(2);
> -        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
> +        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
> +        pool.setFactory(factory);
>          pool.setMaxActive(2);
>          pool.setMinIdle(1);
>          pool.borrowObject(); // numActive = 1, numIdle = 0
> @@ -195,7 +200,8 @@ public class TestGenericObjectPool exten
>      public void checkEvict(boolean lifo) throws Exception {
>          // yea this is hairy but it tests all the code paths in GOP.evict()
>          final SimpleFactory factory = new SimpleFactory();
> -        final GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
> +        final GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
> +        pool.setFactory(factory);
>          pool.setSoftMinEvictableIdleTimeMillis(10);
>          pool.setMinIdle(2);
>          pool.setTestWhileIdle(true);
> @@ -232,7 +238,8 @@ public class TestGenericObjectPool exten
>      
>      private void checkEvictionOrder(boolean lifo) throws Exception {
>          SimpleFactory factory = new SimpleFactory();
> -        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
> +        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
> +        pool.setFactory(factory);
>          pool.setNumTestsPerEvictionRun(2);
>          pool.setMinEvictableIdleTimeMillis(100);
>          pool.setLifo(lifo);
> @@ -250,7 +257,8 @@ public class TestGenericObjectPool exten
>          
>          // Two eviction runs in sequence
>          factory = new SimpleFactory();
> -        pool = new GenericObjectPool<Object>(factory);
> +        pool = new GenericObjectPool<Object>();
> +        pool.setFactory(factory);
>          pool.setNumTestsPerEvictionRun(2);
>          pool.setMinEvictableIdleTimeMillis(100);
>          pool.setLifo(lifo);
> @@ -275,7 +283,8 @@ public class TestGenericObjectPool exten
>      
>      private void checkEvictorVisiting(boolean lifo) throws Exception {
>          VisitTrackerFactory<Object> factory = new VisitTrackerFactory<Object>();
> -        GenericObjectPool<VisitTracker<Object>> pool = new GenericObjectPool<VisitTracker<Object>>(factory);
> +        GenericObjectPool<VisitTracker<Object>> pool = new GenericObjectPool<VisitTracker<Object>>();
> +        pool.setFactory(factory);
>          pool.setNumTestsPerEvictionRun(2);
>          pool.setMinEvictableIdleTimeMillis(-1);
>          pool.setTestWhileIdle(true);
> @@ -307,7 +316,8 @@ public class TestGenericObjectPool exten
>          } 
>  
>          factory = new VisitTrackerFactory<Object>();
> -        pool = new GenericObjectPool<VisitTracker<Object>>(factory);
> +        pool = new GenericObjectPool<VisitTracker<Object>>();
> +        pool.setFactory(factory);
>          pool.setNumTestsPerEvictionRun(3);
>          pool.setMinEvictableIdleTimeMillis(-1);
>          pool.setTestWhileIdle(true);
> @@ -351,7 +361,8 @@ public class TestGenericObjectPool exten
>          for (int i = 0; i < 4; i++) {
>              pool.setNumTestsPerEvictionRun(smallPrimes[i]);
>              for (int j = 0; j < 5; j++) {
> -                pool = new GenericObjectPool<VisitTracker<Object>>(factory);
> +                pool = new GenericObjectPool<VisitTracker<Object>>();
> +                pool.setFactory(factory);
>                  pool.setNumTestsPerEvictionRun(3);
>                  pool.setMinEvictableIdleTimeMillis(-1);
>                  pool.setTestWhileIdle(true);
> @@ -393,7 +404,8 @@ public class TestGenericObjectPool exten
>      @Test
>      public void testExceptionOnPassivateDuringReturn() throws Exception {
>          SimpleFactory factory = new SimpleFactory();        
> -        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
> +        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
> +        pool.setFactory(factory);
>          Object obj = pool.borrowObject();
>          factory.setThrowExceptionOnPassivate(true);
>          pool.returnObject(obj);
> @@ -405,7 +417,8 @@ public class TestGenericObjectPool exten
>      public void testExceptionOnDestroyDuringBorrow() throws Exception {
>          SimpleFactory factory = new SimpleFactory(); 
>          factory.setThrowExceptionOnDestroy(true);
> -        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
> +        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
> +        pool.setFactory(factory);
>          pool.setTestOnBorrow(true);
>          pool.borrowObject();
>          factory.setValid(false); // Make validation fail on next borrow attempt
> @@ -423,7 +436,8 @@ public class TestGenericObjectPool exten
>      public void testExceptionOnDestroyDuringReturn() throws Exception {
>          SimpleFactory factory = new SimpleFactory(); 
>          factory.setThrowExceptionOnDestroy(true);
> -        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
> +        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
> +        pool.setFactory(factory);
>          pool.setTestOnReturn(true);
>          Object obj1 = pool.borrowObject();
>          pool.borrowObject();
> @@ -436,7 +450,8 @@ public class TestGenericObjectPool exten
>      @Test
>      public void testExceptionOnActivateDuringBorrow() throws Exception {
>          SimpleFactory factory = new SimpleFactory(); 
> -        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
> +        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
> +        pool.setFactory(factory);
>          Object obj1 = pool.borrowObject();
>          Object obj2 = pool.borrowObject();
>          pool.returnObject(obj1);
> @@ -740,99 +755,10 @@ public class TestGenericObjectPool exten
>              assertConfiguration(new GenericObjectPool.Config(),pool);
>          }
>          {
> -            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(new SimpleFactory());
> +            GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
> +            pool.setFactory(new SimpleFactory());
>              assertConfiguration(new GenericObjectPool.Config(),pool);
>          }
> -        {
> -            GenericObjectPool.Config expected = new GenericObjectPool.Config();
> -            expected.maxActive = 2;
> -            expected.maxIdle = 3;
> -            expected.maxWait = 5L;
> -            expected.minEvictableIdleTimeMillis = 7L;
> -            expected.numTestsPerEvictionRun = 9;
> -            expected.testOnBorrow = true;
> -            expected.testOnReturn = true;
> -            expected.testWhileIdle = true;
> -            expected.timeBetweenEvictionRunsMillis = 11L;
> -            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
> -            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected);
> -            assertConfiguration(expected,pool);
> -        }
> -        {
> -            GenericObjectPool.Config expected = new GenericObjectPool.Config();
> -            expected.maxActive = 2;
> -            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive);
> -            assertConfiguration(expected,pool);
> -        }
> -        {
> -            GenericObjectPool.Config expected = new GenericObjectPool.Config();
> -            expected.maxActive = 2;
> -            expected.maxWait = 5L;
> -            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
> -            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait);
> -            assertConfiguration(expected,pool);
> -        }
> -        {
> -            GenericObjectPool.Config expected = new GenericObjectPool.Config();
> -            expected.maxActive = 2;
> -            expected.maxWait = 5L;
> -            expected.testOnBorrow = true;
> -            expected.testOnReturn = true;
> -            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
> -            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait,expected.testOnBorrow,expected.testOnReturn);
> -            assertConfiguration(expected,pool);
> -        }
> -        {
> -            GenericObjectPool.Config expected = new GenericObjectPool.Config();
> -            expected.maxActive = 2;
> -            expected.maxIdle = 3;
> -            expected.maxWait = 5L;
> -            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
> -            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait,expected.maxIdle);
> -            assertConfiguration(expected,pool);
> -        }
> -        {
> -            GenericObjectPool.Config expected = new GenericObjectPool.Config();
> -            expected.maxActive = 2;
> -            expected.maxIdle = 3;
> -            expected.maxWait = 5L;
> -            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
> -            expected.testOnBorrow = true;
> -            expected.testOnReturn = true;
> -            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive,expected.whenExhaustedAction,expected.maxWait,expected.maxIdle,expected.testOnBorrow,expected.testOnReturn);
> -            assertConfiguration(expected,pool);
> -        }
> -        {
> -            GenericObjectPool.Config expected = new GenericObjectPool.Config();
> -            expected.maxActive = 2;
> -            expected.maxIdle = 3;
> -            expected.maxWait = 5L;
> -            expected.minEvictableIdleTimeMillis = 7L;
> -            expected.numTestsPerEvictionRun = 9;
> -            expected.testOnBorrow = true;
> -            expected.testOnReturn = true;
> -            expected.testWhileIdle = true;
> -            expected.timeBetweenEvictionRunsMillis = 11L;
> -            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
> -            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive, expected.whenExhaustedAction, expected.maxWait, expected.maxIdle, expected.testOnBorrow, expected.testOnReturn, expected.timeBetweenEvictionRunsMillis, expected.numTestsPerEvictionRun, expected.minEvictableIdleTimeMillis, expected.testWhileIdle);
> -            assertConfiguration(expected,pool);
> -        }
> -        {
> -            GenericObjectPool.Config expected = new GenericObjectPool.Config();
> -            expected.maxActive = 2;
> -            expected.maxIdle = 3;
> -            expected.minIdle = 1;
> -            expected.maxWait = 5L;
> -            expected.minEvictableIdleTimeMillis = 7L;
> -            expected.numTestsPerEvictionRun = 9;
> -            expected.testOnBorrow = true;
> -            expected.testOnReturn = true;
> -            expected.testWhileIdle = true;
> -            expected.timeBetweenEvictionRunsMillis = 11L;
> -            expected.whenExhaustedAction = WhenExhaustedAction.FAIL;
> -            GenericObjectPool<Object> pool = new GenericObjectPool<Object>(null,expected.maxActive, expected.whenExhaustedAction, expected.maxWait, expected.maxIdle, expected.minIdle, expected.testOnBorrow, expected.testOnReturn, expected.timeBetweenEvictionRunsMillis, expected.numTestsPerEvictionRun, expected.minEvictableIdleTimeMillis, expected.testWhileIdle);
> -            assertConfiguration(expected,pool);
> -        }
>      }
>  
>      @Test
> @@ -856,7 +782,8 @@ public class TestGenericObjectPool exten
>  
>      @Test
>      public void testDebugInfo() throws Exception {
> -        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(new SimpleFactory());
> +        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
> +        pool.setFactory(new SimpleFactory());
>          pool.setMaxIdle(3);
>          assertNotNull(pool.debugInfo());
>          Object obj = pool.borrowObject();
> @@ -996,7 +923,8 @@ public class TestGenericObjectPool exten
>              }
>          }
>          
> -        GenericObjectPool<TimeTest> pool = new GenericObjectPool<TimeTest>(new TimeTest());
> +        GenericObjectPool<TimeTest> pool = new GenericObjectPool<TimeTest>();
> +        pool.setFactory(new TimeTest());
>          
>          pool.setMaxIdle(5);
>          pool.setMaxActive(5);
> @@ -1155,7 +1083,8 @@ public class TestGenericObjectPool exten
>          factory.setDestroyLatency(100);  // Destroy takes 100 ms
>          factory.setMaxActive(maxActive); // (makes - destroys) bound
>          factory.setValidationEnabled(true);
> -        pool = new GenericObjectPool(factory);
> +        pool = new GenericObjectPool<Object>();
> +        pool.setFactory(factory);
>          pool.setMaxActive(maxActive);
>          pool.setMaxIdle(-1);
>          pool.setTestOnReturn(true);
> @@ -1710,7 +1639,8 @@ public class TestGenericObjectPool exten
>          final long holdTime = 2 * maxWait; // how long to hold connection
>          final int threads = 10; // number of threads to grab the object initially
>          SimpleFactory factory = new SimpleFactory();
> -        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory);
> +        GenericObjectPool<Object> pool = new GenericObjectPool<Object>();
> +        pool.setFactory(factory);
>          pool.setWhenExhaustedAction(WhenExhaustedAction.BLOCK);
>          pool.setMaxWait(maxWait);
>          pool.setMaxActive(threads);
> @@ -1763,7 +1693,8 @@ public class TestGenericObjectPool exten
>      @Test
>      public void testMakeConcurrentWithReturn() throws Exception {
>          SimpleFactory factory = new SimpleFactory();
> -        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(factory); 
> +        GenericObjectPool<Object> pool = new GenericObjectPool<Object>(); 
> +        pool.setFactory(factory);
>          pool.setTestOnBorrow(true);
>          factory.setValid(true);
>          // Borrow and return an instance, with a short wait
>
> Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java
> URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java?rev=1135192&r1=1135191&r2=1135192&view=diff
> ==============================================================================
> --- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java (original)
> +++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/impl/TestGenericObjectPoolFactory.java Mon Jun 13 17:37:02 2011
> @@ -19,8 +19,6 @@ package org.apache.commons.pool2.impl;
>  
>  import static junit.framework.Assert.*;
>  
> -import java.util.NoSuchElementException;
> -
>  import org.apache.commons.pool2.MethodCallPoolableObjectFactory;
>  import org.apache.commons.pool2.ObjectPoolFactory;
>  import org.apache.commons.pool2.PoolableObjectFactory;
> @@ -38,32 +36,40 @@ import org.junit.Test;
>  public class TestGenericObjectPoolFactory extends TestObjectPoolFactory {
>  
>      @Override
> -    protected ObjectPoolFactory<Object> makeFactory(final PoolableObjectFactory<Object> objectFactory) throws UnsupportedOperationException {
> -        return new GenericObjectPoolFactory<Object>(objectFactory);
> +    protected ObjectPoolFactory<Object> makeFactory(
> +            final PoolableObjectFactory<Object> objectFactory)
> +            throws UnsupportedOperationException {
> +        
> +        GenericObjectPoolConfig<Object> config =
> +            new GenericObjectPoolConfig<Object>();
> +        config.setFactory(objectFactory);
> +        return new GenericObjectPoolFactory<Object>(config);
>      }
>  
>      @Test
>      public void testConstructors() throws Exception {
> -        GenericObjectPoolFactory<Object> factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory());
> -        GenericObjectPool<Object> pool;
> -        factory.createPool().close();
> -
> -        final GenericObjectPool.Config config = new GenericObjectPool.Config();
> -        config.maxActive = 1;
> -        config.maxIdle = 2;
> -        config.maxWait = 3;
> -        config.minIdle = 4;
> -        config.minEvictableIdleTimeMillis = 5;
> -        config.numTestsPerEvictionRun = 6;
> -        config.softMinEvictableIdleTimeMillis = 7;
> -        config.testOnBorrow = true;
> -        config.testOnReturn = false;
> -        config.testWhileIdle = true;
> -        config.lifo = false;
> -        config.timeBetweenEvictionRunsMillis = 8;
> -        config.whenExhaustedAction = WhenExhaustedAction.FAIL;
> -        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), config);
> -        pool = (GenericObjectPool<Object>)factory.createPool();
> +        final GenericObjectPoolConfig<Object> config =
> +            new GenericObjectPoolConfig<Object>();
> +        config.setMaxTotal(1);
> +        config.setMaxIdle(2);
> +        config.setMaxWait(3);
> +        config.setMinIdle(4);
> +        config.setMinEvictableIdleTimeMillis(5);
> +        config.setNumTestsPerEvictionRun(6);
> +        config.setSoftMinEvictableIdleTimeMillis(7);
> +        config.setTestOnBorrow(true);
> +        config.setTestOnReturn(false);
> +        config.setTestWhileIdle(true);
> +        config.setLifo(false);
> +        config.setTimeBetweenEvictionRunsMillis(8);
> +        config.setWhenExhaustedAction(WhenExhaustedAction.FAIL);
> +        config.setFactory(new MethodCallPoolableObjectFactory());
> +
> +        GenericObjectPoolFactory<Object> factory =
> +            new GenericObjectPoolFactory<Object>(config);
> +        GenericObjectPool<Object> pool =
> +            (GenericObjectPool<Object>) factory.createPool();
> +
>          assertEquals(1, pool.getMaxActive());
>          assertEquals(2, pool.getMaxIdle());
>          assertEquals(3, pool.getMaxWait());
> @@ -79,115 +85,5 @@ public class TestGenericObjectPoolFactor
>          assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
>          pool.borrowObject();
>          pool.close();
> -
> -
> -        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1);
> -        pool = (GenericObjectPool<Object>)factory.createPool();
> -        assertEquals(1, pool.getMaxActive());
> -        pool.borrowObject();
> -        pool.close();
> -
> -
> -        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.BLOCK, 125);
> -        pool = (GenericObjectPool<Object>)factory.createPool();
> -        assertEquals(1, pool.getMaxActive());
> -        assertEquals(WhenExhaustedAction.BLOCK, pool.getWhenExhaustedAction());
> -        assertEquals(125, pool.getMaxWait());
> -        pool.borrowObject();
> -        long startTime = System.currentTimeMillis();
> -        try {
> -            pool.borrowObject();
> -            fail();
> -        } catch (NoSuchElementException nsee) {
> -            // expected
> -        }
> -        long delay = System.currentTimeMillis() - startTime;
> -        assertTrue("delay: " + delay, delay > 100);
> -        pool.close();
> -
> -
> -        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, true, false);
> -        pool = (GenericObjectPool<Object>)factory.createPool();
> -        assertEquals(1, pool.getMaxActive());
> -        assertEquals(2, pool.getMaxWait());
> -        assertEquals(true, pool.getTestOnBorrow());
> -        assertEquals(false, pool.getTestOnReturn());
> -        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
> -        pool.borrowObject();
> -        pool.close();
> -
> -
> -        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3);
> -        pool = (GenericObjectPool<Object>)factory.createPool();
> -        assertEquals(1, pool.getMaxActive());
> -        assertEquals(2, pool.getMaxWait());
> -        assertEquals(3, pool.getMaxIdle());
> -        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
> -        pool.borrowObject();
> -        pool.close();
> -
> -
> -        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3, true, false);
> -        pool = (GenericObjectPool<Object>)factory.createPool();
> -        assertEquals(1, pool.getMaxActive());
> -        assertEquals(2, pool.getMaxWait());
> -        assertEquals(3, pool.getMaxIdle());
> -        assertEquals(true, pool.getTestOnBorrow());
> -        assertEquals(false, pool.getTestOnReturn());
> -        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
> -        pool.borrowObject();
> -        pool.close();
> -
> -
> -        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3, true, false, 4, 5, 6, false);
> -        pool = (GenericObjectPool<Object>)factory.createPool();
> -        assertEquals(1, pool.getMaxActive());
> -        assertEquals(2, pool.getMaxWait());
> -        assertEquals(3, pool.getMaxIdle());
> -        assertEquals(4, pool.getTimeBetweenEvictionRunsMillis());
> -        assertEquals(5, pool.getNumTestsPerEvictionRun());
> -        assertEquals(6, pool.getMinEvictableIdleTimeMillis());
> -        assertEquals(true, pool.getTestOnBorrow());
> -        assertEquals(false, pool.getTestOnReturn());
> -        assertEquals(false, pool.getTestWhileIdle());
> -        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
> -        pool.borrowObject();
> -        pool.close();
> -
> -
> -        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3, 4, true, false, 5, 6, 7, true);
> -        pool = (GenericObjectPool<Object>)factory.createPool();
> -        assertEquals(1, pool.getMaxActive());
> -        assertEquals(2, pool.getMaxWait());
> -        assertEquals(3, pool.getMaxIdle());
> -        assertEquals(4, pool.getMinIdle());
> -        assertEquals(5, pool.getTimeBetweenEvictionRunsMillis());
> -        assertEquals(6, pool.getNumTestsPerEvictionRun());
> -        assertEquals(7, pool.getMinEvictableIdleTimeMillis());
> -        assertEquals(true, pool.getTestOnBorrow());
> -        assertEquals(false, pool.getTestOnReturn());
> -        assertEquals(true, pool.getTestWhileIdle());
> -        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
> -        pool.borrowObject();
> -        pool.close();
> -
> -
> -        factory = new GenericObjectPoolFactory<Object>(new MethodCallPoolableObjectFactory(), 1, WhenExhaustedAction.FAIL, 2, 3, 4, true, false, 5, 6, 7, true, 8, false);
> -        pool = (GenericObjectPool<Object>)factory.createPool();
> -        assertEquals(1, pool.getMaxActive());
> -        assertEquals(2, pool.getMaxWait());
> -        assertEquals(3, pool.getMaxIdle());
> -        assertEquals(4, pool.getMinIdle());
> -        assertEquals(5, pool.getTimeBetweenEvictionRunsMillis());
> -        assertEquals(6, pool.getNumTestsPerEvictionRun());
> -        assertEquals(7, pool.getMinEvictableIdleTimeMillis());
> -        assertEquals(8, pool.getSoftMinEvictableIdleTimeMillis());
> -        assertEquals(true, pool.getTestOnBorrow());
> -        assertEquals(false, pool.getTestOnReturn());
> -        assertEquals(true, pool.getTestWhileIdle());
> -        assertEquals(false, pool.getLifo());
> -        assertEquals(WhenExhaustedAction.FAIL, pool.getWhenExhaustedAction());
> -        pool.borrowObject();
> -        pool.close();
>      }
>  }
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org