[jboss-svn-commits] JBL Code SVN: r32112 - in labs/jbosstm/trunk/txbridge: src/org/jboss/jbossts/txbridge/outbound and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Mar 16 11:23:58 EDT 2010
Author: jhalliday
Date: 2010-03-16 11:23:56 -0400 (Tue, 16 Mar 2010)
New Revision: 32112
Modified:
labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/BridgeDurableParticipant.java
labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/BridgeVolatileParticipant.java
labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/InboundBridge.java
labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/InboundBridgeManager.java
labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/InboundBridgeRecoveryManager.java
labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/JaxWSTxInboundBridgeHandler.java
labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/outbound/JaxWSTxOutboundBridgeHandler.java
labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/outbound/OutboundBridge.java
labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/outbound/OutboundBridgeManager.java
labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/outbound/OutboundBridgeRecoveryManager.java
labs/jbosstm/trunk/txbridge/tests/build.xml
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestClient.java
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestService.java
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestService.java
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestServiceImpl.java
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestSynchronization.java
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResource.java
labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecoveryHelper.java
Log:
Improve test harness for inbound txbridge. JBTM-44
Modified: labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/BridgeDurableParticipant.java
===================================================================
--- labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/BridgeDurableParticipant.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/BridgeDurableParticipant.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -47,7 +47,7 @@
*/
public class BridgeDurableParticipant implements Durable2PCParticipant, Serializable
{
- private static final Logger log = Logger.getLogger(BridgeDurableParticipant.class);
+ private static final Logger log = Logger.getLogger(BridgeDurableParticipant.class);
/*
* Uniq String used to prefix ids at participant registration,
@@ -60,7 +60,7 @@
*/
public static final int XARESOURCE_FORMAT_ID = 131080;
- private transient volatile XATerminator xaTerminator;
+ private transient volatile XATerminator xaTerminator;
private transient volatile String externalTxId;
@@ -69,7 +69,7 @@
static final long serialVersionUID = -5739871936627778072L;
// Xid not guaranteed Serializable by spec, but our XidImple happens to be
- private volatile Xid xid;
+ private volatile Xid xid;
// Id needed for recovery of the subordinate tx. Uids are likewise Serializable.
private volatile Uid subordinateTransactionId;
@@ -80,14 +80,14 @@
* @param externalTxId the WS-AT Tx identifier
* @param xid the Xid to use when driving the subordinate XA transaction.
*/
- BridgeDurableParticipant(String externalTxId, Xid xid)
+ BridgeDurableParticipant(String externalTxId, Xid xid)
{
- log.trace("BridgeDurableParticipant(TxId="+externalTxId+", Xid="+xid+")");
+ log.trace("BridgeDurableParticipant(TxId="+externalTxId+", Xid="+xid+")");
this.xid = xid;
this.externalTxId = externalTxId;
- xaTerminator = SubordinationManager.getXATerminator();
- }
+ xaTerminator = SubordinationManager.getXATerminator();
+ }
/**
* Serialization hook. Gathers and writes information needed for transaction recovery.
@@ -162,54 +162,57 @@
* @return an indication of whether it can prepare or not.
* @see com.arjuna.wst.Vote
*/
- public Vote prepare() throws WrongStateException, SystemException
- {
- log.trace("prepare(Xid="+xid+")");
+ public Vote prepare() throws WrongStateException, SystemException
+ {
+ log.trace("prepare(Xid="+xid+")");
- try
+ try
{
- // XAResource.XA_OK, XAResource.XA_RDONLY or exception. if RDONLY, don't call commit
- int result = xaTerminator.prepare(xid);
- if(result == XAResource.XA_OK)
+ // XAResource.XA_OK, XAResource.XA_RDONLY or exception. if RDONLY, don't call commit
+ int result = xaTerminator.prepare(xid);
+ if(result == XAResource.XA_OK)
{
- log.debug("prepare on Xid="+xid+" returning Prepared");
- return new Prepared();
- }
+ log.debug("prepare on Xid="+xid+" returning Prepared");
+ return new Prepared();
+ }
else
{
cleanupRefs();
log.debug("prepare on Xid="+xid+" returning ReadOnly");
- return new ReadOnly();
- }
+ return new ReadOnly();
+ }
- }
+ }
catch(XAException e)
{
+ // TODO: this is not necessarily an error. If the subordinate tx is setRollbackOnly
+ // e.g. due to failure of VolatileParticipant.prepare, then it's expected the prepare will fail.
+ // we really need to use XATerminatorExtensions to expose a isSetRollbackOnly...
cleanupRefs();
log.warn("prepare on Xid="+xid+" returning Aborted", e);
- return new Aborted();
- }
+ return new Aborted();
+ }
}
/**
* The participant should make permanent the work that it controls.
- *
+ *
* @throws WrongStateException
* @throws SystemException
*/
public void commit() throws WrongStateException, SystemException
{
- log.trace("commit(Xid="+xid+")");
+ log.trace("commit(Xid="+xid+")");
- try
- {
- xaTerminator.commit(xid, false);
- log.debug("commit on Xid="+xid+" OK");
- }
- catch (XAException e)
- {
- log.error("commit on Xid="+xid+" failed", e);
- }
+ try
+ {
+ xaTerminator.commit(xid, false);
+ log.debug("commit on Xid="+xid+" OK");
+ }
+ catch (XAException e)
+ {
+ log.error("commit on Xid="+xid+" failed", e);
+ }
finally
{
cleanupRefs();
@@ -225,17 +228,17 @@
*/
public void rollback() throws WrongStateException, SystemException
{
- log.trace("rollback(Xid="+xid+")");
+ log.trace("rollback(Xid="+xid+")");
- try
- {
- xaTerminator.rollback(xid);
- log.debug("rollback on Xid="+xid+" OK");
- }
- catch (XAException e)
- {
- log.error("rollback on Xid="+xid+" failed", e);
- }
+ try
+ {
+ xaTerminator.rollback(xid);
+ log.debug("rollback on Xid="+xid+" OK");
+ }
+ catch (XAException e)
+ {
+ log.error("rollback on Xid="+xid+" failed", e);
+ }
finally
{
cleanupRefs();
@@ -248,9 +251,9 @@
* available (has rolled back) then this operation will be invoked by the
* coordination service.
*/
- public void unknown() throws SystemException
+ public void unknown() throws SystemException
{
- log.trace("unknown(Xid="+xid+"): NOT IMPLEMENTED");
+ log.trace("unknown(Xid="+xid+"): NOT IMPLEMENTED");
}
/**
@@ -258,9 +261,9 @@
* transaction it was registered with. If an error occurs (e.g., the
* transaction service is unavailable) then this operation will be invoked.
*/
- public void error() throws SystemException
+ public void error() throws SystemException
{
- log.trace("error(Xid="+xid+"): NOT IMPLEMENTED");
+ log.trace("error(Xid="+xid+"): NOT IMPLEMENTED");
}
public boolean isAwaitingRecovery() {
Modified: labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/BridgeVolatileParticipant.java
===================================================================
--- labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/BridgeVolatileParticipant.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/BridgeVolatileParticipant.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -58,7 +58,7 @@
*/
BridgeVolatileParticipant(String externalTxId, Xid xid)
{
- log.trace("BridgeVolatileParticipant(TxId="+externalTxId+", Xid="+xid+")");
+ log.trace("BridgeVolatileParticipant(TxId="+externalTxId+", Xid="+xid+")");
this.xid = xid;
this.externalTxId = externalTxId;
@@ -92,7 +92,7 @@
if(!xaTerminatorExtensions.beforeCompletion(xid))
{
- log.warn("prepare on Xid="+xid+" failed, setting RollbackOnly");
+ log.warn("prepare on Xid="+xid+" failed, setting RollbackOnly");
inboundBridge.setRollbackOnly();
}
Modified: labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/InboundBridge.java
===================================================================
--- labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/InboundBridge.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/InboundBridge.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -43,12 +43,12 @@
*/
public class InboundBridge
{
- private static final Logger log = Logger.getLogger(InboundBridge.class);
+ private static final Logger log = Logger.getLogger(InboundBridge.class);
/**
* Identifier for the subordinate transaction.
*/
- private final Xid xid;
+ private final Xid xid;
/**
* Create a new InboundBridge to manage the given subordinate JTA transaction.
@@ -57,46 +57,46 @@
* @throws XAException
* @throws SystemException
*/
- InboundBridge(Xid xid) throws XAException, SystemException
+ InboundBridge(Xid xid) throws XAException, SystemException
{
- log.trace("InboundBridge(Xid="+xid+")");
+ log.trace("InboundBridge(Xid="+xid+")");
- this.xid = xid;
+ this.xid = xid;
- getTransaction(); // ensures transaction is initialized
- }
+ getTransaction(); // ensures transaction is initialized
+ }
- /**
- * Associate the JTA transaction to the current Thread.
- * Typically used by a server side inbound handler.
- *
- * @throws XAException
- * @throws SystemException
- * @throws InvalidTransactionException
- */
- public void start() throws XAException, SystemException, InvalidTransactionException
+ /**
+ * Associate the JTA transaction to the current Thread.
+ * Typically used by a server side inbound handler.
+ *
+ * @throws XAException
+ * @throws SystemException
+ * @throws InvalidTransactionException
+ */
+ public void start() throws XAException, SystemException, InvalidTransactionException
{
- log.trace("start(Xid="+xid+")");
+ log.trace("start(Xid="+xid+")");
- Transaction tx = getTransaction();
+ Transaction tx = getTransaction();
- TransactionManager.transactionManager().resume(tx);
- }
+ TransactionManager.transactionManager().resume(tx);
+ }
- /**
- * Disassociate the JTA transaction from the current Thread.
- * Typically used by a server side outbound handler.
- *
- * @throws XAException
- * @throws SystemException
- * @throws InvalidTransactionException
- */
- public void stop() throws XAException, SystemException, InvalidTransactionException
+ /**
+ * Disassociate the JTA transaction from the current Thread.
+ * Typically used by a server side outbound handler.
+ *
+ * @throws XAException
+ * @throws SystemException
+ * @throws InvalidTransactionException
+ */
+ public void stop() throws XAException, SystemException, InvalidTransactionException
{
- log.trace("stop("+xid+")");
+ log.trace("stop("+xid+")");
- TransactionManager.transactionManager().suspend();
- }
+ TransactionManager.transactionManager().suspend();
+ }
public void setRollbackOnly() throws XAException, SystemException
{
@@ -105,28 +105,28 @@
getTransaction().setRollbackOnly();
}
- /**
- * Get the JTA Transaction which corresponds to the Xid of the instance.
- *
- * @return
- * @throws XAException
- * @throws SystemException
- */
- private Transaction getTransaction()
- throws XAException, SystemException
- {
- Transaction tx = SubordinationManager.getTransactionImporter().importTransaction(xid);
+ /**
+ * Get the JTA Transaction which corresponds to the Xid of the instance.
+ *
+ * @return
+ * @throws XAException
+ * @throws SystemException
+ */
+ private Transaction getTransaction()
+ throws XAException, SystemException
+ {
+ Transaction tx = SubordinationManager.getTransactionImporter().importTransaction(xid);
- switch (tx.getStatus())
- {
+ switch (tx.getStatus())
+ {
// TODO: other cases?
- case Status.STATUS_ACTIVE:
+ case Status.STATUS_ACTIVE:
case Status.STATUS_MARKED_ROLLBACK:
- break;
- default:
- throw new IllegalStateException("Transaction not in state ACTIVE");
- }
- return tx;
- }
+ break;
+ default:
+ throw new IllegalStateException("Transaction not in state ACTIVE");
+ }
+ return tx;
+ }
}
Modified: labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/InboundBridgeManager.java
===================================================================
--- labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/InboundBridgeManager.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/InboundBridgeManager.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -52,35 +52,35 @@
*/
public class InboundBridgeManager
{
- private static final Logger log = Logger.getLogger(InboundBridgeManager.class);
+ private static final Logger log = Logger.getLogger(InboundBridgeManager.class);
// maps WS-AT Tx Id to InboundBridge instance.
- private static final ConcurrentMap<String, InboundBridge> inboundBridgeMappings = new ConcurrentHashMap<String, org.jboss.jbossts.txbridge.inbound.InboundBridge>();
+ private static final ConcurrentMap<String, InboundBridge> inboundBridgeMappings = new ConcurrentHashMap<String, org.jboss.jbossts.txbridge.inbound.InboundBridge>();
- /**
- * Return an InboundBridge instance that maps the current Thread's WS transaction context
- * to a JTA context. Control of the latter is provided by the returned instance.
- *
- * @return an InboundBridge corresponding to the calling Thread's current WS-AT transaction context.
- * @throws WrongStateException
- * @throws UnknownTransactionException
- * @throws com.arjuna.wst.SystemException
- * @throws AlreadyRegisteredException
- */
- public static InboundBridge getInboundBridge()
- throws XAException, WrongStateException, UnknownTransactionException,
- com.arjuna.wst.SystemException, javax.transaction.SystemException, AlreadyRegisteredException
- {
- log.trace("getInboundBridge()");
+ /**
+ * Return an InboundBridge instance that maps the current Thread's WS transaction context
+ * to a JTA context. Control of the latter is provided by the returned instance.
+ *
+ * @return an InboundBridge corresponding to the calling Thread's current WS-AT transaction context.
+ * @throws WrongStateException
+ * @throws UnknownTransactionException
+ * @throws com.arjuna.wst.SystemException
+ * @throws AlreadyRegisteredException
+ */
+ public static InboundBridge getInboundBridge()
+ throws XAException, WrongStateException, UnknownTransactionException,
+ com.arjuna.wst.SystemException, javax.transaction.SystemException, AlreadyRegisteredException
+ {
+ log.trace("getInboundBridge()");
- String externalTxId = UserTransactionFactory.userTransaction().toString();
+ String externalTxId = UserTransactionFactory.userTransaction().toString();
if(!inboundBridgeMappings.containsKey(externalTxId)) {
createMapping(externalTxId);
}
- return inboundBridgeMappings.get(externalTxId);
- }
+ return inboundBridgeMappings.get(externalTxId);
+ }
/**
* Return an InboundBridge instance for the specified WS-AT transaction context.
@@ -111,39 +111,39 @@
}
}
- /**
- * Create the JTA transaction mapping and support objects for a given WS transaction context.
- *
- * @param externalTxId The WS-AT tx identifier.
- * @throws WrongStateException
- * @throws UnknownTransactionException
- * @throws com.arjuna.wst.SystemException
- * @throws AlreadyRegisteredException
- */
- private static synchronized void createMapping(String externalTxId)
- throws XAException, WrongStateException, UnknownTransactionException,
- com.arjuna.wst.SystemException, javax.transaction.SystemException, AlreadyRegisteredException
+ /**
+ * Create the JTA transaction mapping and support objects for a given WS transaction context.
+ *
+ * @param externalTxId The WS-AT tx identifier.
+ * @throws WrongStateException
+ * @throws UnknownTransactionException
+ * @throws com.arjuna.wst.SystemException
+ * @throws AlreadyRegisteredException
+ */
+ private static synchronized void createMapping(String externalTxId)
+ throws XAException, WrongStateException, UnknownTransactionException,
+ com.arjuna.wst.SystemException, javax.transaction.SystemException, AlreadyRegisteredException
{
- log.trace("createMapping(externalTxId="+externalTxId+")");
+ log.trace("createMapping(externalTxId="+externalTxId+")");
- if(inboundBridgeMappings.containsKey(externalTxId)) {
- return;
- }
+ if(inboundBridgeMappings.containsKey(externalTxId)) {
+ return;
+ }
TransactionManager transactionManager = TransactionManagerFactory.transactionManager();
// Xid for driving the subordinate,
// shared by the bridge (thread assoc) and Participant (termination via XATerminator)
- Xid xid = XATxConverter.getXid(new Uid(), false, BridgeDurableParticipant.XARESOURCE_FORMAT_ID);
+ Xid xid = XATxConverter.getXid(new Uid(), false, BridgeDurableParticipant.XARESOURCE_FORMAT_ID);
- BridgeDurableParticipant bridgeDurableParticipant = new BridgeDurableParticipant(externalTxId, xid);
+ BridgeDurableParticipant bridgeDurableParticipant = new BridgeDurableParticipant(externalTxId, xid);
// construct the participantId in such as way as we can recognise it at recovery time:
String participantId = org.jboss.jbossts.txbridge.inbound.BridgeDurableParticipant.TYPE_IDENTIFIER+new Uid().toString();
- transactionManager.enlistForDurableTwoPhase(bridgeDurableParticipant, participantId);
+ transactionManager.enlistForDurableTwoPhase(bridgeDurableParticipant, participantId);
BridgeVolatileParticipant bridgeVolatileParticipant = new BridgeVolatileParticipant(externalTxId, xid);
transactionManager.enlistForVolatileTwoPhase(bridgeVolatileParticipant, new Uid().toString());
inboundBridgeMappings.put(externalTxId, new InboundBridge(xid));
- }
+ }
}
\ No newline at end of file
Modified: labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/InboundBridgeRecoveryManager.java
===================================================================
--- labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/InboundBridgeRecoveryManager.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/InboundBridgeRecoveryManager.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -81,7 +81,7 @@
xtsATRecoveryManager.unregisterRecoveryModule(this);
acRecoveryManager.removeModule(this, false);
-
+
XARecoveryModule xaRecoveryModule = getXARecoveryModule();
xaRecoveryModule.removeXAResourceOrphanFilter(this);
}
@@ -256,7 +256,7 @@
* Used to identify inbound bridged Xids in either the RM log (when called by XARecoveryModule) or
* the JCA subordinate tx log (when called internally from this class) which have or have not got a
* remaining transaction that may still drive them to completion.
- *
+ *
* @param xid The in-doubt xid.
* @return a Vote on the handling of the xid (to roll it back or not).
*/
Modified: labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/JaxWSTxInboundBridgeHandler.java
===================================================================
--- labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/JaxWSTxInboundBridgeHandler.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/inbound/JaxWSTxInboundBridgeHandler.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -42,101 +42,101 @@
*/
public class JaxWSTxInboundBridgeHandler implements Handler
{
- private static final Logger log = Logger.getLogger(JaxWSTxInboundBridgeHandler.class);
+ private static final Logger log = Logger.getLogger(JaxWSTxInboundBridgeHandler.class);
- /**
- * Process a message. Determines if it is inbound or outbound and dispatches accordingly.
- *
- * @param msgContext the context to process
- * @return true on success, false on error
- */
- public boolean handleMessage(MessageContext msgContext)
- {
- log.trace("handleMessage()");
+ /**
+ * Process a message. Determines if it is inbound or outbound and dispatches accordingly.
+ *
+ * @param msgContext the context to process
+ * @return true on success, false on error
+ */
+ public boolean handleMessage(MessageContext msgContext)
+ {
+ log.trace("handleMessage()");
- Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
- if (outbound == null)
- throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+ Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+ if (outbound == null)
+ throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
- return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
- }
+ return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
+ }
- /**
- * Tidy up the Transaction/Thread association before faults are thrown back to the client.
- *
- * @param messageContext unused
- * @return true on success, false on error
- */
- public boolean handleFault(MessageContext messageContext)
- {
- log.trace("handleFault()");
+ /**
+ * Tidy up the Transaction/Thread association before faults are thrown back to the client.
+ *
+ * @param messageContext unused
+ * @return true on success, false on error
+ */
+ public boolean handleFault(MessageContext messageContext)
+ {
+ log.trace("handleFault()");
- return suspendTransaction();
- }
+ return suspendTransaction();
+ }
- public void close(MessageContext messageContext)
- {
- log.trace("close()");
- }
+ public void close(MessageContext messageContext)
+ {
+ log.trace("close()");
+ }
- /**
- * Process inbound messages by mapping the WS transaction context
- * to a JTA one and associating the latter to the current Thread.
- *
- * @param msgContext unused
- * @return true on success, false on error
- */
- protected boolean handleInbound(MessageContext msgContext)
- {
- log.trace("handleInbound()");
+ /**
+ * Process inbound messages by mapping the WS transaction context
+ * to a JTA one and associating the latter to the current Thread.
+ *
+ * @param msgContext unused
+ * @return true on success, false on error
+ */
+ protected boolean handleInbound(MessageContext msgContext)
+ {
+ log.trace("handleInbound()");
- try
- {
- InboundBridge inboundBridge = org.jboss.jbossts.txbridge.inbound.InboundBridgeManager.getInboundBridge();
- inboundBridge.start();
- }
- catch (Exception e)
- {
- log.error(e);
- return false;
- }
+ try
+ {
+ InboundBridge inboundBridge = org.jboss.jbossts.txbridge.inbound.InboundBridgeManager.getInboundBridge();
+ inboundBridge.start();
+ }
+ catch (Exception e)
+ {
+ log.error(e);
+ return false;
+ }
- return true;
- }
+ return true;
+ }
- /**
- * Tidy up the Transaction/Thread association before returning a message to the client.
- *
- * @param msgContext unused
- * @return true on success, false on error
- */
- protected boolean handleOutbound(MessageContext msgContext)
+ /**
+ * Tidy up the Transaction/Thread association before returning a message to the client.
+ *
+ * @param msgContext unused
+ * @return true on success, false on error
+ */
+ protected boolean handleOutbound(MessageContext msgContext)
{
- log.trace("handleOutbound()");
+ log.trace("handleOutbound()");
- return suspendTransaction();
- }
+ return suspendTransaction();
+ }
- /**
- * Break the association between the JTA transaction context and the calling Thread.
+ /**
+ * Break the association between the JTA transaction context and the calling Thread.
*
* @return true on success, false on error
- */
- private boolean suspendTransaction()
+ */
+ private boolean suspendTransaction()
{
- log.trace("suspendTransaction()");
+ log.trace("suspendTransaction()");
- try
- {
- org.jboss.jbossts.txbridge.inbound.InboundBridge inboundBridge = InboundBridgeManager.getInboundBridge();
- inboundBridge.stop();
- }
- catch (Exception e)
- {
- log.error(e);
+ try
+ {
+ org.jboss.jbossts.txbridge.inbound.InboundBridge inboundBridge = InboundBridgeManager.getInboundBridge();
+ inboundBridge.stop();
+ }
+ catch (Exception e)
+ {
+ log.error(e);
return false;
- }
+ }
return true;
- }
+ }
}
\ No newline at end of file
Modified: labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/outbound/JaxWSTxOutboundBridgeHandler.java
===================================================================
--- labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/outbound/JaxWSTxOutboundBridgeHandler.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/outbound/JaxWSTxOutboundBridgeHandler.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -42,101 +42,101 @@
*/
public class JaxWSTxOutboundBridgeHandler implements Handler
{
- private static final Logger log = Logger.getLogger(JaxWSTxOutboundBridgeHandler.class);
+ private static final Logger log = Logger.getLogger(JaxWSTxOutboundBridgeHandler.class);
- /**
- * Process a message. Determines if it is inbound or outbound and dispatches accordingly.
- *
- * @param msgContext the context to process
- * @return true on success, false on error
- */
- public boolean handleMessage(MessageContext msgContext)
- {
- log.trace("handleMessage()");
+ /**
+ * Process a message. Determines if it is inbound or outbound and dispatches accordingly.
+ *
+ * @param msgContext the context to process
+ * @return true on success, false on error
+ */
+ public boolean handleMessage(MessageContext msgContext)
+ {
+ log.trace("handleMessage()");
- Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
- if (outbound == null)
- throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+ Boolean outbound = (Boolean)msgContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
+ if (outbound == null)
+ throw new IllegalStateException("Cannot obtain required property: " + MessageContext.MESSAGE_OUTBOUND_PROPERTY);
- return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
- }
+ return outbound ? handleOutbound(msgContext) : handleInbound(msgContext);
+ }
- /**
- * Tidy up the Transaction/Thread association before faults are thrown back to the client.
- *
- * @param messageContext unused
- * @return true on success, false on error
- */
- public boolean handleFault(MessageContext messageContext)
- {
- log.trace("handleFault()");
+ /**
+ * Tidy up the Transaction/Thread association before faults are thrown back to the client.
+ *
+ * @param messageContext unused
+ * @return true on success, false on error
+ */
+ public boolean handleFault(MessageContext messageContext)
+ {
+ log.trace("handleFault()");
- return suspendTransaction();
- }
+ return suspendTransaction();
+ }
- public void close(MessageContext messageContext)
- {
- log.trace("close()");
- }
+ public void close(MessageContext messageContext)
+ {
+ log.trace("close()");
+ }
- /**
+ /**
* Tidy up the Transaction/Thread association before returning a message to the client.
- *
- * @param msgContext unused
- * @return true on success, false on error
- */
- protected boolean handleInbound(MessageContext msgContext)
- {
- log.trace("handleInbound()");
+ *
+ * @param msgContext unused
+ * @return true on success, false on error
+ */
+ protected boolean handleInbound(MessageContext msgContext)
+ {
+ log.trace("handleInbound()");
- return suspendTransaction();
- }
+ return suspendTransaction();
+ }
- /**
+ /**
* Process outbound messages by mapping the JTA transaction context
* to a WS-AT one and associating the latter to the current Thread.
- *
- * @param msgContext unused
- * @return true on success, false on error
- */
- protected boolean handleOutbound(MessageContext msgContext)
+ *
+ * @param msgContext unused
+ * @return true on success, false on error
+ */
+ protected boolean handleOutbound(MessageContext msgContext)
{
- log.trace("handleOutbound()");
+ log.trace("handleOutbound()");
- try
- {
- OutboundBridge outboundBridge = OutboundBridgeManager.getOutboundBridge();
- outboundBridge.start();
- }
- catch (Exception e)
- {
- log.error(e);
- return false;
- }
+ try
+ {
+ OutboundBridge outboundBridge = OutboundBridgeManager.getOutboundBridge();
+ outboundBridge.start();
+ }
+ catch (Exception e)
+ {
+ log.error(e);
+ return false;
+ }
- return true;
- }
+ return true;
+ }
- /**
- * Break the association between the WS-AT transaction context and the calling Thread.
+ /**
+ * Break the association between the WS-AT transaction context and the calling Thread.
*
* @return true on success, false on error
- */
- private boolean suspendTransaction()
+ */
+ private boolean suspendTransaction()
{
- log.trace("suspendTransaction()");
+ log.trace("suspendTransaction()");
- try
- {
- OutboundBridge outboundBridge = OutboundBridgeManager.getOutboundBridge();
- outboundBridge.stop();
- }
- catch (Exception e)
- {
- log.error(e);
+ try
+ {
+ OutboundBridge outboundBridge = OutboundBridgeManager.getOutboundBridge();
+ outboundBridge.stop();
+ }
+ catch (Exception e)
+ {
+ log.error(e);
return false;
- }
+ }
return true;
- }
+ }
}
\ No newline at end of file
Modified: labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/outbound/OutboundBridge.java
===================================================================
--- labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/outbound/OutboundBridge.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/outbound/OutboundBridge.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -66,12 +66,12 @@
*/
public void start() throws UnknownTransactionException, SystemException
{
- log.trace("start(BridgeWrapper="+bridgeWrapper+")");
+ log.trace("start(BridgeWrapper="+bridgeWrapper+")");
TxContext txContext = bridgeWrapper.getContext();
TransactionManagerFactory.transactionManager().resume(txContext);
- }
+ }
/**
* Disassociate the WS-AT transaction from the current Thread.
Modified: labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/outbound/OutboundBridgeManager.java
===================================================================
--- labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/outbound/OutboundBridgeManager.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/outbound/OutboundBridgeManager.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -62,9 +62,9 @@
*
* @return as OutboundBridge corresponding to the calling Thread's current JTA transaction context.
*/
- public static org.jboss.jbossts.txbridge.outbound.OutboundBridge getOutboundBridge()
- {
- log.trace("getOutboundBridge()");
+ public static org.jboss.jbossts.txbridge.outbound.OutboundBridge getOutboundBridge()
+ {
+ log.trace("getOutboundBridge()");
try
{
@@ -85,7 +85,7 @@
}
return null;
- }
+ }
/**
* Remove the mapping for the given externalTxId. This should be called for gc when the tx is finished.
Modified: labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/outbound/OutboundBridgeRecoveryManager.java
===================================================================
--- labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/outbound/OutboundBridgeRecoveryManager.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/src/org/jboss/jbossts/txbridge/outbound/OutboundBridgeRecoveryManager.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -79,6 +79,6 @@
BridgeWrapper[] bridgeWrappers = BridgeWrapper.scan(OutboundBridgeManager.BRIDGEWRAPPER_PREFIX);
// TODO: do something useful with the results.
-
+
}
}
Modified: labs/jbosstm/trunk/txbridge/tests/build.xml
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/build.xml 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/tests/build.xml 2010-03-16 15:23:56 UTC (rev 32112)
@@ -153,6 +153,7 @@
overwrite="true"/>
</target>
+ <!-- http://localhost:8080/txbridge-outbound-tests-client/testclient -->
<target name="deploy-outbound-client" depends="dist" description="deploy Servlet to JBossAS">
<copy file="${build}/txbridge-outbound-tests-client.war"
todir="${jbossas.home}/server/${jbossas.server}/deploy"
Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestClient.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestClient.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestClient.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -84,10 +84,11 @@
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
- String param = request.getParameter("param");
+ String outcome = request.getParameter("outcome");
+ String failInBeforeCompletion = request.getParameter("failInBeforeCompletion");
+ String prepareXAErrorCode = request.getParameter("prepareXAErrorCode");
+
- log.info("param: "+param);
-
try
{
com.arjuna.mw.wst11.UserTransaction ut = UserTransactionFactory.userTransaction();
@@ -102,13 +103,26 @@
//////////////////////
- testService.doStuff();
+ if("true".equals(failInBeforeCompletion)) {
+ testService.arrangeBeforeCompletionFailure();
+ }
+ if(prepareXAErrorCode != null) {
+ testService.arrangeXAResourcePrepareXAException(Integer.parseInt(prepareXAErrorCode));
+ }
+
+ testService.doTestResourceEnlistment();
+ testService.doNothing();
+
//////////////////////
- log.info("calling commit on the transaction...");
+ log.info("calling "+outcome+" on the transaction...");
- ut.commit();
+ if("commit".equals(outcome)) {
+ ut.commit();
+ } else {
+ ut.rollback();
+ }
}
catch (final TransactionRolledBackException tre)
{
Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestService.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestService.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/client/TestService.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -32,5 +32,11 @@
@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface TestService
{
- public void doStuff();
+ public void doTestResourceEnlistment();
+
+ public void doNothing();
+
+ public void arrangeBeforeCompletionFailure();
+
+ public void arrangeXAResourcePrepareXAException(int xaErrorCode);
}
Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestService.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestService.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestService.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -27,5 +27,11 @@
*/
public interface TestService
{
- public void doStuff();
+ public void doTestResourceEnlistment();
+
+ public void doNothing();
+
+ public void arrangeBeforeCompletionFailure();
+
+ public void arrangeXAResourcePrepareXAException(int xaErrorCode);
}
Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestServiceImpl.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestServiceImpl.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/service/TestServiceImpl.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -33,6 +33,7 @@
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAException;
/**
@@ -50,19 +51,54 @@
{
private static Logger log = Logger.getLogger(TestServiceImpl.class);
+ private boolean arrangeBeforeCompletionFailure = false;
+ private int xaErrorCode = 0;
+
@Override
@WebMethod
- public void doStuff()
+ public void doTestResourceEnlistment()
{
- log.trace("doStuff()");
+ log.trace("doTestResourceEnlistment()");
TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
- try {
- tm.getTransaction().registerSynchronization(new TestSynchronization());
- tm.getTransaction().enlistResource(new TestXAResource());
+ try
+ {
+ TestSynchronization testSynchronization = new TestSynchronization();
+ if(arrangeBeforeCompletionFailure) {
+ testSynchronization.setFailInBeforeCompletion(true);
+ }
+ tm.getTransaction().registerSynchronization(testSynchronization);
+
+ TestXAResource testXAResource = new TestXAResource();
+ if(xaErrorCode != 0) {
+ testXAResource.setPrepareException(new XAException(xaErrorCode));
+ }
+ tm.getTransaction().enlistResource(testXAResource);
+
} catch(Exception e) {
- log.error("could not enlist resource", e);
+ log.error("could not enlist", e);
}
}
+
+ @Override
+ @WebMethod
+ public void doNothing() {
+ log.trace("doNothing()");
+ }
+
+ @Override
+ @WebMethod
+ public void arrangeBeforeCompletionFailure() {
+ log.trace("arrangeBeforeCompletionFailure()");
+ arrangeBeforeCompletionFailure = true;
+ }
+
+ @Override
+ @WebMethod
+ public void arrangeXAResourcePrepareXAException(int xaErrorCode) {
+ log.trace("arrangeXAResourcePrepareXAException("+xaErrorCode+")");
+ this.xaErrorCode = xaErrorCode;
+ }
+
}
\ No newline at end of file
Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestSynchronization.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestSynchronization.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestSynchronization.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -36,6 +36,8 @@
private boolean beforeCompletionDone = false;
private boolean afterCompletionDone = false;
+ private boolean failInBeforeCompletion = false;
+
public boolean isBeforeCompletionDone()
{
return beforeCompletionDone;
@@ -46,6 +48,16 @@
return afterCompletionDone;
}
+ public boolean isFailInBeforeCompletion()
+ {
+ return failInBeforeCompletion;
+ }
+
+ public void setFailInBeforeCompletion(boolean failInBeforeCompletion)
+ {
+ this.failInBeforeCompletion = failInBeforeCompletion;
+ }
+
public void beforeCompletion() {
if(beforeCompletionDone) {
log.trace("beforeCompletion called more than once");
@@ -54,6 +66,11 @@
beforeCompletionDone = true;
log.trace("TestSynchronization.beforeCompletion()");
+
+ if(failInBeforeCompletion) {
+ log.trace("failing in beforeCompletion");
+ throw new RuntimeException("failed in beforeCompletion");
+ }
}
public void afterCompletion(int i) {
Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResource.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResource.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResource.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -40,6 +40,7 @@
private Xid currentXid;
private int prepareReturnValue = XAResource.XA_OK;
+ private XAException prepareException = null;
private XAException commitException = null;
public int getPrepareReturnValue()
@@ -52,6 +53,16 @@
this.prepareReturnValue = prepareReturnValue;
}
+ public XAException getPrepareException()
+ {
+ return prepareException;
+ }
+
+ public void setPrepareException(XAException prepareException)
+ {
+ this.prepareException = prepareException;
+ }
+
public XAException getCommitException()
{
return commitException;
@@ -101,6 +112,12 @@
public int prepare(Xid xid) throws XAException {
log.trace("TestXAResource.prepare(Xid="+xid+") returning "+prepareReturnValue);
+
+ if(prepareException != null) {
+ log.trace("prepare throwing XAException "+prepareException.errorCode);
+ throw prepareException;
+ }
+
if(prepareReturnValue == XA_OK) {
TestXAResourceRecoveryHelper.getInstance().logPrepared(xid);
}
Modified: labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecoveryHelper.java
===================================================================
--- labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecoveryHelper.java 2010-03-16 15:17:28 UTC (rev 32111)
+++ labs/jbosstm/trunk/txbridge/tests/src/org/jboss/jbossts/txbridge/tests/inbound/utility/TestXAResourceRecoveryHelper.java 2010-03-16 15:23:56 UTC (rev 32112)
@@ -130,7 +130,7 @@
if(preparedXids.remove(xid)) {
writeToDisk();
} else {
- throw new XAException(XAException.XAER_NOTA);
+ log.trace("no log present for "+xid);
}
}
}
More information about the jboss-svn-commits
mailing list