commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1154033 - in /commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2: BasicDataSource.java datasources/PerUserPoolDataSourceFactory.java datasources/SharedPoolDataSource.java managed/PoolableManagedConnectionFactory.java
Date Thu, 04 Aug 2011 22:01:25 GMT
Author: markt
Date: Thu Aug  4 22:01:24 2011
New Revision: 1154033

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

Modified:
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSourceFactory.java
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java?rev=1154033&r1=1154032&r2=1154033&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java Thu Aug
 4 22:01:24 2011
@@ -1122,7 +1122,7 @@ public class BasicDataSource implements 
     /**
      * The object pool that internally manages our connections.
      */
-    protected volatile GenericObjectPool connectionPool = null;
+    protected volatile GenericObjectPool<Connection> connectionPool = null;
     
     /**
      * The connection properties that will be sent to our JDBC driver when

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSourceFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSourceFactory.java?rev=1154033&r1=1154032&r2=1154033&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSourceFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSourceFactory.java
Thu Aug  4 22:01:24 2011
@@ -39,6 +39,7 @@ public class PerUserPoolDataSourceFactor
         return PER_USER_POOL_CLASSNAME.equals(className);
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     protected InstanceKeyDataSource getNewInstance(Reference ref) 
         throws IOException, ClassNotFoundException {
@@ -64,38 +65,43 @@ public class PerUserPoolDataSourceFactor
         ra = ref.get("perUserDefaultAutoCommit");
         if (ra != null  && ra.getContent() != null) {
             byte[] serialized = (byte[]) ra.getContent();
-            pupds.perUserDefaultAutoCommit = (Map) deserialize(serialized);
+            pupds.perUserDefaultAutoCommit =
+                (Map<String,Boolean>) deserialize(serialized);
         }
 
         ra = ref.get("perUserDefaultTransactionIsolation");
         if (ra != null  && ra.getContent() != null) {
             byte[] serialized = (byte[]) ra.getContent();
             pupds.perUserDefaultTransactionIsolation = 
-                (Map) deserialize(serialized);
+                (Map<String,Integer>) deserialize(serialized);
         }
 
         ra = ref.get("perUserMaxTotal");
         if (ra != null  && ra.getContent() != null) {
             byte[] serialized = (byte[]) ra.getContent();
-            pupds.perUserMaxTotal = (Map) deserialize(serialized);
+            pupds.perUserMaxTotal =
+                (Map<String,Integer>) deserialize(serialized);
         }
         
         ra = ref.get("perUserMaxIdle");
         if (ra != null  && ra.getContent() != null) {
             byte[] serialized = (byte[]) ra.getContent();
-            pupds.perUserMaxIdle = (Map) deserialize(serialized);
+            pupds.perUserMaxIdle =
+                (Map<String,Integer>) deserialize(serialized);
         }
         
         ra = ref.get("perUserMaxWait");
         if (ra != null  && ra.getContent() != null) {
             byte[] serialized = (byte[]) ra.getContent();
-            pupds.perUserMaxWait = (Map) deserialize(serialized);
+            pupds.perUserMaxWait =
+                (Map<String,Integer>) deserialize(serialized);
         }
                 
         ra = ref.get("perUserDefaultReadOnly");
         if (ra != null  && ra.getContent() != null) {
             byte[] serialized = (byte[]) ra.getContent();
-            pupds.perUserDefaultReadOnly = (Map) deserialize(serialized);
+            pupds.perUserDefaultReadOnly =
+                (Map<String,Boolean>) deserialize(serialized);
         }
         return pupds;
     }            

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=1154033&r1=1154032&r2=1154033&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 Aug  4 22:01:24 2011
@@ -58,7 +58,7 @@ public class SharedPoolDataSource
     private int maxIdle = GenericObjectPoolConfig.DEFAULT_MAX_IDLE;
     private int maxWait = (int)Math.min(Integer.MAX_VALUE,
             GenericObjectPoolConfig.DEFAULT_MAX_WAIT);
-    private transient KeyedObjectPool pool = null;
+    private transient KeyedObjectPool<UserPassKey,PooledConnectionAndInfo> pool = null;
     private transient KeyedCPDSConnectionFactory factory = null;
 
     /**
@@ -180,7 +180,7 @@ public class SharedPoolDataSource
         UserPassKey key = new UserPassKey(username, password);
         
         try {
-            info = (PooledConnectionAndInfo) pool.borrowObject(key);
+            info = pool.borrowObject(key);
         }
         catch (Exception e) {
             throw new SQLException(
@@ -216,7 +216,8 @@ public class SharedPoolDataSource
         // Create an object pool to contain our PooledConnections
         factory = new KeyedCPDSConnectionFactory(cpds, getValidationQuery(),
                 isRollbackAfterValidation());
-        GenericKeyedObjectPool tmpPool = new GenericKeyedObjectPool(factory);
+        GenericKeyedObjectPool<UserPassKey,PooledConnectionAndInfo> tmpPool =
+            new GenericKeyedObjectPool<UserPassKey,PooledConnectionAndInfo>(factory);
         factory.setPool(tmpPool);
         tmpPool.setMaxTotalPerKey(getMaxTotal());
         tmpPool.setMaxIdlePerKey(getMaxIdle());

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java?rev=1154033&r1=1154032&r2=1154033&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java
Thu Aug  4 22:01:24 2011
@@ -18,6 +18,8 @@
 package org.apache.commons.dbcp2.managed;
 import java.sql.Connection;
 
+import org.apache.commons.dbcp2.DelegatingPreparedStatement;
+import org.apache.commons.dbcp2.PStmtKey;
 import org.apache.commons.dbcp2.PoolableConnection;
 import org.apache.commons.dbcp2.PoolableConnectionFactory;
 import org.apache.commons.dbcp2.PoolingConnection;
@@ -62,15 +64,16 @@ public class PoolableManagedConnectionFa
         initializeConnection(conn);
         if(poolStatements) {
             conn = new PoolingConnection(conn);
-            GenericKeyedObjectPoolConfig config =
-                new GenericKeyedObjectPoolConfig();
+            GenericKeyedObjectPoolConfig<PStmtKey,DelegatingPreparedStatement> config
=
+                new GenericKeyedObjectPoolConfig<PStmtKey,DelegatingPreparedStatement>();
             config.setMaxTotalPerKey(-1);
             config.setWhenExhaustedAction(WhenExhaustedAction.FAIL);
             config.setMaxWait(0);
             config.setMaxIdlePerKey(1);
             config.setMaxTotal(maxOpenPreparedStatements);
-            KeyedObjectPool stmtPool =
-                new GenericKeyedObjectPool((PoolingConnection)conn, config);
+            KeyedObjectPool<PStmtKey,DelegatingPreparedStatement> stmtPool =
+                new GenericKeyedObjectPool<PStmtKey,DelegatingPreparedStatement>(
+                        (PoolingConnection)conn, config);
             ((PoolingConnection)conn).setStatementPool(stmtPool);
             ((PoolingConnection) conn).setCacheState(_cacheState);
         }



Mime
View raw message