[Mulgara-svn] r1351 - trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi
ronald at mulgara.org
ronald at mulgara.org
Thu Oct 23 13:12:00 UTC 2008
Author: ronald
Date: 2008-10-23 06:11:59 -0700 (Thu, 23 Oct 2008)
New Revision: 1351
Modified:
trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractXAResource.java
Log:
Factored out transaction cleanup; this also now provides a nice hook for
subclasses to do their cleanup in.
Modified: trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractXAResource.java
===================================================================
--- trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractXAResource.java 2008-10-23 13:11:53 UTC (rev 1350)
+++ trunk/src/jar/resolver-spi/java/org/mulgara/resolver/spi/AbstractXAResource.java 2008-10-23 13:11:59 UTC (rev 1351)
@@ -164,8 +164,9 @@
try {
int sts = doPrepare(tx);
- if (sts == XA_RDONLY)
- resourceManager.transactions.remove(new XidWrapper(xid));
+ if (sts == XA_RDONLY) {
+ transactionCompleted(tx);
+ }
return sts;
} catch (Throwable t) {
logger.warn("Attempt to prepare failed", t);
@@ -185,7 +186,7 @@
if (onePhase) {
int sts = doPrepare(tx);
if (sts == XA_RDONLY) {
- resourceManager.transactions.remove(new XidWrapper(xid));
+ transactionCompleted(tx);
return;
}
}
@@ -211,7 +212,7 @@
throw new XAException(XAException.XAER_RMERR);
} finally {
if (clean) {
- resourceManager.transactions.remove(new XidWrapper(xid));
+ transactionCompleted(tx);
}
}
}
@@ -239,7 +240,7 @@
throw new XAException(XAException.XAER_RMERR);
} finally {
if (clean) {
- resourceManager.transactions.remove(new XidWrapper(xid));
+ transactionCompleted(tx);
}
}
}
@@ -265,7 +266,7 @@
throw new XAException(XAException.XAER_RMERR);
} finally {
if (clean) {
- resourceManager.transactions.remove(new XidWrapper(xid));
+ transactionCompleted(tx);
}
}
}
@@ -319,7 +320,7 @@
if (t instanceof XAException) {
XAException xae = (XAException)t;
if (xae.errorCode == XAException.XAER_RMFAIL || doneOnRb && isRollback(xae)) {
- resourceManager.transactions.remove(new XidWrapper(tx.xid));
+ transactionCompleted(tx);
}
throw xae;
}
@@ -379,6 +380,15 @@
*/
protected abstract void doForget(T tx) throws Exception;
+ /**
+ * This is invoked whenever a transaction has fully completed. Subclasses may override this but
+ * must make sure to always invoke <code>super.transactionCompleted()</code>.
+ *
+ * @param tx the transaction that completed.
+ */
+ protected void transactionCompleted(T tx) {
+ resourceManager.transactions.remove(new XidWrapper(tx.xid));
+ }
/** The resource-manager info */
public static class RMInfo<T extends TxInfo> {
More information about the Mulgara-svn
mailing list