Author: markt
Date: Sat Jul 30 16:23:31 2011
New Revision: 1152491
URL: http://svn.apache.org/viewvc?rev=1152491&view=rev
Log:
Generics
Modified:
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/TransactionContext.java
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/TransactionRegistry.java
Modified:
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/TransactionContext.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/TransactionContext.java?rev=1152491&r1=1152490&r2=1152491&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/TransactionContext.java
(original)
+++
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/TransactionContext.java
Sat Jul 30 16:23:31 2011
@@ -38,7 +38,7 @@ import java.lang.ref.WeakReference;
*/
public class TransactionContext {
private final TransactionRegistry transactionRegistry;
- private final WeakReference transactionRef;
+ private final WeakReference<Transaction> transactionRef;
private Connection sharedConnection;
/**
@@ -54,7 +54,7 @@ public class TransactionContext {
if (transactionRegistry == null) throw new
NullPointerException("transactionRegistry is null");
if (transaction == null) throw new NullPointerException("transaction
is null");
this.transactionRegistry = transactionRegistry;
- this.transactionRef = new WeakReference(transaction);
+ this.transactionRef = new WeakReference<Transaction>(transaction);
}
/**
@@ -129,7 +129,7 @@ public class TransactionContext {
*/
public boolean isActive() throws SQLException {
try {
- Transaction transaction = (Transaction) this.transactionRef.get();
+ Transaction transaction = this.transactionRef.get();
if (transaction == null) {
return false;
}
@@ -141,7 +141,7 @@ public class TransactionContext {
}
private Transaction getTransaction() throws SQLException {
- Transaction transaction = (Transaction) this.transactionRef.get();
+ Transaction transaction = this.transactionRef.get();
if (transaction == null) {
throw new SQLException("Unable to enlist connection because the
transaction has been garbage collected");
}
Modified:
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/TransactionRegistry.java
URL:
http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/TransactionRegistry.java?rev=1152491&r1=1152490&r2=1152491&view=diff
==============================================================================
---
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/TransactionRegistry.java
(original)
+++
commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/managed/TransactionRegistry.java
Sat Jul 30 16:23:31 2011
@@ -40,8 +40,10 @@ import javax.transaction.xa.XAResource;
*/
public class TransactionRegistry {
private final TransactionManager transactionManager;
- private final Map caches = new WeakHashMap();
- private final Map xaResources = new WeakHashMap();
+ private final Map<Transaction, TransactionContext> caches =
+ new WeakHashMap<Transaction, TransactionContext>();
+ private final Map<Connection, XAResource> xaResources =
+ new WeakHashMap<Connection, XAResource>();
/**
* Creates a TransactionRegistry for the specified transaction manager.
@@ -73,7 +75,7 @@ public class TransactionRegistry {
*/
public synchronized XAResource getXAResource(Connection connection) throws
SQLException {
if (connection == null) throw new NullPointerException("connection is
null");
- XAResource xaResource = (XAResource) xaResources.get(connection);
+ XAResource xaResource = xaResources.get(connection);
if (xaResource == null) {
throw new SQLException("Connection does not have a registered
XAResource " + connection);
}
@@ -106,7 +108,7 @@ public class TransactionRegistry {
// register the the context (or create a new one)
synchronized (this) {
- TransactionContext cache = (TransactionContext)
caches.get(transaction);
+ TransactionContext cache = caches.get(transaction);
if (cache == null) {
cache = new TransactionContext(this, transaction);
caches.put(transaction, cache);