commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1214258 - /commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java
Date Wed, 14 Dec 2011 14:33:35 GMT
Author: sebb
Date: Wed Dec 14 14:33:35 2011
New Revision: 1214258

URL: http://svn.apache.org/viewvc?rev=1214258&view=rev
Log:
Convert to use pre-set config rather than creating pool and then configuring it
[which is how it's already done elsehere in DBCP2]

Modified:
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java?rev=1214258&r1=1214257&r2=1214258&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java
Wed Dec 14 14:33:35 2011
@@ -29,6 +29,7 @@ import javax.sql.ConnectionPoolDataSourc
 
 import org.apache.commons.pool2.KeyedObjectPool;
 import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
+import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
 import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
 
 /**
@@ -215,27 +216,28 @@ public class SharedPoolDataSource
         // Create an object pool to contain our PooledConnections
         factory = new KeyedCPDSConnectionFactory(cpds, getValidationQuery(),
                 isRollbackAfterValidation());
-        GenericKeyedObjectPool<UserPassKey,PooledConnectionAndInfo> tmpPool =
-            new GenericKeyedObjectPool<UserPassKey,PooledConnectionAndInfo>(factory);
-        factory.setPool(tmpPool);
-        tmpPool.setMaxTotalPerKey(getMaxTotal());
-        tmpPool.setMaxIdlePerKey(getMaxIdle());
-        tmpPool.setMaxWait(getMaxWait());
-        tmpPool.setBlockWhenExhausted(true);
+        GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig<UserPassKey,PooledConnectionAndInfo>();
+        config.setMaxTotalPerKey(getMaxTotal());
+        config.setMaxIdlePerKey(getMaxIdle());
+        config.setMaxWait(getMaxWait());
+        config.setBlockWhenExhausted(true);
         if (maxTotal <= 0) {
-            tmpPool.setBlockWhenExhausted(false);
-            tmpPool.setMaxTotalPerKey(Integer.MAX_VALUE);
+            config.setBlockWhenExhausted(false);
+            config.setMaxTotalPerKey(Integer.MAX_VALUE);
         }
         if (maxWait == 0) {
-            tmpPool.setBlockWhenExhausted(false);
+            config.setBlockWhenExhausted(false);
         }
-        tmpPool.setTestOnBorrow(getTestOnBorrow());
-        tmpPool.setTestOnReturn(getTestOnReturn());
-        tmpPool.setTimeBetweenEvictionRunsMillis(
+        config.setTestOnBorrow(getTestOnBorrow());
+        config.setTestOnReturn(getTestOnReturn());
+        config.setTimeBetweenEvictionRunsMillis(
             getTimeBetweenEvictionRunsMillis());
-        tmpPool.setNumTestsPerEvictionRun(getNumTestsPerEvictionRun());
-        tmpPool.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
-        tmpPool.setTestWhileIdle(getTestWhileIdle());
+        config.setNumTestsPerEvictionRun(getNumTestsPerEvictionRun());
+        config.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
+        config.setTestWhileIdle(getTestWhileIdle());
+        KeyedObjectPool<UserPassKey,PooledConnectionAndInfo> tmpPool =
+            new GenericKeyedObjectPool<UserPassKey,PooledConnectionAndInfo>(factory,
config);
+        factory.setPool(tmpPool);
         pool = tmpPool;
     }
 



Mime
View raw message