You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jb...@apache.org on 2003/11/18 03:15:59 UTC
cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound LocalXAResource.java
jboynes 2003/11/17 18:15:59
Modified: modules/core/src/java/org/apache/geronimo/connector/outbound
LocalXAResource.java
Log:
Fix mismatched xids with local tx
Tidy up javadoc
Revision Changes Path
1.3 +22 -90 incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/LocalXAResource.java
Index: LocalXAResource.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/LocalXAResource.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- LocalXAResource.java 14 Nov 2003 16:00:23 -0000 1.2
+++ LocalXAResource.java 18 Nov 2003 02:15:59 -0000 1.3
@@ -80,161 +80,93 @@
public LocalXAResource(LocalTransaction localTx) {
this.localTx = localTx;
- } // LocalXAResource constructor
+ }
// Implementation of javax.transaction.xa.XAResource
- /**
- * The <code>commit</code> method
- *
- * @param xid a <code>Xid</code> value
- * @param flag a <code>boolean</code> value
- * @exception XAException if an error occurs
- */
public void commit(Xid xid, boolean flag) throws XAException {
if (this.xid == null || !this.xid.equals(xid)) {
throw new XAException();
- } // end of if ()
+ }
try {
localTx.commit();
} catch (ResourceException e) {
XAException xae = new XAException();
//xae.setLinkedException(e);
throw xae;
- } // end of try-catch
- finally {
+ } finally {
this.xid = null;
- } // end of finally
+ }
}
- /**
- * The <code>forget</code> method
- *
- * @param xid a <code>Xid</code> value
- * @exception XAException if an error occurs
- */
public void forget(Xid xid) throws XAException {
this.xid = null;
}
- /**
- * The <code>getTransactionTimeout</code> method
- *
- * @return an <code>int</code> value
- * @exception XAException if an error occurs
- */
public int getTransactionTimeout() throws XAException {
return txTimeout;
}
- /**
- * The <code>isSameRM</code> method
- *
- * @param XAResource a <code>XAResource</code> value
- * @return a <code>boolean</code> value
- * @exception XAException if an error occurs
- */
public boolean isSameRM(XAResource xares) throws XAException {
return this == xares;
}
- /**
- * The <code>recover</code> method
- *
- * @param n an <code>int</code> value
- * @return a <code>Xid[]</code> value
- * @exception XAException if an error occurs
- */
public Xid[] recover(int n) throws XAException {
return null;
}
- /**
- * The <code>rollback</code> method
- *
- * @param xid a <code>Xid</code> value
- * @exception XAException if an error occurs
- */
public void rollback(Xid xid) throws XAException {
if (this.xid == null || !this.xid.equals(xid)) {
throw new XAException();
- } // end of if ()
+ }
try {
localTx.rollback();
} catch (ResourceException e) {
XAException xae = new XAException();
//xae.setLinkedException(e);
throw xae;
- } // end of try-catch
+ }
finally {
this.xid = null;
- } // end of finally
-
+ }
}
- /**
- * The <code>setTransactionTimeout</code> method
- *
- * @param n an <code>int</code> value
- * @return a <code>boolean</code> value
- * @exception XAException if an error occurs
- */
public boolean setTransactionTimeout(int txTimeout) throws XAException {
this.txTimeout = txTimeout;
return true;
}
- /**
- * The <code>start</code> method
- *
- * @param xid a <code>Xid</code> value
- * @param n an <code>int</code> value
- * @exception XAException if an error occurs
- */
public void start(Xid xid, int flag) throws XAException {
if (flag == XAResource.TMNOFLAGS) {
- if (xid != null) {
- throw new XAException();
- } // end of if ()
+ // first time in this transaction
+ if (this.xid != null) {
+ throw new XAException("already enlisted");
+ }
this.xid = xid;
try {
localTx.begin();
} catch (ResourceException e) {
- throw new XAException(); //"could not start local tx", e);
- } // end of try-catch
-
- } // end of if ()
- if (flag == XAResource.TMRESUME && xid != this.xid) {
- throw new XAException();
- } // end of if ()
- throw new XAException("unknown state");
+ throw (XAException) new XAException("could not start local tx").initCause(e);
+ }
+ } else if (flag == XAResource.TMRESUME) {
+ if (xid != this.xid) {
+ throw new XAException("attempting to resume in different transaction");
+ }
+ } else {
+ throw new XAException("unknown state");
+ }
}
- /**
- * The <code>end</code> method
- *
- * @param xid a <code>Xid</code> value
- * @param n an <code>int</code> value
- * @exception XAException if an error occurs
- */
public void end(Xid xid, int flag) throws XAException {
if (xid != this.xid) {
throw new XAException();
- } // end of if ()
+ }
//we could keep track of if the flag is TMSUCCESS...
}
- /**
- * The <code>prepare</code> method
- *
- * @param xid a <code>Xid</code> value
- * @return an <code>int</code> value
- * @exception XAException if an error occurs
- */
public int prepare(Xid xid) throws XAException {
//log warning that semantics are incorrect...
return XAResource.XA_OK;
}
-
-} // LocalXAResource
+}