Author: markt
Date: Thu Jul 7 16:36:58 2011
New Revision: 1143910
URL: http://svn.apache.org/viewvc?rev=1143910&view=rev
Log:
More preparation for pool2 changes.
Modified:
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.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/cpdsadapter/DriverAdapterCPDS.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java?rev=1143910&r1=1143909&r2=1143910&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 Jul 7 16:36:58 2011
@@ -34,7 +34,6 @@ import javax.naming.RefAddr;
import javax.naming.StringRefAddr;
import javax.naming.NamingException;
-import org.apache.commons.pool2.KeyedPoolableObjectFactory;
import org.apache.commons.pool2.KeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
@@ -160,18 +159,36 @@ public class DriverAdapterCPDS
* @param pass password to be used fur the connection
*/
@Override
- public PooledConnection getPooledConnection(String username,
- String pass)
+ public PooledConnection getPooledConnection(String username, String pass)
throws SQLException {
getConnectionCalled = true;
- /*
- public GenericKeyedObjectPool(KeyedPoolableObjectFactory factory,
- int maxActive, byte whenExhaustedAction, long maxWait,
- int maxIdle, boolean testOnBorrow, boolean testOnReturn,
- long timeBetweenEvictionRunsMillis,
- int numTestsPerEvictionRun, long minEvictableIdleTimeMillis,
- boolean testWhileIdle) {
- */
+ PooledConnectionImpl pci = null;
+ // Workaround for buggy WebLogic 5.1 classloader - ignore the
+ // exception upon first invocation.
+ try {
+ if (connectionProperties != null) {
+ connectionProperties.put("user", username);
+ connectionProperties.put("password", pass);
+ pci = new PooledConnectionImpl(DriverManager.getConnection(
+ getUrl(), connectionProperties));
+ } else {
+ pci = new PooledConnectionImpl(DriverManager.getConnection(
+ getUrl(), username, pass));
+ }
+
pci.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());
+ }
+ catch (ClassCircularityError e)
+ {
+ if (connectionProperties != null) {
+ pci = new PooledConnectionImpl(DriverManager.getConnection(
+ getUrl(), connectionProperties));
+ } else {
+ pci = new PooledConnectionImpl(DriverManager.getConnection(
+ getUrl(), username, pass));
+ }
+
pci.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());
+ return pci;
+ }
KeyedObjectPool stmtPool = null;
if (isPoolPreparedStatements()) {
GenericKeyedObjectPoolConfig config =
@@ -199,40 +216,10 @@ public class DriverAdapterCPDS
config.setMinEvictableIdleTimeMillis(0);
}
stmtPool = new GenericKeyedObjectPool(config);
+ stmtPool.setFactory(pci);
+ pci.setStatementPool(stmtPool);
}
- // Workaround for buggy WebLogic 5.1 classloader - ignore the
- // exception upon first invocation.
- try {
- PooledConnectionImpl pci = null;
- if (connectionProperties != null) {
- connectionProperties.put("user", username);
- connectionProperties.put("password", pass);
- pci = new PooledConnectionImpl(
- DriverManager.getConnection(getUrl(),
connectionProperties),
- stmtPool);
- } else {
- pci = new PooledConnectionImpl(
- DriverManager.getConnection(getUrl(), username, pass),
- stmtPool);
- }
-
pci.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());
- return pci;
- }
- catch (ClassCircularityError e)
- {
- PooledConnectionImpl pci = null;
- if (connectionProperties != null) {
- pci = new PooledConnectionImpl(
- DriverManager.getConnection(getUrl(),
connectionProperties),
- stmtPool);
- } else {
- pci = new PooledConnectionImpl(
- DriverManager.getConnection(getUrl(), username, pass),
- stmtPool);
- }
-
pci.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());
- return pci;
- }
+ return pci;
}
// ----------------------------------------------------------------------
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=1143910&r1=1143909&r2=1143910&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 Jul 7 16:36:58 2011
@@ -91,7 +91,7 @@ class PooledConnectionImpl
* @param connection the connection to be wrapped
* @param pool the pool to use
*/
- PooledConnectionImpl(Connection connection, KeyedObjectPool pool) {
+ PooledConnectionImpl(Connection connection) {
this.connection = connection;
if (connection instanceof DelegatingConnection) {
this.delegatingConnection = (DelegatingConnection) connection;
@@ -100,10 +100,10 @@ class PooledConnectionImpl
}
eventListeners = new Vector();
isClosed = false;
- if (pool != null) {
- pstmtPool = pool;
- pstmtPool.setFactory(this);
- }
+ }
+
+ public void setStatementPool(KeyedObjectPool statementPool) {
+ pstmtPool = statementPool;
}
/**