[jboss-svn-commits] JBL Code SVN: r38084 - in labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP: ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/recovery and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed May 9 12:42:44 EDT 2012
Author: tomjenkinson
Date: 2012-05-09 12:42:43 -0400 (Wed, 09 May 2012)
New Revision: 38084
Removed:
labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImpleJDBC3.java
labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/recovery/JDBC2RecoveryConnection.java
Modified:
labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImple.java
labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionManager.java
labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/recovery/BasicXARecovery.java
labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/qa/tests/build-jts.xml
labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/qa/tests/src/org/jboss/jbossts/qa/astests/ASCrashRecovery01/Test03.java
Log:
JBTM-1120 updated to work with JDK7 (but needed to keep compat with JDK5
Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImple.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImple.java 2012-05-09 14:11:30 UTC (rev 38083)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImple.java 2012-05-09 16:42:43 UTC (rev 38084)
@@ -31,33 +31,31 @@
package com.arjuna.ats.internal.jdbc;
-import com.arjuna.ats.internal.jdbc.drivers.modifiers.ModifierFactory;
-import com.arjuna.ats.internal.jdbc.drivers.modifiers.ConnectionModifier;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+import java.util.Properties;
+import javax.sql.XAConnection;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.xa.XAResource;
+
+import com.arjuna.ats.internal.jdbc.drivers.modifiers.ConnectionModifier;
+import com.arjuna.ats.internal.jdbc.drivers.modifiers.ModifierFactory;
import com.arjuna.ats.jdbc.TransactionalDriver;
-import com.arjuna.ats.jdbc.logging.*;
import com.arjuna.ats.jdbc.common.jdbcPropertyManager;
-
-import com.arjuna.ats.jta.*;
-import com.arjuna.ats.jta.recovery.*;
-import com.arjuna.ats.jta.xa.XAModifier;
+import com.arjuna.ats.jdbc.logging.jdbcLogger;
import com.arjuna.ats.jta.xa.RecoverableXAConnection;
+import com.arjuna.ats.jta.xa.XAModifier;
+import com.arjuna.common.util.logging.DebugLevel;
+import com.arjuna.common.util.logging.VisibilityLevel;
-import com.arjuna.ats.arjuna.common.*;
-
-import com.arjuna.common.util.logging.*;
-
-import javax.transaction.*;
-import javax.transaction.xa.*;
-import javax.sql.*;
-import java.util.*;
-import java.util.concurrent.Executor;
-import java.sql.*;
-import javax.transaction.RollbackException;
-import java.sql.SQLException;
-
/**
- * A transactional JDBC 2.0 connection. This wraps the real connection and
+ * A transactional JDBC connection using InvocationHandling. This wraps the real connection and
* registers it with the transaction at appropriate times to ensure that all
* worked performed by it may be committed or rolled back.
*
@@ -74,7 +72,7 @@
* @since JTS 2.0.
*/
-public class ConnectionImple implements java.sql.Connection
+public class ConnectionImple implements InvocationHandler
{
public ConnectionImple(String dbName, Properties info) throws SQLException
@@ -154,81 +152,8 @@
_theConnection = null;
}
- public Statement createStatement() throws SQLException
- {
- checkTransaction();
- registerDatabase();
- return getConnection().createStatement();
- }
-
- public Statement createStatement(int rs, int rc) throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().createStatement(rs, rc);
- }
-
- public PreparedStatement prepareStatement(String sql) throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().prepareStatement(sql);
- }
-
- public PreparedStatement prepareStatement(String sql, int rs, int rc)
- throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().prepareStatement(sql, rs, rc);
- }
-
- public CallableStatement prepareCall(String sql) throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().prepareCall(sql);
- }
-
- public CallableStatement prepareCall(String sql, int rs, int rc)
- throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().prepareCall(sql, rs, rc);
- }
-
- public String nativeSQL(String sql) throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().nativeSQL(sql);
- }
-
- public Map getTypeMap() throws SQLException
- {
- return getConnection().getTypeMap();
- }
-
- public void setTypeMap(Map map) throws SQLException
- {
- getConnection().setTypeMap(map);
- }
-
/**
* Not allowed if within a transaction.
*
@@ -250,11 +175,6 @@
}
}
- public boolean getAutoCommit() throws SQLException
- {
- return getConnection().getAutoCommit();
- }
-
/**
* @message com.arjuna.ats.internal.jdbc.commiterror Commit not allowed by
* transaction service.
@@ -404,11 +324,6 @@
return _theConnection.isClosed();
}
- public DatabaseMetaData getMetaData() throws SQLException
- {
- return getConnection().getMetaData();
- }
-
/**
* Can only set readonly before we use the connection in a given
* transaction!
@@ -428,61 +343,7 @@
.getString("com.arjuna.ats.internal.jdbc.setreadonly"));
}
- public boolean isReadOnly() throws SQLException
- {
- return getConnection().isReadOnly();
- }
-
- public void setCatalog(String cat) throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- getConnection().setCatalog(cat);
- }
-
- public String getCatalog() throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().getCatalog();
- }
-
/**
- * @message com.arjuna.ats.internal.jdbc.stateerror State must be:
- */
-
- public void setTransactionIsolation(int iso) throws SQLException
- {
- checkTransaction();
-
- /*
- * if (iso != Connection.TRANSACTION_SERIALIZABLE) throw new
- * SQLException(jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.stateerror")+"Connection.TRANSACTION_SERIALIZABLE");
- */
-
- getConnection().setTransactionIsolation(iso);
- }
-
- public int getTransactionIsolation() throws SQLException
- {
- return getConnection().getTransactionIsolation();
- }
-
- public SQLWarning getWarnings() throws SQLException
- {
- return getConnection().getWarnings();
- }
-
- public void clearWarnings() throws SQLException
- {
- getConnection().clearWarnings();
- }
-
- /**
* @return the Arjuna specific recovery connection information. This should
* not be used by anything other than Arjuna.
*/
@@ -492,271 +353,6 @@
return _recoveryConnection;
}
- /*
- * ******************************************************************* *
- * JDBC 3.0 section, needed to compile under jdk1.4 * We don't support this
- * stuff yet, so we just throw exceptions.
- */
-
- public void setHoldability(int holdability) throws SQLException
- {
- throw new SQLException("feature not supported");
- }
-
- public int getHoldability() throws SQLException
- {
- throw new SQLException("feature not supported");
- }
-
- public Savepoint setSavepoint() throws SQLException
- {
- throw new SQLException("feature not supported");
- }
-
- public Savepoint setSavepoint(String name) throws SQLException
- {
- throw new SQLException("feature not supported");
- }
-
- public void rollback(Savepoint savepoint) throws SQLException
- {
- throw new SQLException("feature not supported");
- }
-
- public void releaseSavepoint(Savepoint savepoint) throws SQLException
- {
- throw new SQLException("feature not supported");
- }
-
- public Statement createStatement(int resultSetType,
- int resultSetConcurrency, int resultSetHoldability)
- throws SQLException
- {
- throw new SQLException("feature not supported");
- }
-
- public PreparedStatement prepareStatement(String sql, int resultSetType,
- int resultSetConcurrency, int resultSetHoldability)
- throws SQLException
- {
- throw new SQLException("feature not supported");
- }
-
- public CallableStatement prepareCall(String sql, int resultSetType,
- int resultSetConcurrency, int resultSetHoldability)
- throws SQLException
- {
- throw new SQLException("feature not supported");
- }
-
- public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
- throws SQLException
- {
- throw new SQLException("feature not supported");
- }
-
- public PreparedStatement prepareStatement(String sql, int columnIndexes[])
- throws SQLException
- {
- throw new SQLException("feature not supported");
- }
-
- public PreparedStatement prepareStatement(String sql, String columnNames[])
- throws SQLException
- {
- throw new SQLException("feature not supported");
- }
-
- /*
- * end of the JDBC 3.0 section
- * *******************************************************************
- */
-
- /*
- * ******************************************************************* *
- * JDBC 4.0 method section.
- */
-
- public Clob createClob() throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().createClob();
- }
-
- public Blob createBlob() throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().createBlob();
- }
-
- public NClob createNClob() throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().createNClob();
- }
-
- public SQLXML createSQLXML() throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().createSQLXML();
- }
-
- public boolean isValid(int timeout) throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().isValid(timeout);
- }
-
- public String getClientInfo(String name) throws SQLException
- {
- return getConnection().getClientInfo(name);
- }
-
- public Properties getClientInfo() throws SQLException
- {
- return getConnection().getClientInfo();
- }
-
- public void setClientInfo(String name, String value) throws SQLClientInfoException
- {
- try
- {
- getConnection().setClientInfo(name, value);
- }
- catch(SQLException e)
- {
- throw new SQLClientInfoException("setClientInfo : getConnection failed", null, e);
- }
- }
-
- public void setClientInfo(Properties properties) throws SQLClientInfoException
- {
- try
- {
- getConnection().setClientInfo(properties);
- }
- catch(SQLException e)
- {
- throw new SQLClientInfoException("setClientInfo : getConnection failed", null, e);
- }
- }
-
- public Array createArrayOf(String typeName, Object[] elements) throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().createArrayOf(typeName, elements);
- }
-
- public Struct createStruct(String typeName, Object[] attributes) throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().createStruct(typeName, attributes);
- }
-
- public <T> T unwrap(Class<T> iface) throws SQLException
- {
- if (iface != null) {
- if (iface.isInstance(this)) {
- return (T) this;
- } else {
- Connection conn = getConnection();
- if (conn != null) {
- if (iface.isInstance(conn)) {
- return (T) conn;
- } else if(conn.isWrapperFor(iface)) {
- return conn.unwrap(iface);
- }
- }
- }
- }
- return null;
- }
-
- public boolean isWrapperFor(Class<?> iface) throws SQLException
- {
- if (iface != null) {
- if (iface.isInstance(this)) {
- return true;
- } else {
- Connection conn = getConnection();
- if (conn != null) {
- if (iface.isInstance(conn)) {
- return true;
- } else {
- return conn.isWrapperFor(iface);
- }
- }
- }
- }
- return false;
- }
-
- /*
- * end of the JDBC 4.0 section
- * *******************************************************************
- */
-
- /*
- * ******************************************************************* *
- * Java 7 method section.
- */
-
- //@Override
- public void setSchema(String schema) throws SQLException
- {
- throw new SQLException();
- }
-
- //@Override
- public String getSchema() throws SQLException
- {
- throw new SQLException();
- }
-
- //@Override
- public void abort(Executor executor) throws SQLException
- {
- throw new SQLException();
- }
-
- //@Override
- public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException
- {
- throw new SQLException();
- }
-
- //@Override
- public int getNetworkTimeout() throws SQLException
- {
- throw new SQLException();
- }
-
- /*
- * end of the Java 7 section
- * *******************************************************************
- */
-
/**
* @return the XAResource associated with the current XAConnection.
*/
@@ -1138,4 +734,86 @@
}
}
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+
+ if (method.getName().equals("setAutoCommit")) {
+ setAutoCommit((Boolean) args[0]);
+ return null;
+ } else if (method.getName().equals("commit")) {
+ commit();
+ return null;
+ } else if (method.getName().equals("rollback")) {
+ rollback();
+ return null;
+ } else if (method.getName().equals("close")) {
+ close();
+ return null;
+ } else if (method.getName().equals("isClosed")) {
+ return isClosed();
+ } else if (method.getName().equals("setReadOnly")) {
+ setReadOnly((Boolean) args[0]);
+ return null;
+ } else {
+ if ((method.getName().equals("setSavepoint")
+ || method.getName().equals("rollback") || method.getName()
+ .equals("releaseSavepoint"))) {
+ if (transactionRunning())
+ throw new SQLException(
+ jdbcLogger.logMesg
+ .getString("com.arjuna.ats.internal.jdbc.releasesavepointerror"));
+ // Don't do checkTransaction or registerDatabase
+ } else if (method.getName().equals("setSchema")
+ || method.getName().equals("getSchema")
+ || method.getName().equals("abort")
+ || method.getName().equals("setNetworkTimeout")
+ || method.getName().equals("getNetworkTimeout")) {
+ throw new SQLException("Method " + method.getName()
+ + " not supported");
+ } else if (method.getName().equals("getTypeMap")
+ || method.getName().equals("setTypeMap")
+ || method.getName().equals("getAutoCommit")
+ || method.getName().equals("getMetaData")
+ || method.getName().equals("isReadOnly")
+ || method.getName().equals("getTransactionIsolation")
+ || method.getName().equals("getWarnings")
+ || method.getName().equals("clearWarnings")
+ || method.getName().equals("getClientInfo")
+ || method.getName().equals("setClientInfo")
+ || method.getName().equals("isWrapperFor")
+ || method.getName().equals("unwrap")) {
+ // Don't do checkTransaction or registerDatabase
+ } else if (method.getName().equals("setTransactionIsolation")
+ || method.getName().equals("setTypeMap")
+ || method.getName().equals("getAutoCommit")
+ || method.getName().equals("getMetaData")
+ || method.getName().equals("isReadOnly")
+ || method.getName().equals("getTransactionIsolation")
+ || method.getName().equals("getWarnings")
+ || method.getName().equals("clearWarnings")
+ || method.getName().equals("getClientInfo")
+ || method.getName().equals("setClientInfo")) {
+ // Don't do registerDatabase
+ checkTransaction();
+ } else {
+ checkTransaction();
+
+ registerDatabase();
+ }
+
+ try {
+ return (Boolean) method.invoke(getConnection(), args);
+ } catch (Throwable e) {
+ SQLException e2 = new SQLException("Could not call isValid:"
+ + e.getMessage());
+ if (e.getCause() instanceof SQLException) {
+ e2.setNextException((SQLException) e.getCause());
+ } else {
+ e.printStackTrace();
+ }
+ throw e2;
+ }
+ }
+ }
+
}
Deleted: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImpleJDBC3.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImpleJDBC3.java 2012-05-09 14:11:30 UTC (rev 38083)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImpleJDBC3.java 2012-05-09 16:42:43 UTC (rev 38084)
@@ -1,174 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2006,
- * @author JBoss Inc.
- *
- * $Id$
- */
-
-package com.arjuna.ats.internal.jdbc;
-
-import com.arjuna.ats.jdbc.logging.jdbcLogger;
-
-import java.sql.*;
-import java.util.Properties;
-
-/**
- * JDBC 3.0 extention to the JDBC 2.0 Connection wrapper
- */
-public class ConnectionImpleJDBC3 extends ConnectionImple implements Connection
-{
- public ConnectionImpleJDBC3(String dbName, Properties info) throws SQLException {
- super(dbName, info);
- }
-
- public void setHoldability(int holdability) throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- getConnection().setHoldability(holdability);
- }
-
- public int getHoldability() throws SQLException
- {
- return getConnection().getHoldability();
- }
-
- // The JDBC 3.0 spec (section 12.4) prohibits calling setSavepoint indide an XA tx.
- // It does not explicitly disallow calling rollback(savepoint) or releaseSavepoint(savepoint)
- // but allowing them does not make a whole lot of sense, so we don't:
-
- /**
- * @message com.arjuna.ats.internal.jdbc.setsavepointerror setSavepoint not allowed inside distributed tx.
- */
- public Savepoint setSavepoint() throws SQLException
- {
- if (transactionRunning())
- {
- throw new SQLException(jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.setsavepointerror"));
- }
- else
- {
- return getConnection().setSavepoint();
- }
- }
-
- public Savepoint setSavepoint(String name) throws SQLException
- {
- if (transactionRunning())
- {
- throw new SQLException(jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.setsavepointerror"));
- }
- else
- {
- return getConnection().setSavepoint(name);
- }
- }
-
- /**
- * @message com.arjuna.ats.internal.jdbc.rollbacksavepointerror rollback(Savepoint) not allowed inside distributed tx.
- */
- public void rollback(Savepoint savepoint) throws SQLException
- {
- if (transactionRunning())
- {
- throw new SQLException(jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.rollbacksavepointerror"));
- }
- else
- {
- getConnection().rollback(savepoint);
- }
- }
-
- /**
- * @message com.arjuna.ats.internal.jdbc.releasesavepointerror rollback(Savepoint) not allowed inside distributed tx.
- */
- public void releaseSavepoint(Savepoint savepoint) throws SQLException
- {
- if (transactionRunning())
- {
- throw new SQLException(jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.releasesavepointerror"));
- }
- else
- {
- getConnection().releaseSavepoint(savepoint);
- }
- }
-
- public Statement createStatement(int resultSetType, int resultSetConcurrency,
- int resultSetHoldability) throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
- }
-
- public PreparedStatement prepareStatement(String sql, int resultSetType,
- int resultSetConcurrency, int resultSetHoldability) throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
- }
-
- public CallableStatement prepareCall(String sql, int resultSetType,
- int resultSetConcurrency, int resultSetHoldability) throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
- }
-
- public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
- throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().prepareStatement(sql, autoGeneratedKeys);
- }
-
- public PreparedStatement prepareStatement(String sql, int columnIndexes[])
- throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().prepareStatement(sql, columnIndexes);
- }
-
- public PreparedStatement prepareStatement(String sql, String columnNames[])
- throws SQLException
- {
- checkTransaction();
-
- registerDatabase();
-
- return getConnection().prepareStatement(sql, columnNames);
- }
-}
Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionManager.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionManager.java 2012-05-09 14:11:30 UTC (rev 38083)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionManager.java 2012-05-09 16:42:43 UTC (rev 38084)
@@ -31,16 +31,20 @@
package com.arjuna.ats.internal.jdbc;
-import com.arjuna.ats.jdbc.TransactionalDriver;
-import com.arjuna.ats.jdbc.logging.jdbcLogger;
-
-import java.util.*;
-
+import java.lang.reflect.Proxy;
+import java.sql.Connection;
import java.sql.SQLException;
-import java.lang.reflect.Constructor;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
+import com.arjuna.ats.jdbc.TransactionalDriver;
+
/*
* Only ever create a single instance of a given connection, based upon the
* user/password/url/dynamic_class options. If the connection we have cached
@@ -57,22 +61,21 @@
/**
* @message com.arjuna.ats.internal.jdbc.nojdbc3 Can't load JDBC 3.0 wrapper, falling back to JDBC 2.0
*/
- public static synchronized ConnectionImple create (String dbUrl, Properties info) throws SQLException
+ public static synchronized Connection create (String dbUrl, Properties info) throws SQLException
{
String user = info.getProperty(TransactionalDriver.userName);
String passwd = info.getProperty(TransactionalDriver.password);
String dynamic = info.getProperty(TransactionalDriver.dynamicClass);
- Enumeration e = _connections.elements();
- ConnectionImple conn = null;
-
+ Iterator<ConnectionImple> e = _connections.keySet().iterator();
+
if (dynamic == null)
dynamic = "";
- while (e.hasMoreElements())
+ while (e.hasNext())
{
- conn = (ConnectionImple) e.nextElement();
+ ConnectionImple connectionImple = e.next();
- ConnectionControl connControl = conn.connectionControl();
+ ConnectionControl connControl = connectionImple.connectionControl();
TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
Transaction tx1, tx2 = null;
@@ -99,9 +102,11 @@
* Should not overload the meaning of closed. Change!
*/
- if (!conn.isClosed())
+ if (!connectionImple.isClosed())
{
- return conn;
+ return _connections.get(connectionImple);
+ } else {
+ _connections.remove(connectionImple);
}
}
catch (Exception ex)
@@ -111,43 +116,16 @@
}
}
}
+ ConnectionImple connectionImple = new ConnectionImple(dbUrl, info);
+ Connection conn = (Connection) Proxy.newProxyInstance(Connection.class.getClassLoader(), new Class[] {Connection.class}, connectionImple);
+
- conn = null;
- if(System.getProperty("java.specification.version").equals("1.5"))
- {
- // the 1.5 (JDBC3) wrapper version is loaded dynamically because classloading
- // it on earlier versions of the platform is not possible.
- try
- {
- Class clazz = Class.forName("com.arjuna.ats.internal.jdbc.ConnectionImpleJDBC3");
- Constructor ctor = clazz.getConstructor(new Class[] { String.class, Properties.class} );
- conn = (ConnectionImple)ctor.newInstance(new Object[] { dbUrl, info });
- }
- catch(Exception exception)
- {
- // not necessarily an errror - maybe we are running the 1.4 build on 1.5 vm.
- if (jdbcLogger.logger.isDebugEnabled())
- {
- jdbcLogger.logger.warn(jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.nojdbc3")+": "+e.toString());
- }
- }
- }
-
- if(conn == null)
- {
- // we are probably either on Java < 1.5 or running a build that was
- // done on Java 1.5 and thus does not have the JDBC3 wrapper.
- // Either way we use the default JDBC 2.0 implementation
- conn = new ConnectionImple(dbUrl, info);
- }
-
-
/*
* Will replace any old (closed) connection which had the
* same connection information.
*/
- _connections.put(conn, conn);
+ _connections.put(connectionImple, conn);
return conn;
}
@@ -157,6 +135,6 @@
_connections.remove(conn);
}
- private static Hashtable _connections = new Hashtable();
+ private static Map<ConnectionImple, Connection> _connections = new HashMap<ConnectionImple, Connection>();
}
Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/recovery/BasicXARecovery.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/recovery/BasicXARecovery.java 2012-05-09 14:11:30 UTC (rev 38083)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/recovery/BasicXARecovery.java 2012-05-09 16:42:43 UTC (rev 38084)
@@ -31,20 +31,19 @@
package com.arjuna.ats.internal.jdbc.recovery;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import javax.transaction.xa.XAResource;
+
+import com.arjuna.ats.internal.jdbc.ConnectionImple;
import com.arjuna.ats.jdbc.TransactionalDriver;
import com.arjuna.ats.jdbc.common.jdbcPropertyManager;
import com.arjuna.ats.jdbc.logging.jdbcLogger;
-
import com.arjuna.ats.jta.recovery.XAResourceRecovery;
-
-import com.arjuna.common.util.logging.*;
-
-import java.sql.*;
-import javax.transaction.xa.*;
-import java.util.*;
-
-import java.lang.NumberFormatException;
import com.arjuna.common.internal.util.propertyservice.plugins.io.XMLFilePlugin;
+import com.arjuna.common.util.logging.DebugLevel;
+import com.arjuna.common.util.logging.VisibilityLevel;
/**
* This class implements the XAResourceRecovery interface for XAResources. The
@@ -190,7 +189,7 @@
public synchronized XAResource getXAResource () throws SQLException
{
- JDBC2RecoveryConnection conn = null;
+ ConnectionImple conn = null;
if (hasMoreResources())
{
@@ -222,7 +221,7 @@
return true;
}
- private final JDBC2RecoveryConnection getStandardConnection ()
+ private final ConnectionImple getStandardConnection ()
throws SQLException
{
String number = new String("" + connectionIndex);
@@ -246,13 +245,13 @@
if (dc != null)
dbProperties.put(TransactionalDriver.dynamicClass, dc);
- return new JDBC2RecoveryConnection(url, dbProperties);
+ return new ConnectionImple(url, dbProperties);
}
else
return null;
}
- private final JDBC2RecoveryConnection getJNDIConnection ()
+ private final ConnectionImple getJNDIConnection ()
throws SQLException
{
String number = new String("" + connectionIndex);
@@ -270,7 +269,7 @@
dbProperties.put(TransactionalDriver.userName, theUser);
dbProperties.put(TransactionalDriver.password, thePassword);
- return new JDBC2RecoveryConnection(url, dbProperties);
+ return new ConnectionImple(url, dbProperties);
}
else
return null;
Deleted: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/recovery/JDBC2RecoveryConnection.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/recovery/JDBC2RecoveryConnection.java 2012-05-09 14:11:30 UTC (rev 38083)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/recovery/JDBC2RecoveryConnection.java 2012-05-09 16:42:43 UTC (rev 38084)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 2001,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: JDBC2RecoveryConnection.java 2342 2006-03-30 13:06:17Z $
- */
-
-package com.arjuna.ats.internal.jdbc.recovery;
-
-import com.arjuna.ats.internal.jdbc.ConnectionImple;
-
-import java.util.Properties;
-import java.sql.*;
-
-/**
- * To perform recovery on arbitrary connections we may need to recreate those
- * connections.
- *
- * The ArjunaJDBC2Connection class must not be used directly by applications,
- * hence the requirement for this class.
- *
- * @since JTS 2.1.
- */
-
-public class JDBC2RecoveryConnection extends ConnectionImple
-{
-
- public JDBC2RecoveryConnection (String dbName, Properties info)
- throws SQLException
- {
- super(dbName, info);
- }
-
- public JDBC2RecoveryConnection (String dbName, String user, String passwd)
- throws SQLException
- {
- this(dbName, user, passwd, null);
- }
-
- public JDBC2RecoveryConnection (String dbName, String user, String passwd,
- String dynamic) throws SQLException
- {
- super(dbName, user, passwd, dynamic);
- }
-
-}
Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/qa/tests/build-jts.xml
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/qa/tests/build-jts.xml 2012-05-09 14:11:30 UTC (rev 38083)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/qa/tests/build-jts.xml 2012-05-09 16:42:43 UTC (rev 38084)
@@ -285,6 +285,7 @@
<include name="**/EnlistDelistEnlist01*/**"/>
<include name="**/Issues0001*/**"/>
<include name="**/report.java"/>
+ <exclude name="**/CrashRecovery13Impls/ExampleXAConnection.java"/>
<classpath>
<path refid="jts.classpath"/>
Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/qa/tests/src/org/jboss/jbossts/qa/astests/ASCrashRecovery01/Test03.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/qa/tests/src/org/jboss/jbossts/qa/astests/ASCrashRecovery01/Test03.java 2012-05-09 14:11:30 UTC (rev 38083)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/qa/tests/src/org/jboss/jbossts/qa/astests/ASCrashRecovery01/Test03.java 2012-05-09 16:42:43 UTC (rev 38084)
@@ -26,7 +26,7 @@
import org.jboss.jbossts.qa.astests.taskdefs.TransactionLog;
import org.jboss.jbossts.qa.astests.crash.CrashRem;
import org.jboss.jbossts.qa.astests.crash.CrashRemHome;
-import org.jboss.remoting.CannotConnectException;
+//import org.jboss.remoting.CannotConnectException;
import org.apache.tools.ant.BuildException;
import java.util.Map;
@@ -231,7 +231,7 @@
return "Passed".equalsIgnoreCase(res);
}
- catch (CannotConnectException e)
+ catch (Exception e) // Was CannotConnectException
{
if (expectFailure)
{
@@ -246,11 +246,11 @@
e.printStackTrace();
}
}
- catch (Throwable t)
- {
- t.printStackTrace();
- System.err.println("XACrashTest:crashTest: Caught " + t);
- }
+ //catch (Throwable t)
+ //{
+ // t.printStackTrace();
+ // System.err.println("XACrashTest:crashTest: Caught " + t);
+ //}
finally {
if (clientTx)
try
More information about the jboss-svn-commits
mailing list