[jboss-svn-commits] JBL Code SVN: r37602 - in labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example: server and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Oct 19 05:20:22 EDT 2011


Author: tomjenkinson
Date: 2011-10-19 05:20:21 -0400 (Wed, 19 Oct 2011)
New Revision: 37602

Modified:
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/ExampleDistributedJTATestCase.java
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/LocalServer.java
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/RemoteServer.java
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResource.java
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java
Log:
JBTM-895 updated to add more documentation to the example

Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/ExampleDistributedJTATestCase.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/ExampleDistributedJTATestCase.java	2011-10-19 08:51:06 UTC (rev 37601)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/ExampleDistributedJTATestCase.java	2011-10-19 09:20:21 UTC (rev 37602)
@@ -41,6 +41,7 @@
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 
+import org.jboss.tm.TransactionTimeoutConfiguration;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -71,8 +72,8 @@
 	}
 
 	@Test
-	public void testMigrateTransaction() throws NotSupportedException, SystemException, IllegalStateException, RollbackException,
-			InvalidTransactionException, XAException, SecurityException, HeuristicMixedException, HeuristicRollbackException {
+	public void testMigrateTransaction() throws NotSupportedException, SystemException, IllegalStateException, RollbackException, InvalidTransactionException,
+			XAException, SecurityException, HeuristicMixedException, HeuristicRollbackException {
 
 		File file = new File(System.getProperty("user.dir") + "/tmp/");
 		if (file.exists()) {
@@ -121,24 +122,23 @@
 		TransactionManager transactionManager = originalServer.getTransactionManager();
 		transactionManager.setTransactionTimeout(startingTimeout);
 		transactionManager.begin();
+
 		Transaction originalTransaction = transactionManager.getTransaction();
-		int remainingTimeout = (int) (originalServer.getTimeLeftBeforeTransactionTimeout() / 1000);
-		Transaction transaction = transactionManager.getTransaction();
-		transaction.registerSynchronization(new TestSynchronization(originalServer.getNodeName()));
-		transaction.enlistResource(new TestResource(counter, originalServer.getNodeName(), false));
+		originalTransaction.registerSynchronization(new TestSynchronization(originalServer.getNodeName()));
+		originalTransaction.enlistResource(new TestResource(counter, originalServer.getNodeName(), false));
 
 		if (!nodesToFlowTo.isEmpty()) {
 			Integer nextServerNodeName = nodesToFlowTo.get(0);
 
 			// FLOW THE TRANSACTION
-			remainingTimeout = (int) (originalServer.getTimeLeftBeforeTransactionTimeout() / 1000);
+			int remainingTimeout = (int) (((TransactionTimeoutConfiguration) transactionManager).getTimeLeftBeforeTransactionTimeout(false) / 1000);
 
 			// SUSPEND THE TRANSACTION
 			Xid currentXid = originalServer.getCurrentXid();
 			originalServer.storeRootTransaction();
 			transactionManager.suspend();
 			boolean proxyRequired = performTransactionalWork(counter, nodesToFlowTo, remainingTimeout, currentXid);
-			transactionManager.resume(transaction);
+			transactionManager.resume(originalTransaction);
 
 			// Create a proxy for the new server if necessary, this can orphan
 			// the remote server but XA recovery will handle that on the remote
@@ -148,8 +148,8 @@
 			// transactions and performance issues
 			if (proxyRequired) {
 				XAResource proxyXAResource = originalServer.generateProxyXAResource(lookupProvider, originalServer.getNodeName(), nextServerNodeName);
-				transaction.enlistResource(proxyXAResource);
-				transaction.registerSynchronization(originalServer.generateProxySynchronization(lookupProvider, originalServer.getNodeName(),
+				originalTransaction.enlistResource(proxyXAResource);
+				originalTransaction.registerSynchronization(originalServer.generateProxySynchronization(lookupProvider, originalServer.getNodeName(),
 						nextServerNodeName, currentXid));
 			}
 			originalServer.removeRootTransaction(currentXid);
@@ -178,7 +178,7 @@
 			Integer nextServerNodeName = nodesToFlowTo.get(0);
 
 			// FLOW THE TRANSACTION
-			remainingTimeout = (int) (currentServer.getTimeLeftBeforeTransactionTimeout() / 1000);
+			remainingTimeout = (int) (((TransactionTimeoutConfiguration) transactionManager).getTimeLeftBeforeTransactionTimeout(false) / 1000);
 
 			// SUSPEND THE TRANSACTION
 			Xid currentXid = currentServer.getCurrentXid();
@@ -186,12 +186,6 @@
 			boolean proxyRequired = performTransactionalWork(counter, nodesToFlowTo, remainingTimeout, currentXid);
 			transactionManager.resume(transaction);
 
-			// Create a proxy for the new server if necessary, this can orphan
-			// the remote server but XA recovery will handle that on the remote
-			// server
-			// The alternative is to always create a proxy but this is a
-			// performance drain and will result in multiple subordinate
-			// transactions and performance issues
 			if (proxyRequired) {
 				XAResource proxyXAResource = currentServer.generateProxyXAResource(lookupProvider, currentServer.getNodeName(), nextServerNodeName);
 				transaction.enlistResource(proxyXAResource);

Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/LocalServer.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/LocalServer.java	2011-10-19 08:51:06 UTC (rev 37601)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/LocalServer.java	2011-10-19 09:20:21 UTC (rev 37602)
@@ -44,10 +44,6 @@
 
 	public TransactionManager getTransactionManager() throws NotSupportedException, SystemException;
 
-	public void doRecoveryManagerScan();
-
-	public long getTimeLeftBeforeTransactionTimeout() throws RollbackException;
-
 	public void storeRootTransaction() throws SystemException;
 
 	public void removeRootTransaction(Xid toMigrate);
@@ -64,6 +60,4 @@
 	public Xid extractXid(XAResource proxyXAResource);
 
 	public Xid getCurrentXid() throws SystemException;
-
-	public CompletionCounter getCompletionCounter();
 }

Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/RemoteServer.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/RemoteServer.java	2011-10-19 08:51:06 UTC (rev 37601)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/RemoteServer.java	2011-10-19 09:20:21 UTC (rev 37602)
@@ -27,8 +27,6 @@
 
 public interface RemoteServer {
 
-	public void setOffline(boolean offline);
-
 	public int propagatePrepare(Xid xid) throws XAException, DummyRemoteException;
 
 	public void propagateCommit(Xid xid) throws XAException, DummyRemoteException;

Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResource.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResource.java	2011-10-19 08:51:06 UTC (rev 37601)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResource.java	2011-10-19 09:20:21 UTC (rev 37602)
@@ -35,10 +35,13 @@
 import org.jboss.tm.XAResourceWrapper;
 
 import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
 import com.arjuna.jta.distributed.example.server.DummyRemoteException;
 import com.arjuna.jta.distributed.example.server.LookupProvider;
 
+/**
+ * I chose for this class to implement XAResourceWrapper so that I can provide a
+ * name to the Transaction manager for it to store in its XID.
+ */
 public class ProxyXAResource implements XAResource, XAResourceWrapper {
 
 	private int transactionTimeout;
@@ -48,12 +51,27 @@
 	private LookupProvider lookupProvider;
 	private Xid xid;
 
+	/**
+	 * Create a new proxy to the remote server.
+	 * 
+	 * @param lookupProvider
+	 * @param localServerName
+	 * @param remoteServerName
+	 */
 	public ProxyXAResource(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName) {
 		this.lookupProvider = lookupProvider;
 		this.localServerName = localServerName;
 		this.remoteServerName = remoteServerName;
 	}
 
+	/**
+	 * Used by recovery
+	 * 
+	 * @param lookupProvider
+	 * @param localServerName
+	 * @param file
+	 * @throws IOException
+	 */
 	public ProxyXAResource(LookupProvider lookupProvider, Integer localServerName, File file) throws IOException {
 		this.lookupProvider = lookupProvider;
 		this.localServerName = localServerName;
@@ -85,22 +103,37 @@
 		};
 	}
 
+	/**
+	 * Store the XID.
+	 */
 	@Override
 	public void start(Xid xid, int flags) throws XAException {
 		System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_START   [" + xid + "]");
 		this.xid = xid;
 	}
 
+	/**
+	 * Reference the XID.
+	 */
 	@Override
 	public void end(Xid xid, int flags) throws XAException {
 		System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_END     [" + xid + "]");
 		this.xid = null;
 	}
 
+	/**
+	 * Prepare the resource, save the XID locally first, the propagate the
+	 * prepare. This ensures that in recovery we know the XID to ask a remote
+	 * server about.
+	 */
 	@Override
 	public synchronized int prepare(Xid xid) throws XAException {
 		System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_PREPARE [" + xid + "]");
 
+		// Persist a proxy for the remote server this can mean we try to recover
+		// a transaction at a remote server that did not get chance to
+		// prepare but the alternative is to orphan a prepared server
+
 		try {
 			File dir = new File(System.getProperty("user.dir") + "/tmp/ProxyXAResource/" + localServerName + "/");
 			dir.mkdirs();
@@ -118,18 +151,13 @@
 			throw new XAException(XAException.XAER_RMERR);
 		}
 
-		ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
 		try {
-			Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
 			int propagatePrepare = lookupProvider.lookup(remoteServerName).propagatePrepare(xid);
 			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_PREPARED");
 			return propagatePrepare;
 		} catch (DummyRemoteException ce) {
 			throw new XAException(XAException.XA_RETRY);
-		} finally {
-			Thread.currentThread().setContextClassLoader(contextClassLoader);
 		}
-
 	}
 
 	/**
@@ -139,15 +167,11 @@
 	public synchronized void commit(Xid xid, boolean onePhase) throws XAException {
 		System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_COMMIT  [" + xid + "]");
 
-		ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
 		try {
-			Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
 			lookupProvider.lookup(remoteServerName).propagateCommit(xid);
 			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_COMMITED");
 		} catch (DummyRemoteException ce) {
 			throw new XAException(XAException.XA_RETRY);
-		} finally {
-			Thread.currentThread().setContextClassLoader(contextClassLoader);
 		}
 
 		if (file != null) {
@@ -158,15 +182,11 @@
 	@Override
 	public synchronized void rollback(Xid xid) throws XAException {
 		System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_ROLLBACK[" + xid + "]");
-		ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
 		try {
-			Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
 			lookupProvider.lookup(remoteServerName).propagateRollback(xid);
 			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_ROLLBACKED");
 		} catch (DummyRemoteException ce) {
 			throw new XAException(XAException.XA_RETRY);
-		} finally {
-			Thread.currentThread().setContextClassLoader(contextClassLoader);
 		}
 
 		if (file != null) {
@@ -174,6 +194,16 @@
 		}
 	}
 
+	/**
+	 * This will ensure that the remote server has loaded the subordinate
+	 * transaction.
+	 * 
+	 * @return It returns the proxies view of the XID state, returning the
+	 *         remote servers view of the XID would present an XID to the local
+	 *         server that it knows nothing about and indeed potentially the
+	 *         remote server does not have a corresponding record of the XID in
+	 *         case of failure during prepare.
+	 */
 	@Override
 	public Xid[] recover(int flag) throws XAException {
 		Xid[] recovered = null;
@@ -187,14 +217,10 @@
 		}
 
 		if (this.xid != null) {
-			ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
 			try {
-				Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
 				recovered = lookupProvider.lookup(remoteServerName).propagateRecover(xid.getFormatId(), xid.getGlobalTransactionId(), flag);
 			} catch (DummyRemoteException ce) {
 				throw new XAException(XAException.XA_RETRY);
-			} finally {
-				Thread.currentThread().setContextClassLoader(contextClassLoader);
 			}
 		}
 
@@ -218,15 +244,11 @@
 	@Override
 	public void forget(Xid xid) throws XAException {
 		System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_FORGET  [" + xid + "]");
-		ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
 		try {
-			Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
 			lookupProvider.lookup(remoteServerName).propagateForget(xid);
 			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_FORGETED[" + xid + "]");
 		} catch (DummyRemoteException ce) {
 			throw new XAException(XAException.XA_RETRY);
-		} finally {
-			Thread.currentThread().setContextClassLoader(contextClassLoader);
 		}
 	}
 
@@ -253,7 +275,7 @@
 	}
 
 	/**
-	 * I don't think this is used by TM.
+	 * Not used by the TM.
 	 */
 	@Override
 	public XAResource getResource() {
@@ -261,7 +283,7 @@
 	}
 
 	/**
-	 * I don't think this is used by TM.
+	 * Not used by the TM.
 	 */
 	@Override
 	public String getProductName() {
@@ -269,16 +291,20 @@
 	}
 
 	/**
-	 * I don't think this is used by TM.
+	 * Not used by the TM.
 	 */
 	@Override
 	public String getProductVersion() {
 		return null;
 	}
 
+	/**
+	 * This allows the proxy to contain meaningful information in the XID in
+	 * case of failure to recover.
+	 */
 	@Override
 	public String getJndiName() {
-		return "ProxyXAResource";
+		return "ProxyXAResource: " + localServerName + " " + remoteServerName;
 	}
 
 	public Xid getXid() {

Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java	2011-10-19 08:51:06 UTC (rev 37601)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java	2011-10-19 09:20:21 UTC (rev 37602)
@@ -30,7 +30,6 @@
 import java.util.Map;
 
 import javax.transaction.InvalidTransactionException;
-import javax.transaction.RollbackException;
 import javax.transaction.Synchronization;
 import javax.transaction.SystemException;
 import javax.transaction.Transaction;
@@ -39,8 +38,6 @@
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 
-import org.jboss.tm.TransactionTimeoutConfiguration;
-
 import com.arjuna.ats.arjuna.common.CoordinatorEnvironmentBean;
 import com.arjuna.ats.arjuna.common.CoreEnvironmentBean;
 import com.arjuna.ats.arjuna.common.CoreEnvironmentBeanException;
@@ -70,48 +67,14 @@
 	private int nodeName;
 	private RecoveryManagerService recoveryManagerService;
 	private TransactionManagerService transactionManagerService;
-	private boolean offline;
-	private LookupProvider lookupProvider;
 	private Map<SubordinateXidImple, TransactionImple> transactions = new HashMap<SubordinateXidImple, TransactionImple>();
 	private RecoveryManager _recoveryManager;
 	private CompletionCounter counter;
 
 	public void initialise(LookupProvider lookupProvider, Integer nodeName) throws CoreEnvironmentBeanException, IOException, SecurityException,
 			NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
-		this.lookupProvider = lookupProvider;
 		this.nodeName = nodeName;
-		this.counter = new CompletionCounter() {
-			private int commitCount = 0;
-			private int rollbackCount = 0;
 
-			@Override
-			public void incrementCommit() {
-				commitCount++;
-
-			}
-
-			@Override
-			public void incrementRollback() {
-				rollbackCount++;
-			}
-
-			@Override
-			public int getCommitCount() {
-				return commitCount;
-			}
-
-			@Override
-			public int getRollbackCount() {
-				return rollbackCount;
-			}
-
-			@Override
-			public void resetCounters() {
-				commitCount = 0;
-				rollbackCount = 0;
-			}
-		};
-
 		RecoveryEnvironmentBean recoveryEnvironmentBean = com.arjuna.ats.arjuna.common.recoveryPropertyManager.getRecoveryEnvironmentBean();
 		recoveryEnvironmentBean.setRecoveryBackoffPeriod(1);
 
@@ -180,37 +143,18 @@
 		recoveryManagerService.create();
 		recoveryManagerService.addXAResourceRecovery(new ProxyXAResourceRecovery(lookupProvider, nodeName));
 		recoveryManagerService.addXAResourceRecovery(new TestResourceRecovery(counter, nodeName));
-		
-		// recoveryManagerService.start();
-		_recoveryManager = RecoveryManager.manager();
-		RecoveryManager.manager().initialize();
 
+		recoveryManagerService.start();
+
 		transactionManagerService = new TransactionManagerService();
 		TxControl txControl = new com.arjuna.ats.arjuna.coordinator.TxControl();
 		transactionManagerService.setJbossXATerminator(new com.arjuna.ats.internal.jbossatx.jta.jca.XATerminator());
 		transactionManagerService
 				.setTransactionSynchronizationRegistry(new com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple());
 		transactionManagerService.create();
-
-		// Field safetyIntervalMillis =
-		// RecoveryXids.class.getDeclaredField("safetyIntervalMillis");
-		// safetyIntervalMillis.setAccessible(true);
-		// Field modifiersField = Field.class.getDeclaredField("modifiers");
-		// modifiersField.setAccessible(true);
-		// safetyIntervalMillis.set(null, 0);
 	}
 
 	@Override
-	public void doRecoveryManagerScan() {
-		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-		ClassLoader serversClassLoader = this.getClass().getClassLoader();
-		Thread.currentThread().setContextClassLoader(serversClassLoader);
-
-		_recoveryManager.scan();
-		Thread.currentThread().setContextClassLoader(classLoader);
-	}
-
-	@Override
 	public TransactionManager getTransactionManager() {
 		return transactionManagerService.getTransactionManager();
 	}
@@ -237,11 +181,6 @@
 	}
 
 	@Override
-	public long getTimeLeftBeforeTransactionTimeout() throws RollbackException {
-		return ((TransactionTimeoutConfiguration) transactionManagerService.getTransactionManager()).getTimeLeftBeforeTransactionTimeout(false);
-	}
-
-	@Override
 	public void storeRootTransaction() throws SystemException {
 		TransactionImple transaction = ((TransactionImple) transactionManagerService.getTransactionManager().getTransaction());
 		Xid txId = transaction.getTxId();
@@ -270,23 +209,18 @@
 	}
 
 	@Override
-	public void setOffline(boolean offline) {
-		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-		ClassLoader serversClassLoader = this.getClass().getClassLoader();
-		Thread.currentThread().setContextClassLoader(serversClassLoader);
-		this.offline = offline;
-		Thread.currentThread().setContextClassLoader(classLoader);
-	}
-
-	@Override
 	public RemoteServer connectTo() {
 		return this;
 	}
 
 	@Override
 	public int propagatePrepare(Xid xid) throws XAException, DummyRemoteException {
-		if (offline) {
-			throw new DummyRemoteException("Connection refused to: " + nodeName);
+		ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+		try {
+			Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+			
+		} finally {
+			Thread.currentThread().setContextClassLoader(contextClassLoader);			
 		}
 		SubordinateTransaction tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
 		return SubordinationManager.getXATerminator().prepare(xid);
@@ -294,53 +228,68 @@
 
 	@Override
 	public void propagateCommit(Xid xid) throws XAException, DummyRemoteException {
-		if (offline) {
-			throw new DummyRemoteException("Connection refused to: " + nodeName);
+		ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+		try {
+			Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+			SubordinationManager.getXATerminator().commit(xid, false);
+		} finally {
+			Thread.currentThread().setContextClassLoader(contextClassLoader);			
 		}
-		SubordinationManager.getXATerminator().commit(xid, false);
 	}
 
 	@Override
 	public void propagateRollback(Xid xid) throws XAException, DummyRemoteException {
-		if (offline) {
-			throw new DummyRemoteException("Connection refused to: " + nodeName);
+		ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+		try {
+			Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+			SubordinationManager.getXATerminator().rollback(xid);			
+		} finally {
+			Thread.currentThread().setContextClassLoader(contextClassLoader);			
 		}
-		SubordinationManager.getXATerminator().rollback(xid);
 	}
 
 	@Override
 	public Xid[] propagateRecover(int formatId, byte[] gtrid, int flag) throws XAException, DummyRemoteException {
-		if (offline) {
-			throw new DummyRemoteException("Connection refused to: " + nodeName);
-		}
-		List<Xid> toReturn = new ArrayList<Xid>();
-		Xid[] recovered = SubordinationManager.getXATerminator().recover(flag);
-		if (recovered != null) {
-			for (int i = 0; i < recovered.length; i++) {
-				// Filter out the transactions that are not owned by this parent
-				if (recovered[i].getFormatId() == formatId && Arrays.equals(gtrid, recovered[i].getGlobalTransactionId())) {
-					toReturn.add(recovered[i]);
+		ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+		try {
+			Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+			List<Xid> toReturn = new ArrayList<Xid>();
+			Xid[] recovered = SubordinationManager.getXATerminator().recover(flag);
+			if (recovered != null) {
+				for (int i = 0; i < recovered.length; i++) {
+					// Filter out the transactions that are not owned by this parent
+					if (recovered[i].getFormatId() == formatId && Arrays.equals(gtrid, recovered[i].getGlobalTransactionId())) {
+						toReturn.add(recovered[i]);
+					}
 				}
 			}
+			return toReturn.toArray(new Xid[0]);
+		} finally {
+			Thread.currentThread().setContextClassLoader(contextClassLoader);			
 		}
-		return toReturn.toArray(new Xid[0]);
 	}
 
 	@Override
 	public void propagateForget(Xid xid) throws XAException, DummyRemoteException {
-		if (offline) {
-			throw new DummyRemoteException("Connection refused to: " + nodeName);
+		ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+		try {
+			Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+			SubordinationManager.getXATerminator().forget(xid);
+		} finally {
+			Thread.currentThread().setContextClassLoader(contextClassLoader);			
 		}
-		SubordinationManager.getXATerminator().forget(xid);
 
 	}
 
 	@Override
 	public void propagateBeforeCompletion(Xid xid) throws XAException, SystemException, DummyRemoteException {
-		if (offline) {
-			throw new DummyRemoteException("Connection refused to: " + nodeName);
+		ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+		try {
+			Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+			((XATerminatorImple) SubordinationManager.getXATerminator()).beforeCompletion(xid);
+		} finally {
+			Thread.currentThread().setContextClassLoader(contextClassLoader);			
 		}
-		((XATerminatorImple) SubordinationManager.getXATerminator()).beforeCompletion(xid);
 	}
 
 	@Override
@@ -348,9 +297,4 @@
 		ProxyXAResource proxyXAResource = (ProxyXAResource) xaResource;
 		return proxyXAResource.getXid();
 	}
-
-	@Override
-	public CompletionCounter getCompletionCounter() {
-		return counter;
-	}
 }



More information about the jboss-svn-commits mailing list