diff --git a/src/main/java/com/alibaba/druid/pool/DruidDataSource.java b/src/main/java/com/alibaba/druid/pool/DruidDataSource.java
index 79c990f3ea..8a8557bba0 100644
--- a/src/main/java/com/alibaba/druid/pool/DruidDataSource.java
+++ b/src/main/java/com/alibaba/druid/pool/DruidDataSource.java
@@ -515,14 +515,14 @@ public class DruidDataSource extends DruidDataAbstractSource implements DruidDat
if (timeBetweenEvictionRunsMillis > 0) {
Thread.sleep(timeBetweenEvictionRunsMillis);
}
-
+
ConnectionHolder first = null;
lock.lock();
try {
if (count <= 0) {
continue;
}
-
+
if (count <= maxIdle) {
highWater.await();
continue;
diff --git a/src/main/java/com/alibaba/druid/pool/PoolableConnection.java b/src/main/java/com/alibaba/druid/pool/PoolableConnection.java
index bde2134a54..3b940f612b 100644
--- a/src/main/java/com/alibaba/druid/pool/PoolableConnection.java
+++ b/src/main/java/com/alibaba/druid/pool/PoolableConnection.java
@@ -416,7 +416,7 @@ public class PoolableConnection implements PooledConnection, Connection {
if (holder == null) {
return true;
}
-
+
return conn.isClosed();
}
diff --git a/src/main/java/com/alibaba/druid/pool/xa/DataSourceXAConnectionFactory.java b/src/main/java/com/alibaba/druid/pool/xa/DataSourceXAConnectionFactory.java
index 4ba166aad1..036b5c7b81 100644
--- a/src/main/java/com/alibaba/druid/pool/xa/DataSourceXAConnectionFactory.java
+++ b/src/main/java/com/alibaba/druid/pool/xa/DataSourceXAConnectionFactory.java
@@ -24,37 +24,39 @@ import java.sql.SQLException;
/**
* An implementation of XAConnectionFactory which uses a real XADataSource to obtain connections and XAResources.
- *
+ *
* @author Dain Sundstrom
* @version $Revision$
*/
public class DataSourceXAConnectionFactory implements XAConnectionFactory {
+
protected TransactionRegistry transactionRegistry;
- protected XADataSource xaDataSource;
- protected String username;
- protected String password;
+ protected XADataSource xaDataSource;
+ protected String username;
+ protected String password;
/**
- * Creates an DataSourceXAConnectionFactory which uses the specified XADataSource to create database
- * connections. The connections are enlisted into transactions using the specified transaction manager.
- *
+ * Creates an DataSourceXAConnectionFactory which uses the specified XADataSource to create database connections.
+ * The connections are enlisted into transactions using the specified transaction manager.
+ *
* @param transactionManager the transaction manager in which connections will be enlisted
* @param xaDataSource the data source from which connections will be retrieved
*/
- public DataSourceXAConnectionFactory(TransactionManager transactionManager, XADataSource xaDataSource) {
+ public DataSourceXAConnectionFactory(TransactionManager transactionManager, XADataSource xaDataSource){
this(transactionManager, xaDataSource, null, null);
}
/**
- * Creates an DataSourceXAConnectionFactory which uses the specified XADataSource to create database
- * connections. The connections are enlisted into transactions using the specified transaction manager.
- *
+ * Creates an DataSourceXAConnectionFactory which uses the specified XADataSource to create database connections.
+ * The connections are enlisted into transactions using the specified transaction manager.
+ *
* @param transactionManager the transaction manager in which connections will be enlisted
* @param xaDataSource the data source from which connections will be retrieved
* @param username the username used for authenticating new connections or null for unauthenticated
* @param password the password used for authenticating new connections
*/
- public DataSourceXAConnectionFactory(TransactionManager transactionManager, XADataSource xaDataSource, String username, String password) {
+ public DataSourceXAConnectionFactory(TransactionManager transactionManager, XADataSource xaDataSource,
+ String username, String password){
if (transactionManager == null) throw new NullPointerException("transactionManager is null");
if (xaDataSource == null) throw new NullPointerException("xaDataSource is null");
@@ -66,6 +68,7 @@ public class DataSourceXAConnectionFactory implements XAConnectionFactory {
/**
* Gets the username used to authenticate new connections.
+ *
* @return the user name or null if unauthenticated connections are used
*/
public String getUsername() {
@@ -74,6 +77,7 @@ public class DataSourceXAConnectionFactory implements XAConnectionFactory {
/**
* Sets the username used to authenticate new connections.
+ *
* @param username the username used for authenticating the connection or null for unauthenticated
*/
public void setUsername(String username) {
@@ -82,6 +86,7 @@ public class DataSourceXAConnectionFactory implements XAConnectionFactory {
/**
* Sets the password used to authenticate new connections.
+ *
* @param password the password used for authenticating the connection or null for unauthenticated
*/
public void setPassword(String password) {
@@ -111,4 +116,3 @@ public class DataSourceXAConnectionFactory implements XAConnectionFactory {
return connection;
}
}
-
diff --git a/src/main/java/com/alibaba/druid/pool/xa/DruidXADataSource.java b/src/main/java/com/alibaba/druid/pool/xa/DruidXADataSource.java
index 3af14e5c21..ba47bd5f11 100644
--- a/src/main/java/com/alibaba/druid/pool/xa/DruidXADataSource.java
+++ b/src/main/java/com/alibaba/druid/pool/xa/DruidXADataSource.java
@@ -124,7 +124,7 @@ public class DruidXADataSource extends DruidDataSource {
// Create the XADataSource instance using the configured class name if it has not been set
if (xaDataSourceInstance == null) {
- Class xaDataSourceClass = null;
+ Class> xaDataSourceClass = null;
try {
xaDataSourceClass = Class.forName(xaDataSource);
} catch (Throwable t) {
diff --git a/src/main/java/com/alibaba/druid/pool/xa/LocalXAConnectionFactory.java b/src/main/java/com/alibaba/druid/pool/xa/LocalXAConnectionFactory.java
index 29c7e69fa0..74a1b40ce4 100644
--- a/src/main/java/com/alibaba/druid/pool/xa/LocalXAConnectionFactory.java
+++ b/src/main/java/com/alibaba/druid/pool/xa/LocalXAConnectionFactory.java
@@ -46,8 +46,13 @@ public class LocalXAConnectionFactory implements XAConnectionFactory {
* @param connectionFactory the connection factory from which connections will be retrieved
*/
public LocalXAConnectionFactory(TransactionManager transactionManager, ConnectionFactory connectionFactory){
- if (transactionManager == null) throw new NullPointerException("transactionManager is null");
- if (connectionFactory == null) throw new NullPointerException("connectionFactory is null");
+ if (transactionManager == null) {
+ throw new NullPointerException("transactionManager is null");
+ }
+
+ if (connectionFactory == null) {
+ throw new NullPointerException("connectionFactory is null");
+ }
this.transactionRegistry = new TransactionRegistry(transactionManager);
this.connectionFactory = connectionFactory;
diff --git a/src/main/java/com/alibaba/druid/pool/xa/ManagedConnection.java b/src/main/java/com/alibaba/druid/pool/xa/ManagedConnection.java
index 83ba3545b5..730fc57ecd 100644
--- a/src/main/java/com/alibaba/druid/pool/xa/ManagedConnection.java
+++ b/src/main/java/com/alibaba/druid/pool/xa/ManagedConnection.java
@@ -154,35 +154,35 @@ public class ManagedConnection extends PoolableConnection {
}
protected void transactionComplete() {
-// transactionContext = null;
-//
-// // if we were using a shared connection, clear the reference now that the transaction has completed
-// if (isSharedConnection) {
-// // for now, just set the delegate to null, it will be created later if needed
-// setDelegate(null);
-// isSharedConnection = false;
-// }
-//
-// // if this connection was closed during the transaction and there is still a delegate present close it
-// Connection delegate = getDelegateInternal();
-// if (isClosed() && delegate != null) {
-// try {
-// setDelegate(null);
-//
-// // don't actually close the connection if in a transaction
-// if (!delegate.isClosed()) {
-// // don't use super.close() because it calls passivate() which marks the
-// // the connection as closed without returning it to the pool
-// delegate.close();
-// }
-// } catch (SQLException ignored) {
-// // not a whole lot we can do here as connection is closed
-// // and this is a transaction callback so there is no
-// // way to report the error
-// } finally {
-// _closed = true;
-// }
-// }
+ // transactionContext = null;
+ //
+ // // if we were using a shared connection, clear the reference now that the transaction has completed
+ // if (isSharedConnection) {
+ // // for now, just set the delegate to null, it will be created later if needed
+ // setDelegate(null);
+ // isSharedConnection = false;
+ // }
+ //
+ // // if this connection was closed during the transaction and there is still a delegate present close it
+ // Connection delegate = getDelegateInternal();
+ // if (isClosed() && delegate != null) {
+ // try {
+ // setDelegate(null);
+ //
+ // // don't actually close the connection if in a transaction
+ // if (!delegate.isClosed()) {
+ // // don't use super.close() because it calls passivate() which marks the
+ // // the connection as closed without returning it to the pool
+ // delegate.close();
+ // }
+ // } catch (SQLException ignored) {
+ // // not a whole lot we can do here as connection is closed
+ // // and this is a transaction callback so there is no
+ // // way to report the error
+ // } finally {
+ // _closed = true;
+ // }
+ // }
throw new RuntimeException("TODO");
}
diff --git a/src/main/java/com/alibaba/druid/pool/xa/ManagedDataSource.java b/src/main/java/com/alibaba/druid/pool/xa/ManagedDataSource.java
index 4af72305dc..d5b7939145 100644
--- a/src/main/java/com/alibaba/druid/pool/xa/ManagedDataSource.java
+++ b/src/main/java/com/alibaba/druid/pool/xa/ManagedDataSource.java
@@ -18,60 +18,58 @@ package com.alibaba.druid.pool.xa;
import java.sql.Connection;
import java.sql.SQLException;
-
/**
* The ManagedDataSource is a PoolingDataSource that creates ManagedConnections.
- *
+ *
* @author Dain Sundstrom
* @version $Revision$
*/
public class ManagedDataSource {
+
private TransactionRegistry transactionRegistry;
/**
- * Creates an uninitialized datasource. Before this data source can be used a pool and
- * transaction registry must be set.
+ * Creates an uninitialized datasource. Before this data source can be used a pool and transaction registry must be
+ * set.
*/
- public ManagedDataSource() {
+ public ManagedDataSource(){
}
/**
- * Creates a ManagedDataSource which obtains connections from the specified pool and
- * manages them using the specified transaction registry. The TransactionRegistry must
- * be the transaction registry obtained from the XAConnectionFactory used to create
- * the connection pool. If not an error will occure when attempting to use the connection
- * in a global transaction because the XAResource object associated with the connection
- * will be unavailable.
- *
+ * Creates a ManagedDataSource which obtains connections from the specified pool and manages them using the
+ * specified transaction registry. The TransactionRegistry must be the transaction registry obtained from the
+ * XAConnectionFactory used to create the connection pool. If not an error will occure when attempting to use the
+ * connection in a global transaction because the XAResource object associated with the connection will be
+ * unavailable.
+ *
* @param pool the connection pool
- * @param transactionRegistry the transaction registry obtained from the
- * XAConnectionFactory used to create the connection pool object factory
+ * @param transactionRegistry the transaction registry obtained from the XAConnectionFactory used to create the
+ * connection pool object factory
*/
- public ManagedDataSource(TransactionRegistry transactionRegistry) {
+ public ManagedDataSource(TransactionRegistry transactionRegistry){
this.transactionRegistry = transactionRegistry;
}
/**
- * Sets the transaction registry from the XAConnectionFactory used to create the pool.
- * The transaction registry can only be set once using either a connector or this setter
- * method.
- * @param transactionRegistry the transaction registry acquired from the XAConnectionFactory
- * used to create the pool
+ * Sets the transaction registry from the XAConnectionFactory used to create the pool. The transaction registry can
+ * only be set once using either a connector or this setter method.
+ *
+ * @param transactionRegistry the transaction registry acquired from the XAConnectionFactory used to create the pool
*/
public void setTransactionRegistry(TransactionRegistry transactionRegistry) {
- if(this.transactionRegistry != null) throw new IllegalStateException("TransactionRegistry already set");
- if(transactionRegistry == null) throw new NullPointerException("TransactionRegistry is null");
+ if (this.transactionRegistry != null) throw new IllegalStateException("TransactionRegistry already set");
+ if (transactionRegistry == null) throw new NullPointerException("TransactionRegistry is null");
this.transactionRegistry = transactionRegistry;
}
public Connection getConnection() throws SQLException {
-// if (_pool == null) throw new IllegalStateException("Pool has not been set");
-// if (transactionRegistry == null) throw new IllegalStateException("TransactionRegistry has not been set");
-//
-// Connection connection = new ManagedConnection(_pool, transactionRegistry, isAccessToUnderlyingConnectionAllowed());
-// return connection;
+ // if (_pool == null) throw new IllegalStateException("Pool has not been set");
+ // if (transactionRegistry == null) throw new IllegalStateException("TransactionRegistry has not been set");
+ //
+ // Connection connection = new ManagedConnection(_pool, transactionRegistry,
+ // isAccessToUnderlyingConnectionAllowed());
+ // return connection;
throw new SQLException("TODO"); // TODO
}
}
-
diff --git a/src/main/java/com/alibaba/druid/pool/xa/TransactionContext.java b/src/main/java/com/alibaba/druid/pool/xa/TransactionContext.java
index 433e70e574..e41c2c2d3f 100644
--- a/src/main/java/com/alibaba/druid/pool/xa/TransactionContext.java
+++ b/src/main/java/com/alibaba/druid/pool/xa/TransactionContext.java
@@ -26,29 +26,27 @@ import java.sql.SQLException;
import java.lang.ref.WeakReference;
/**
- * TransactionContext represents the association between a single XAConnectionFactory and a Transaction.
- * This context contains a single shared connection which should be used by all ManagedConnections for
- * the XAConnectionFactory, the ability to listen for the transaction completion event, and a method
- * to check the status of the transaction.
- *
+ * TransactionContext represents the association between a single XAConnectionFactory and a Transaction. This context
+ * contains a single shared connection which should be used by all ManagedConnections for the XAConnectionFactory, the
+ * ability to listen for the transaction completion event, and a method to check the status of the transaction.
+ *
* @author Dain Sundstrom
* @version $Revision$
*/
public class TransactionContext {
- private final TransactionRegistry transactionRegistry;
+
+ private final TransactionRegistry transactionRegistry;
private final WeakReference