Author: markt
Date: Thu Aug  4 12:49:45 2011
New Revision: 1153870

URL: http://svn.apache.org/viewvc?rev=1153870&view=rev
Log:
Generics

Modified:
    
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolablePreparedStatement.java
    
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java
    
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PoolablePreparedStatementStub.java
    
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java

Modified: 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolablePreparedStatement.java
URL: 
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolablePreparedStatement.java?rev=1153870&r1=1153869&r2=1153870&view=diff
==============================================================================
--- 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolablePreparedStatement.java
 (original)
+++ 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolablePreparedStatement.java
 Thu Aug  4 12:49:45 2011
@@ -38,16 +38,16 @@ import org.apache.commons.pool2.KeyedObj
  * @author Dirk Verbeeck
  * @version $Revision$ $Date$
  */
-public class PoolablePreparedStatement extends DelegatingPreparedStatement {
+public class PoolablePreparedStatement<K, S extends 
DelegatingPreparedStatement> extends DelegatingPreparedStatement {
     /**
      * The {@link KeyedObjectPool} from which I was obtained.
      */
-    protected KeyedObjectPool<PStmtKey, DelegatingPreparedStatement> _pool = 
null;
+    protected KeyedObjectPool<K, S> _pool = null;
 
     /**
      * My "key" as used by {@link KeyedObjectPool}.
      */
-    protected PStmtKey _key = null;
+    protected K _key = null;
 
     private volatile boolean batchAdded = false;
 
@@ -58,8 +58,8 @@ public class PoolablePreparedStatement e
      * @param pool the {@link KeyedObjectPool} from which I was obtained.
      * @param conn the {@link Connection} from which I was created
      */
-    public PoolablePreparedStatement(PreparedStatement stmt, PStmtKey key,
-            KeyedObjectPool<PStmtKey, DelegatingPreparedStatement> pool,
+    public PoolablePreparedStatement(PreparedStatement stmt, K key,
+            KeyedObjectPool<K, S> pool,
             Connection conn) {
         super((DelegatingConnection) conn, stmt);
         _pool = pool;
@@ -98,7 +98,7 @@ public class PoolablePreparedStatement e
         // calling close twice should have no effect
         if (!isClosed()) {
             try {
-                _pool.returnObject(_key,this);
+                _pool.returnObject(_key, (S) this);
             } catch(SQLException e) {
                 throw e;
             } catch(RuntimeException e) {

Modified: 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java
URL: 
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java?rev=1153870&r1=1153869&r2=1153870&view=diff
==============================================================================
--- 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java
 (original)
+++ 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java
 Thu Aug  4 12:49:45 2011
@@ -189,10 +189,10 @@ public class DriverAdapterCPDS
             
pci.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());
             return pci;
         }
-        KeyedObjectPool stmtPool = null;
+        KeyedObjectPool<PStmtKeyCPDS,PoolablePreparedStatementStub> stmtPool = 
null;
         if (isPoolPreparedStatements()) {
-            GenericKeyedObjectPoolConfig config =
-                new GenericKeyedObjectPoolConfig();
+            
GenericKeyedObjectPoolConfig<PStmtKeyCPDS,PoolablePreparedStatementStub> config 
=
+                new 
GenericKeyedObjectPoolConfig<PStmtKeyCPDS,PoolablePreparedStatementStub>();
             config.setMaxTotalPerKey(Integer.MAX_VALUE);
             config.setWhenExhaustedAction(WhenExhaustedAction.FAIL);
             config.setMaxWait(0);
@@ -215,7 +215,7 @@ public class DriverAdapterCPDS
                 config.setNumTestsPerEvictionRun(0);
                 config.setMinEvictableIdleTimeMillis(0);
             }
-            stmtPool = new GenericKeyedObjectPool(pci, config);
+            stmtPool = new 
GenericKeyedObjectPool<PStmtKeyCPDS,PoolablePreparedStatementStub>(pci, config);
             pci.setStatementPool(stmtPool);
         }
         return pci;

Modified: 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PoolablePreparedStatementStub.java
URL: 
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PoolablePreparedStatementStub.java?rev=1153870&r1=1153869&r2=1153870&view=diff
==============================================================================
--- 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PoolablePreparedStatementStub.java
 (original)
+++ 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PoolablePreparedStatementStub.java
 Thu Aug  4 12:49:45 2011
@@ -21,8 +21,6 @@ import java.sql.PreparedStatement;
 import java.sql.Connection;
 import java.sql.SQLException;
 import org.apache.commons.pool2.KeyedObjectPool;
-import org.apache.commons.dbcp2.DelegatingPreparedStatement;
-import org.apache.commons.dbcp2.PStmtKey;
 import org.apache.commons.dbcp2.PoolablePreparedStatement;
 
 /**
@@ -33,7 +31,7 @@ import org.apache.commons.dbcp2.Poolable
  * @author John D. McNally
  * @version $Revision$ $Date$
  */
-class PoolablePreparedStatementStub extends PoolablePreparedStatement {
+class PoolablePreparedStatementStub extends 
PoolablePreparedStatement<PStmtKeyCPDS,PoolablePreparedStatementStub> {
 
     /**
      * Constructor
@@ -43,8 +41,8 @@ class PoolablePreparedStatementStub exte
      * @param conn the {@link Connection} from which I was created
      */
     public PoolablePreparedStatementStub(PreparedStatement stmt,
-            PStmtKey key,
-            KeyedObjectPool<PStmtKey,DelegatingPreparedStatement> pool,
+            PStmtKeyCPDS key,
+            KeyedObjectPool<PStmtKeyCPDS,PoolablePreparedStatementStub> pool,
             Connection conn) {
         super(stmt, key, pool, conn);
     }

Modified: 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java
URL: 
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java?rev=1153870&r1=1153869&r2=1153870&view=diff
==============================================================================
--- 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java
 (original)
+++ 
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java
 Thu Aug  4 12:49:45 2011
@@ -30,8 +30,6 @@ import javax.sql.StatementEventListener;
 /* JDBC_4_ANT_KEY_END */
 
 import org.apache.commons.dbcp2.DelegatingConnection;
-import org.apache.commons.dbcp2.DelegatingPreparedStatement;
-import org.apache.commons.dbcp2.PStmtKey;
 import org.apache.commons.pool2.KeyedObjectPool;
 import org.apache.commons.pool2.KeyedPoolableObjectFactory;
 
@@ -81,7 +79,7 @@ class PooledConnectionImpl implements Po
 
     /** My pool of {*link PreparedStatement}s. */
     // TODO - make final?
-    protected KeyedObjectPool<PStmtKey,DelegatingPreparedStatement> pstmtPool 
= null;
+    protected KeyedObjectPool<PStmtKeyCPDS,PoolablePreparedStatementStub> 
pstmtPool = null;
 
     /** 
      * Controls access to the underlying connection 
@@ -105,7 +103,7 @@ class PooledConnectionImpl implements Po
     }
     
     public void setStatementPool(
-            KeyedObjectPool<PStmtKey,DelegatingPreparedStatement> 
statementPool) {
+            KeyedObjectPool<PStmtKeyCPDS,PoolablePreparedStatementStub> 
statementPool) {
         pstmtPool = statementPool;
     }
 


Reply via email to