[jboss-svn-commits] JBL Code SVN: r26393 - in labs/jbosstm/trunk: ArjunaCore and 5 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed May 6 07:23:16 EDT 2009
Author: jhalliday
Date: 2009-05-06 07:23:16 -0400 (Wed, 06 May 2009)
New Revision: 26393
Added:
labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImpleJDBC4.java
Removed:
labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/CrashRecovery13Impls/ExampleXAConnection.java
Modified:
labs/jbosstm/trunk/ArjunaCore/build.xml
labs/jbosstm/trunk/ArjunaJTA/build.xml
labs/jbosstm/trunk/ArjunaJTA/jdbc/build.xml
labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImple.java
labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImpleJDBC3.java
labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionManager.java
labs/jbosstm/trunk/ArjunaJTS/build.xml
labs/jbosstm/trunk/build.xml
Log:
Added JDBC4 support to TransactionalDriver, thus allowing us to build on JDK 6. JBTM-419
Modified: labs/jbosstm/trunk/ArjunaCore/build.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/build.xml 2009-05-06 10:45:41 UTC (rev 26392)
+++ labs/jbosstm/trunk/ArjunaCore/build.xml 2009-05-06 11:23:16 UTC (rev 26393)
@@ -60,17 +60,6 @@
<format property="com.hp.mw.date" pattern="yyyy/MMM/dd HH:mm"/>
</tstamp>
- <condition property="JDK_VERSION_OK">
- <or>
- <equals arg1="${java.specification.version}" arg2="1.4"/>
- <equals arg1="${java.specification.version}" arg2="1.5"/>
- </or>
- </condition>
-
- <fail unless="JDK_VERSION_OK">
- JBossTS Core currently requires jdk1.4 or jdk1.5 to build.
- </fail>
-
<property name="com.hp.mw.installationdirectory" location="install"/>
<property name="com.hp.mw.sourceid" value="unknown"/>
<property name="com.hp.mw.version" value="unknown"/>
@@ -178,7 +167,7 @@
</fileset>
</jar>
<delete file="built_using_java_${java.specification.version}"/>
-
+
<mkdir dir="${com.hp.mwlabs.ts.product.services.jar.dest}"/>
<module-to-product destdir="${com.hp.mwlabs.ts.product.services.jar.dest}" destfile="${com.hp.mw.ts.module.name.lowercase}-services">
<fileset dir=".">
Modified: labs/jbosstm/trunk/ArjunaJTA/build.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/build.xml 2009-05-06 10:45:41 UTC (rev 26392)
+++ labs/jbosstm/trunk/ArjunaJTA/build.xml 2009-05-06 11:23:16 UTC (rev 26393)
@@ -61,17 +61,6 @@
<format property="com.hp.mw.date" pattern="yyyy/MMM/dd HH:mm"/>
</tstamp>
- <condition property="JDK_VERSION_OK">
- <or>
- <equals arg1="${java.specification.version}" arg2="1.4"/>
- <equals arg1="${java.specification.version}" arg2="1.5"/>
- </or>
- </condition>
-
- <fail unless="JDK_VERSION_OK">
- JBossTS JTA currently requires jdk1.4 or jdk1.5 to build.
- </fail>
-
<property name="com.hp.mw.installationdirectory" location="install"/>
<property name="com.hp.mw.sourceid" value="unknown"/>
<property name="com.hp.mw.version" value="unknown"/>
Modified: labs/jbosstm/trunk/ArjunaJTA/jdbc/build.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/build.xml 2009-05-06 10:45:41 UTC (rev 26392)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/build.xml 2009-05-06 11:23:16 UTC (rev 26393)
@@ -56,13 +56,14 @@
<property name="com.hp.mwlabs.ts.jdbc.jar.dest" location="lib"/>
<property name="com.hp.mwlabs.ts.jdbc.tests.destdir" location="${com.hp.mwlabs.ts.jdbc.jar.dest}/tests/"/>
- <!-- don't try and build JDBC3 support if we are on jdk 1.4 -->
- <condition property="com.hp.mwlabs.ts.jdbc.compile.excludes.jdbc3" value="**/*JDBC3*.java" else="">
- <equals arg1="${java.specification.version}" arg2="1.4"/>
+ <!-- TODO don't try and build JDBC4 support if we are on jdk 1.5, it won't work -->
+ <condition property="com.hp.mwlabs.ts.jdbc.compile.excludes.jdbc"
+ value="**/ConnectionImpleJDBC4.java" else="**/ConnectionImpleJDBC3.java">
+ <equals arg1="${java.specification.version}" arg2="1.5"/>
</condition>
<!-- Relative path for files to exclude in main compile -->
- <property name="com.hp.mwlabs.ts.jdbc.compile.excludes" value="**/oracle_8*.java, **/oracle_9*.java, **/sequelink*.java, **/cloudscape*.java, ${com.hp.mwlabs.ts.jdbc.compile.excludes.jdbc3}"/>
+ <property name="com.hp.mwlabs.ts.jdbc.compile.excludes" value="**/oracle_8*.java, **/oracle_9*.java, **/sequelink*.java, **/cloudscape*.java, ${com.hp.mwlabs.ts.jdbc.compile.excludes.jdbc}"/>
<property name="com.hp.mwlabs.ts.jdbc.resourcebundle"
value="jdbc_msg_en_US.properties"/>
Modified: labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImple.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImple.java 2009-05-06 10:45:41 UTC (rev 26392)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImple.java 2009-05-06 11:23:16 UTC (rev 26393)
@@ -15,7 +15,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
- * (C) 2005-2006,
+ * (C) 2005-2009,
* @author JBoss Inc.
*/
/*
@@ -38,13 +38,9 @@
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.jta.xa.RecoverableXAConnection;
-import com.arjuna.ats.arjuna.common.*;
-
import com.arjuna.common.util.logging.*;
import javax.transaction.*;
@@ -56,24 +52,30 @@
import java.sql.SQLException;
/**
- * A transactional JDBC 2.0 connection. This wraps the real connection and
+ * A transactional JDBC connection. 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.
- *
+ *
* Once a connection is used within a transaction, that instance is bound to
* that transaction for the duration. It can be used by any number of threads,
* as long as they all have the same notion of the "current" transaction. When
* the transaction terminates, the connection is freed for use in another
* transaction.
- *
+ *
* Applications must not use this class directly.
- *
+ *
+ * Because of API changes between JDBC 3.0 (jdk 5) and JDBC 4.0 (jdk 6)
+ * it is not possible to write a single class that 'implements Connection'
+ * and compiles on both JDKs. Thus this class does not implement the interface
+ * but provides a home for methods that will compile on either. See also
+ * ConnectionImpleJDBC3, ConnectionImpleJDBC4 and ConnectionManager
+ *
* @author Mark Little (mark at arjuna.com)
* @version $Id: ConnectionImple.java 2342 2006-03-30 13:06:17Z $
* @since JTS 2.0.
*/
-public class ConnectionImple implements java.sql.Connection
+public abstract class ConnectionImple
{
public ConnectionImple(String dbName, Properties info) throws SQLException
@@ -223,14 +225,15 @@
return getConnection().getTypeMap();
}
- public void setTypeMap(Map map) throws SQLException
+/*
+ public void setTypeMap(Map map) throws SQLException
{
getConnection().setTypeMap(map);
}
-
+*/
/**
* Not allowed if within a transaction.
- *
+ *
* @message com.arjuna.ats.internal.jdbc.autocommit AutoCommit is not
* allowed by the transaction service.
*/
@@ -364,7 +367,7 @@
_recoveryConnection.closeCloseCurrentConnection();
if (_theConnection != null && !_theConnection.isClosed())
_theConnection.close();
-
+
_theConnection = null;
}
@@ -411,7 +414,7 @@
/**
* Can only set readonly before we use the connection in a given
* transaction!
- *
+ *
* @message com.arjuna.ats.internal.jdbc.setreadonly Cannot set readonly
* when within a transaction!
*/
@@ -493,77 +496,147 @@
/*
* ******************************************************************* *
- * JDBC 3.0 section, needed to compile under jdk1.4 * We don't support this
- * stuff yet, so we just throw exceptions.
+ * JDBC 3.0 section
*/
- public void setHoldability(int holdability) throws SQLException
- {
- throw new SQLException("feature not supported");
- }
+ public void setTypeMap(Map<String, Class<?>> map) throws SQLException
+ {
+ getConnection().setTypeMap(map);
+ }
- public int getHoldability() throws SQLException
- {
- throw new SQLException("feature not supported");
- }
+ public void setHoldability(int holdability) throws SQLException
+ {
+ checkTransaction();
- public Savepoint setSavepoint() throws SQLException
- {
- throw new SQLException("feature not supported");
- }
+ registerDatabase();
- public Savepoint setSavepoint(String name) throws SQLException
- {
- throw new SQLException("feature not supported");
- }
+ getConnection().setHoldability(holdability);
+ }
+ public int getHoldability() throws SQLException
+ {
+ return getConnection().getHoldability();
+ }
+
+ /**
+ * @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);
+ }
+ }
+
+ // 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.rollbacksavepointerror rollback(Savepoint) not allowed inside distributed tx.
+ */
public void rollback(Savepoint savepoint) throws SQLException
{
- throw new SQLException("feature not supported");
+ 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
{
- throw new SQLException("feature not supported");
+ 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
+ public Statement createStatement(int resultSetType, int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException
{
- throw new SQLException("feature not supported");
+ checkTransaction();
+
+ registerDatabase();
+
+ return getConnection().createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
}
public PreparedStatement prepareStatement(String sql, int resultSetType,
- int resultSetConcurrency, int resultSetHoldability)
- throws SQLException
+ int resultSetConcurrency, int resultSetHoldability) throws SQLException
{
- throw new SQLException("feature not supported");
+ checkTransaction();
+
+ registerDatabase();
+
+ return getConnection().prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
}
public CallableStatement prepareCall(String sql, int resultSetType,
- int resultSetConcurrency, int resultSetHoldability)
- throws SQLException
+ int resultSetConcurrency, int resultSetHoldability) throws SQLException
{
- throw new SQLException("feature not supported");
+ checkTransaction();
+
+ registerDatabase();
+
+ return getConnection().prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
}
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
throws SQLException
{
- throw new SQLException("feature not supported");
+ checkTransaction();
+
+ registerDatabase();
+
+ return getConnection().prepareStatement(sql, autoGeneratedKeys);
}
public PreparedStatement prepareStatement(String sql, int columnIndexes[])
throws SQLException
{
- throw new SQLException("feature not supported");
+ checkTransaction();
+
+ registerDatabase();
+
+ return getConnection().prepareStatement(sql, columnIndexes);
}
public PreparedStatement prepareStatement(String sql, String columnNames[])
throws SQLException
{
- throw new SQLException("feature not supported");
+ checkTransaction();
+
+ registerDatabase();
+
+ return getConnection().prepareStatement(sql, columnNames);
}
/*
@@ -571,7 +644,10 @@
* *******************************************************************
*/
- /**
+
+
+
+ /**
* @return the XAResource associated with the current XAConnection.
*/
@@ -701,7 +777,7 @@
* and not do a registration at all. This would require the connection
* object to be informed whenever a transaction completes so that it could
* flush its cache of XAResources though.
- *
+ *
* @message com.arjuna.ats.internal.jdbc.rollbackerror {0} - could not mark
* transaction rollback
* @message com.arjuna.ats.internal.jdbc.enlistfailed enlist of resource
@@ -849,7 +925,7 @@
if (tx == null)
return;
-
+
if (tx.getStatus() != Status.STATUS_ACTIVE)
throw new SQLException(jdbcLogger.logMesg
.getString("com.arjuna.ats.internal.jdbc.inactivetransaction"));
@@ -951,5 +1027,4 @@
}
}
}
-
}
Modified: labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImpleJDBC3.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImpleJDBC3.java 2009-05-06 10:45:41 UTC (rev 26392)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImpleJDBC3.java 2009-05-06 11:23:16 UTC (rev 26393)
@@ -15,7 +15,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
- * (C) 2006,
+ * (C) 2006, 2009
* @author JBoss Inc.
*
* $Id$
@@ -23,152 +23,18 @@
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
+ * JDBC 3.0 extention to the Connection wrapper.
+ * Since ConnectionImple now implements all the JDBC3 functions we don't
+ * have much to do. This class only really exists to add the
+ * 'implements Connection' clause.
*/
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);
- }
}
Added: labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImpleJDBC4.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImpleJDBC4.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionImpleJDBC4.java 2009-05-06 11:23:16 UTC (rev 26393)
@@ -0,0 +1,163 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ *
+ * (C) 2009 @author JBoss Inc
+ */
+package com.arjuna.ats.internal.jdbc;
+
+import com.arjuna.ats.jdbc.logging.jdbcLogger;
+
+import java.sql.*;
+import java.util.Properties;
+import java.util.Map;
+
+/**
+ * JDBC 4.0 extention to the Connection wrapper.
+ * ConnectionImple 'implements' JDBC3, this subclass
+ * adds those that use methods only present in the JDK 1.6 standard library.
+ */
+public class ConnectionImpleJDBC4 extends ConnectionImple implements Connection
+{
+ public ConnectionImpleJDBC4(String dbName, Properties info) throws SQLException {
+ super(dbName, info);
+ }
+
+ /*
+ * ******************************************************************* *
+ * 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);
+ }
+
+ /**
+ * @message com.arjuna.ats.internal.jdbc.nounwrapping Unwrapping is not supported.
+ */
+ public <T> T unwrap(Class<T> iface) throws SQLException
+ {
+ throw new SQLException(jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.nounwrapping"));
+ }
+
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ throw new SQLException(jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.nounwrapping"));
+ }
+
+ /*
+ * end of the JDBC 4.0 section
+ * *******************************************************************
+ */
+}
Modified: labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionManager.java 2009-05-06 10:45:41 UTC (rev 26392)
+++ labs/jbosstm/trunk/ArjunaJTA/jdbc/classes/com/arjuna/ats/internal/jdbc/ConnectionManager.java 2009-05-06 11:23:16 UTC (rev 26393)
@@ -15,7 +15,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
- * (C) 2005-2006,
+ * (C) 2005-2009,
* @author JBoss Inc.
*/
/*
@@ -37,6 +37,7 @@
import java.util.*;
import java.sql.SQLException;
+import java.sql.Connection;
import java.lang.reflect.Constructor;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
@@ -46,7 +47,6 @@
* user/password/url/dynamic_class options. If the connection we have cached
* has been closed, then create a new one.
*/
-
public class ConnectionManager
{
@@ -54,109 +54,111 @@
* Connections are pooled for the duration of a transaction.
*/
- /**
- * @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
+ /**
+ * @message com.arjuna.ats.internal.jdbc.nojdbcimple Can't load ConnectionImple class.
+ */
+ 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;
+ String user = info.getProperty(TransactionalDriver.userName);
+ String passwd = info.getProperty(TransactionalDriver.password);
+ String dynamic = info.getProperty(TransactionalDriver.dynamicClass);
+ if (dynamic == null)
+ dynamic = "";
- if (dynamic == null)
- dynamic = "";
+ for (ConnectionImple conn : _connections)
+ {
+ ConnectionControl connControl = conn.connectionControl();
+ TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
+ Transaction tx1, tx2 = null;
- while (e.hasMoreElements())
- {
- conn = (ConnectionImple) e.nextElement();
+ tx1 = connControl.transaction();
+ try
+ {
+ tx2 = tm.getTransaction();
+ }
+ catch (javax.transaction.SystemException se)
+ {
+ /* Ignore: tx2 is null already */
+ }
- ConnectionControl connControl = conn.connectionControl();
- TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
- Transaction tx1, tx2 = null;
+ /* Check transaction and database connection. */
+ if ((tx1 != null && tx1.equals(tx2))
+ && connControl.url().equals(dbUrl)
+ && connControl.user().equals(user)
+ && connControl.password().equals(passwd)
+ && connControl.dynamicClass().equals(dynamic))
+ {
+ try
+ {
+ /*
+ * Should not overload the meaning of closed. Change!
+ */
- tx1 = connControl.transaction();
- try
- {
- tx2 = tm.getTransaction();
- }
- catch (javax.transaction.SystemException se)
- {
- /* Ignore: tx2 is null already */
- }
+ if (!conn.isClosed())
+ {
+ // ConnectionImple does not actually implement Connection, but its
+ // concrete child classes do. See ConnectionImple javadoc.
+ return (Connection)conn;
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ throw new SQLException(ex.getMessage());
+ }
+ }
+ }
- /* Check transaction and database connection. */
- if ((tx1 != null && tx1.equals(tx2))
- && connControl.url().equals(dbUrl)
- && connControl.user().equals(user)
- && connControl.password().equals(passwd)
- && connControl.dynamicClass().equals(dynamic))
- {
- try
- {
- /*
- * Should not overload the meaning of closed. Change!
- */
+ // the ConnectionImple subclass is loaded dynamically because we only have one or the
+ // other available at build time, so we can't reference either directly in the code.
+ // See ConnectionImple javadoc.
- if (!conn.isClosed())
- {
- return conn;
- }
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- throw new SQLException(ex.getMessage());
- }
- }
- }
+ String connectionImpleClassName = "com.arjuna.ats.internal.jdbc.ConnectionImpleJDBC4";
+ ConnectionImple conn;
+ try
+ {
+ Class clazz = Class.forName(connectionImpleClassName);
+ Constructor ctor = clazz.getConstructor(new Class[] { String.class, Properties.class} );
+ conn = (ConnectionImple)ctor.newInstance(new Object[] { dbUrl, info });
+ }
+ catch(Exception exception)
+ {
+ // not necessarily an error, we may have a JDK5 build that does not include the JDBC4 driver.
+ // try to fallback to the older driver
+ connectionImpleClassName = "com.arjuna.ats.internal.jdbc.ConnectionImpleJDBC3";
+ try
+ {
+ Class clazz = Class.forName(connectionImpleClassName);
+ Constructor ctor = clazz.getConstructor(new Class[] { String.class, Properties.class} );
+ conn = (ConnectionImple)ctor.newInstance(new Object[] { dbUrl, info });
+ }
+ catch(Exception e)
+ {
+ if (jdbcLogger.logger.isErrorEnabled())
+ {
+ jdbcLogger.logger.error(jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.nojdbcimple")+exception.toString());
+ }
+ throw new SQLException(jdbcLogger.logMesg.getString("com.arjuna.ats.internal.jdbc.nojdbcimple")+exception.toString());
+ }
+ }
- 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());
- }
- }
- }
+ /*
+ * Will replace any old (closed) connection which had the
+ * same connection information.
+ */
- 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);
- }
+ _connections.add(conn);
-
- /*
- * Will replace any old (closed) connection which had the
- * same connection information.
- */
-
- _connections.put(conn, conn);
-
- return conn;
+ // ConnectionImple does not actually implement Connection, but its
+ // concrete child classes do. See ConnectionImple javadoc.
+ return (Connection)conn;
}
public static synchronized void remove (ConnectionImple conn)
{
- _connections.remove(conn);
+ _connections.remove(conn);
}
- private static Hashtable _connections = new Hashtable();
+ private static Set<ConnectionImple> _connections = new HashSet<ConnectionImple>();
}
Modified: labs/jbosstm/trunk/ArjunaJTS/build.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaJTS/build.xml 2009-05-06 10:45:41 UTC (rev 26392)
+++ labs/jbosstm/trunk/ArjunaJTS/build.xml 2009-05-06 11:23:16 UTC (rev 26393)
@@ -65,17 +65,6 @@
<format property="com.hp.mw.date" pattern="yyyy/MMM/dd HH:mm"/>
</tstamp>
- <condition property="JDK_VERSION_OK">
- <or>
- <equals arg1="${java.specification.version}" arg2="1.4"/>
- <equals arg1="${java.specification.version}" arg2="1.5"/>
- </or>
- </condition>
-
- <fail unless="JDK_VERSION_OK">
- JBossTS JTS currently requires jdk1.4 or jdk1.5 to build.
- </fail>
-
<property name="com.hp.mw.installationdirectory" location="install"/>
<property name="com.hp.mw.sourceid" value="unknown"/>
<property name="com.hp.mw.version" value="unknown"/>
Modified: labs/jbosstm/trunk/build.xml
===================================================================
--- labs/jbosstm/trunk/build.xml 2009-05-06 10:45:41 UTC (rev 26392)
+++ labs/jbosstm/trunk/build.xml 2009-05-06 11:23:16 UTC (rev 26393)
@@ -43,7 +43,7 @@
<available property="jts.present" file="${jts.dir}" type="dir"/>
<property name="com.hp.mw.sourceid" value="unknown"/>
-
+
<property name="junit.jar" location="ext/junit.jar"/>
<macrodef name="runant">
<attribute name="target"/>
@@ -227,17 +227,6 @@
<format property="com.hp.mw.date" pattern="yyyy/MMM/dd HH:mm"/>
</tstamp>
- <condition property="JDK_VERSION_OK">
- <or>
- <equals arg1="${java.specification.version}" arg2="1.4"/>
- <equals arg1="${java.specification.version}" arg2="1.5"/>
- </or>
- </condition>
-
- <fail unless="JDK_VERSION_OK">
- JBossTS currently requires jdk1.4 or jdk1.5 to build.
- </fail>
-
<!-- starting from 4.6 we change from ${com.hp.mw.ts.product.name.lowercase}-properties.xml
to a common name of jbossts-properties.xml to facilitate using the JTS binaries for either
JTA or JTS. The actual content of the config file is not affected. -->
Deleted: labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/CrashRecovery13Impls/ExampleXAConnection.java
===================================================================
--- labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/CrashRecovery13Impls/ExampleXAConnection.java 2009-05-06 10:45:41 UTC (rev 26392)
+++ labs/jbosstm/trunk/qa/tests/src/org/jboss/jbossts/qa/CrashRecovery13Impls/ExampleXAConnection.java 2009-05-06 11:23:16 UTC (rev 26393)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, 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) 2004,
- *
- * Arjuna Technologies Ltd,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: ExampleXAConnection.java,v 1.1 2004/10/13 15:45:47 nmcl Exp $
- */
-
-package org.jboss.jbossts.qa.CrashRecovery13Impls;
-
-import javax.sql.ConnectionEventListener;
-import javax.sql.XAConnection;
-import javax.transaction.xa.XAResource;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-public class ExampleXAConnection implements XAConnection
-{
- public XAResource getXAResource() throws SQLException
- {
- return new ExampleXAResource();
- }
-
- public void addConnectionEventListener(ConnectionEventListener l)
- {
- }
-
- public void close() throws SQLException
- {
- }
-
- public Connection getConnection() throws SQLException
- {
- return null;
- }
-
- public void removeConnectionEventListener(ConnectionEventListener l)
- {
- }
-
-}
-
More information about the jboss-svn-commits
mailing list