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 2013/07/24 22:06:43 UTC
svn commit: r1506687 [2/2] - in
/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2: ./
cpdsadapter/ datasources/ managed/
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=1506687&r1=1506686&r2=1506687&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 Wed Jul 24 20:06:42 2013
@@ -24,29 +24,31 @@ import org.apache.commons.dbcp2.Poolable
import org.apache.commons.dbcp2.PoolableConnectionFactory;
import org.apache.commons.dbcp2.PoolingConnection;
import org.apache.commons.pool2.KeyedObjectPool;
+import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
+import org.apache.commons.pool2.impl.PooledObjectImpl;
/**
* A {@link PoolableConnectionFactory} that creates {@link PoolableManagedConnection}s.
- *
+ *
* @version $Revision$ $Date$
*/
public class PoolableManagedConnectionFactory extends PoolableConnectionFactory {
/** Transaction registry associated with connections created by this factory */
private final TransactionRegistry transactionRegistry;
-
+
/**
* Create a PoolableManagedConnectionFactory and attach it to a connection pool.
- *
+ *
* @param connFactory XAConnectionFactory
*/
public PoolableManagedConnectionFactory(XAConnectionFactory connFactory) {
super(connFactory);
this.transactionRegistry = connFactory.getTransactionRegistry();
}
-
+
/**
* Uses the configured XAConnectionFactory to create a {@link PoolableManagedConnection}.
* Throws <code>IllegalStateException</code> if the connection factory returns null.
@@ -55,7 +57,7 @@ public class PoolableManagedConnectionFa
* if statement pooling is enabled.
*/
@Override
- synchronized public PoolableConnection makeObject() throws Exception {
+ synchronized public PooledObject<PoolableConnection> makeObject() throws Exception {
Connection conn = _connFactory.createConnection();
if (conn == null) {
throw new IllegalStateException("Connection factory returned null from createConnection");
@@ -70,12 +72,12 @@ public class PoolableManagedConnectionFa
config.setMaxIdlePerKey(1);
config.setMaxTotal(maxOpenPreparedStatements);
KeyedObjectPool<PStmtKey,DelegatingPreparedStatement> stmtPool =
- new GenericKeyedObjectPool<PStmtKey,DelegatingPreparedStatement>(
- (PoolingConnection)conn, config);
+ new GenericKeyedObjectPool<>((PoolingConnection)conn, config);
((PoolingConnection)conn).setStatementPool(stmtPool);
((PoolingConnection) conn).setCacheState(_cacheState);
}
- return new PoolableManagedConnection(transactionRegistry, conn, _pool);
+ return new PooledObjectImpl<PoolableConnection>(
+ new PoolableManagedConnection(transactionRegistry, conn, _pool));
}
}