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/12/03 22:59:41 UTC
svn commit: r1547604 - in /commons/proper/dbcp/trunk/src:
java/org/apache/commons/dbcp2/ java/org/apache/commons/dbcp2/managed/
test/org/apache/commons/dbcp2/managed/
Author: markt
Date: Tue Dec 3 21:59:41 2013
New Revision: 1547604
URL: http://svn.apache.org/r1547604
Log:
More work to address generics warnings
Modified:
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/BasicDataSource.java
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/ManagedConnection.java
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/ManagedDataSource.java
commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSource.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=1547604&r1=1547603&r2=1547604&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 Tue Dec 3 21:59:41 2013
@@ -230,7 +230,7 @@ public class BasicDataSource implements
* The instance of the JDBC Driver to use.
*/
private Driver driver = null;
-
+
/**
* Returns the JDBC Driver that has been configured for use by this pool.
* <p>
@@ -238,13 +238,13 @@ public class BasicDataSource implements
* {@link #setDriver(Driver)}. It does not return any driver instance that
* may have been created from the value set via
* {@link #setDriverClassName(String)}.
- *
+ *
* @return the JDBC Driver that has been configured for use by this pool
*/
public synchronized Driver getDriver() {
return driver;
}
-
+
/**
* Sets the JDBC Driver instance to use for this pool.
* <p>
@@ -252,13 +252,13 @@ public class BasicDataSource implements
* initialized. The pool is initialized the first time one of the
* following methods is invoked: <code>getConnection, setLogwriter,
* setLoginTimeout, getLoginTimeout, getLogWriter.</code></p>
- *
+ *
* @param driver
*/
public synchronized void setDriver(Driver driver) {
this.driver = driver;
}
-
+
/**
* The fully qualified Java class name of the JDBC driver to be used.
*/
@@ -1201,7 +1201,7 @@ public class BasicDataSource implements
/**
* The object pool that internally manages our connections.
*/
- protected volatile GenericObjectPool<Connection> connectionPool = null;
+ protected volatile GenericObjectPool<PoolableConnection> connectionPool = null;
/**
* The connection properties that will be sent to our JDBC driver when
@@ -1518,7 +1518,7 @@ public class BasicDataSource implements
}
return null;
}
-
+
/**
* Sets the log writer to be used by this configuration to log
* information on abandoned objects.
@@ -1532,7 +1532,7 @@ public class BasicDataSource implements
abandonedConfig.setLogWriter(logWriter);
this.restartNeeded = true;
}
-
+
/**
* If the connection pool implements {@link UsageTracking}, should the
* connection pool record a stack trace every time a method is called on a
@@ -1547,7 +1547,7 @@ public class BasicDataSource implements
}
return false;
}
-
+
/**
* If the connection pool implements {@link UsageTracking}, configure
* whether the connection pool should record a stack trace every time a
@@ -1565,7 +1565,7 @@ public class BasicDataSource implements
abandonedConfig.setUseUsageTracking(usageTracking);
this.restartNeeded = true;
}
-
+
// --------------------------------------------------------- Public Methods
/**
@@ -1882,15 +1882,15 @@ public class BasicDataSource implements
*/
protected void createConnectionPool(PoolableConnectionFactory factory) {
// Create an object pool to contain our active connections
- GenericObjectPool gop;
+ GenericObjectPool<PoolableConnection> gop;
if (abandonedConfig != null &&
(abandonedConfig.getRemoveAbandonedOnBorrow() ||
abandonedConfig.getRemoveAbandonedOnMaintenance())) {
- gop = new GenericObjectPool(factory, new GenericObjectPoolConfig(),
+ gop = new GenericObjectPool<>(factory, new GenericObjectPoolConfig(),
abandonedConfig);
}
else {
- gop = new GenericObjectPool(factory);
+ gop = new GenericObjectPool<>(factory);
}
gop.setMaxTotal(maxTotal);
gop.setMaxIdle(maxIdle);
@@ -1939,7 +1939,7 @@ public class BasicDataSource implements
* @throws SQLException if unable to create a datasource instance
*/
protected void createDataSourceInstance() throws SQLException {
- PoolingDataSource pds = new PoolingDataSource(connectionPool);
+ PoolingDataSource<PoolableConnection> pds = new PoolingDataSource<>(connectionPool);
pds.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());
pds.setLogWriter(logWriter);
dataSource = pds;
Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/ManagedConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/ManagedConnection.java?rev=1547604&r1=1547603&r2=1547604&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/ManagedConnection.java (original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/ManagedConnection.java Tue Dec 3 21:59:41 2013
@@ -40,7 +40,7 @@ import java.sql.SQLException;
* @author Dain Sundstrom
* @version $Revision$
*/
-public class ManagedConnection extends DelegatingConnection {
+public class ManagedConnection<C extends Connection> extends DelegatingConnection {
private final ObjectPool<Connection> pool;
private final TransactionRegistry transactionRegistry;
private final boolean accessToUnderlyingConnectionAllowed;
Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/ManagedDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/ManagedDataSource.java?rev=1547604&r1=1547603&r2=1547604&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/ManagedDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/ManagedDataSource.java Tue Dec 3 21:59:41 2013
@@ -29,7 +29,7 @@ import java.sql.SQLException;
* @author Dain Sundstrom
* @version $Revision$
*/
-public class ManagedDataSource extends PoolingDataSource {
+public class ManagedDataSource<C extends Connection> extends PoolingDataSource<C> {
private TransactionRegistry transactionRegistry;
/**
@@ -51,7 +51,7 @@ public class ManagedDataSource extends P
* @param transactionRegistry the transaction registry obtained from the
* XAConnectionFactory used to create the connection pool object factory
*/
- public ManagedDataSource(ObjectPool<Connection> pool,
+ public ManagedDataSource(ObjectPool<C> pool,
TransactionRegistry transactionRegistry) {
super(pool);
this.transactionRegistry = transactionRegistry;
Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSource.java?rev=1547604&r1=1547603&r2=1547604&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/managed/TestManagedDataSource.java Tue Dec 3 21:59:41 2013
@@ -22,6 +22,7 @@ import junit.framework.TestSuite;
import org.apache.commons.dbcp2.ConnectionFactory;
import org.apache.commons.dbcp2.DelegatingConnection;
import org.apache.commons.dbcp2.DriverConnectionFactory;
+import org.apache.commons.dbcp2.PoolableConnection;
import org.apache.commons.dbcp2.PoolableConnectionFactory;
import org.apache.commons.dbcp2.PoolingDataSource;
import org.apache.commons.dbcp2.TestConnectionPool;
@@ -53,8 +54,8 @@ public class TestManagedDataSource exten
return ds.getConnection();
}
- protected PoolingDataSource ds = null;
- private GenericObjectPool pool = null;
+ protected PoolingDataSource<PoolableConnection> ds = null;
+ private GenericObjectPool<PoolableConnection> pool = null;
protected TransactionManager transactionManager;
@Override
@@ -81,13 +82,13 @@ public class TestManagedDataSource exten
factory.setDefaultAutoCommit(true);
// create the pool
- pool = new GenericObjectPool(factory);
+ pool = new GenericObjectPool<>(factory);
factory.setPool(pool);
pool.setMaxTotal(getMaxTotal());
pool.setMaxWaitMillis(getMaxWaitMillis());
// finally create the datasource
- ds = new ManagedDataSource(pool, xaConnectionFactory.getTransactionRegistry());
+ ds = new ManagedDataSource<>(pool, xaConnectionFactory.getTransactionRegistry());
ds.setAccessToUnderlyingConnectionAllowed(true);
}