[jboss-cvs] JBossAS SVN: r59811 - branches/Branch_4_2/connector/src/main/org/jboss/resource/adapter/jdbc/xa.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jan 19 02:52:55 EST 2007
Author: weston.price at jboss.com
Date: 2007-01-19 02:52:55 -0500 (Fri, 19 Jan 2007)
New Revision: 59811
Modified:
branches/Branch_4_2/connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnection.java
Log:
[JBAS-3860] Implemented LocalTransaction on XAManagedConnection to
fix condition of a hanging transaction when run outside of a managed
transaction context.
Modified: branches/Branch_4_2/connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnection.java
===================================================================
--- branches/Branch_4_2/connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnection.java 2007-01-19 07:46:32 UTC (rev 59810)
+++ branches/Branch_4_2/connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnection.java 2007-01-19 07:52:55 UTC (rev 59811)
@@ -43,7 +43,7 @@
*
* @version $Revision$
*/
-public class XAManagedConnection extends BaseWrapperManagedConnection implements XAResource
+public class XAManagedConnection extends BaseWrapperManagedConnection implements XAResource, LocalTransaction
{
protected final XAConnection xaConnection;
@@ -79,7 +79,7 @@
public LocalTransaction getLocalTransaction() throws ResourceException
{
- throw new JBossResourceException("xa tx only!");
+ return this;
}
public XAResource getXAResource() throws ResourceException
@@ -219,4 +219,69 @@
{
return props;
}
+
+ public void begin() throws ResourceException
+ {
+ synchronized (stateLock)
+ {
+ if (inManagedTransaction == false)
+ {
+ try
+ {
+ if (underlyingAutoCommit)
+ {
+ underlyingAutoCommit = false;
+ con.setAutoCommit(false);
+ }
+ checkState();
+ inManagedTransaction = true;
+ }
+ catch (SQLException e)
+ {
+ checkException(e);
+ }
+ }
+ else
+ throw new JBossResourceException("Trying to begin a nested local tx");
+ }
+ }
+ public void commit() throws ResourceException
+ {
+ synchronized (stateLock)
+ {
+ if (inManagedTransaction)
+ inManagedTransaction = false;
+ }
+ try
+ {
+ con.commit();
+ }
+ catch (SQLException e)
+ {
+ checkException(e);
+ }
+ }
+ public void rollback() throws ResourceException
+ {
+ synchronized (stateLock)
+ {
+ if (inManagedTransaction)
+ inManagedTransaction = false;
+ }
+ try
+ {
+ con.rollback();
+ }
+ catch (SQLException e)
+ {
+ try
+ {
+ checkException(e);
+ }
+ catch (Exception e2)
+ {
+ }
+ }
+ }
+
}
More information about the jboss-cvs-commits
mailing list