commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1143918 - in /commons/proper/dbcp/trunk/src: java/org/apache/commons/dbcp2/datasources/ test/org/apache/commons/dbcp2/datasources/
Date Thu, 07 Jul 2011 16:53:24 GMT
Author: markt
Date: Thu Jul  7 16:53:23 2011
New Revision: 1143918

URL: http://svn.apache.org/viewvc?rev=1143918&view=rev
Log:
More preparation for pool2 changes.

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

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java?rev=1143918&r1=1143917&r2=1143918&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java
Thu Jul  7 16:53:23 2011
@@ -50,7 +50,7 @@ class KeyedCPDSConnectionFactory
     private final ConnectionPoolDataSource _cpds;
     private final String _validationQuery;
     private final boolean _rollbackAfterValidation;
-    private final KeyedObjectPool _pool;
+    private KeyedObjectPool _pool;
     
     /** 
      * Map of PooledConnections for which close events are ignored.
@@ -66,38 +66,35 @@ class KeyedCPDSConnectionFactory
     /**
      * Create a new <tt>KeyedPoolableConnectionFactory</tt>.
      * @param cpds the ConnectionPoolDataSource from which to obtain PooledConnection's
-     * @param pool the {*link ObjectPool} in which to pool those {*link Connection}s
      * @param validationQuery a query to use to {*link #validateObject validate} {*link Connection}s.
      * Should return at least one row. May be <tt>null</tt>
      */
     public KeyedCPDSConnectionFactory(ConnectionPoolDataSource cpds,
-                                      KeyedObjectPool pool,
                                       String validationQuery) {
-        this(cpds , pool, validationQuery, false);  
+        this(cpds , validationQuery, false);  
     }
 
     /**
      * Create a new <tt>KeyedPoolableConnectionFactory</tt>.
      * @param cpds the ConnectionPoolDataSource from which to obtain
      * PooledConnections
-     * @param pool the {@link KeyedObjectPool} in which to pool those
-     * {@link Connection}s
      * @param validationQuery a query to use to {@link #validateObject validate}
      * {@link Connection}s.  Should return at least one row. May be <tt>null</tt>
      * @param rollbackAfterValidation whether a rollback should be issued after
      * {@link #validateObject validating} {@link Connection}s.
      */
     public KeyedCPDSConnectionFactory(ConnectionPoolDataSource cpds, 
-                                      KeyedObjectPool pool, 
                                       String validationQuery,
                                       boolean rollbackAfterValidation) {
         _cpds = cpds;
-        _pool = pool;
-        pool.setFactory(this);
         _validationQuery = validationQuery;
         _rollbackAfterValidation = rollbackAfterValidation;
     }
-    
+
+    public void setPool(KeyedObjectPool pool) {
+        this._pool = pool;
+    }
+
     /**
      * Returns the keyed object pool used to pool connections created by this factory.
      * 

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=1143918&r1=1143917&r2=1143918&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
Thu Jul  7 16:53:23 2011
@@ -234,12 +234,11 @@ public class SharedPoolDataSource
         tmpPool.setNumTestsPerEvictionRun(getNumTestsPerEvictionRun());
         tmpPool.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
         tmpPool.setTestWhileIdle(getTestWhileIdle());
-        pool = tmpPool;
-        // Set up the factory we will use (passing the pool associates
-        // the factory with the pool, so we do not have to do so
-        // explicitly)
-        factory = new KeyedCPDSConnectionFactory(cpds, pool, getValidationQuery(),
+        factory = new KeyedCPDSConnectionFactory(cpds, getValidationQuery(),
                                        isRollbackAfterValidation());
+        factory.setPool(tmpPool);
+        tmpPool.setFactory(factory);
+        pool = tmpPool;
     }
 
     @Override

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/datasources/TestKeyedCPDSConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/datasources/TestKeyedCPDSConnectionFactory.java?rev=1143918&r1=1143917&r2=1143918&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/datasources/TestKeyedCPDSConnectionFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/datasources/TestKeyedCPDSConnectionFactory.java
Thu Jul  7 16:53:23 2011
@@ -91,7 +91,9 @@ public class TestKeyedCPDSConnectionFact
         UserPassKey key = new UserPassKey("username", "password");
         GenericKeyedObjectPool pool = new GenericKeyedObjectPool();
         KeyedCPDSConnectionFactory factory = 
-            new KeyedCPDSConnectionFactory(cpds, pool, null, false);
+            new KeyedCPDSConnectionFactory(cpds, null, false);
+        factory.setPool(pool);
+        pool.setFactory(factory);
         
         // Checkout a pair of connections
         PooledConnection pcon1 = 



Mime
View raw message