[jboss-cvs] JBossAS SVN: r59810 - trunk/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:46:32 EST 2007
Author: weston.price at jboss.com
Date: 2007-01-19 02:46:32 -0500 (Fri, 19 Jan 2007)
New Revision: 59810
Modified:
trunk/connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnection.java
Log:
[JBAS-3860] Implement LocalTransaction on XAManagedConnection to handle
the condition of a hanging transaction when used outside of managed transaction
context.
Modified: trunk/connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnection.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnection.java 2007-01-19 07:23:13 UTC (rev 59809)
+++ trunk/connector/src/main/org/jboss/resource/adapter/jdbc/xa/XAManagedConnection.java 2007-01-19 07:46:32 UTC (rev 59810)
@@ -42,14 +42,14 @@
* @author <a href="weston.price at jboss.com">Weston Price</a>
* @version $Revision$
*/
-public class XAManagedConnection extends BaseWrapperManagedConnection implements XAResource
+public class XAManagedConnection extends BaseWrapperManagedConnection implements XAResource, LocalTransaction
{
protected final XAConnection xaConnection;
protected final XAResource xaResource;
protected Xid currentXid;
-
+
public XAManagedConnection(XAManagedConnectionFactory mcf, XAConnection xaConnection, Properties props,
int transactionIsolation, int psCacheSize) throws SQLException
{
@@ -71,6 +71,73 @@
this.xaResource = xaConnection.getXAResource();
}
+ 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)
+ {
+ }
+ }
+ }
+
protected void broadcastConnectionError(SQLException e)
{
super.broadcastConnectionError(e);
@@ -78,7 +145,7 @@
public LocalTransaction getLocalTransaction() throws ResourceException
{
- throw new JBossResourceException("xa tx only!");
+ return this;
}
public XAResource getXAResource() throws ResourceException
More information about the jboss-cvs-commits
mailing list