[jboss-svn-commits] JBL Code SVN: r37600 - in labs/jbosstm/branches/JBOSSTS_4_15_0_Final: atsintegration/examples/classes/com/arjuna/ats/jta and 6 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Oct 19 04:49:50 EDT 2011


Author: tomjenkinson
Date: 2011-10-19 04:49:49 -0400 (Wed, 19 Oct 2011)
New Revision: 37600

Added:
   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/
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxySynchronization.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/ProxyXAResourceRecovery.java
   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/server/
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/server/impl/
Removed:
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/SimpleIsolatedServers.java
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxySynchronization.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/ProxyXAResourceRecovery.java
   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/server/impl/ProxySynchronization.java
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/server/impl/ProxyXAResource.java
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/server/impl/ProxyXAResourceRecovery.java
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/server/impl/ServerImpl.java
Modified:
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/.classpath
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResource.java
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResourceRecovery.java
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/CompletionCounter.java
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/DummyRemoteException.java
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/IsolatableServersClassLoader.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/LookupProvider.java
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/RemoteServer.java
Log:
JBTM-895 converted the test to an example

Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/.classpath
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/.classpath	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/.classpath	2011-10-19 08:49:49 UTC (rev 37600)
@@ -4,7 +4,6 @@
 	<classpathentry kind="src" path="atsintegration/classes"/>
 	<classpathentry kind="src" path="atsintegration/examples/classes"/>
 	<classpathentry kind="src" path="antbuildsystem/classes"/>
-	<classpathentry kind="src" path="atsintegration/tests/classes"/>
 	<classpathentry kind="src" path="common/classes"/>
 	<classpathentry kind="src" path="common/tests"/>
 	<classpathentry kind="src" path="ArjunaCore/arjuna/build/classes"/>

Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/ExampleDistributedJTATestCase.java (from rev 37599, labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/SimpleIsolatedServers.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/ExampleDistributedJTATestCase.java	                        (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/ExampleDistributedJTATestCase.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -0,0 +1,224 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.jta.distributed.example;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.common.CoreEnvironmentBeanException;
+import com.arjuna.jta.distributed.example.server.CompletionCounter;
+import com.arjuna.jta.distributed.example.server.IsolatableServersClassLoader;
+import com.arjuna.jta.distributed.example.server.LocalServer;
+import com.arjuna.jta.distributed.example.server.LookupProvider;
+import com.arjuna.jta.distributed.example.server.RemoteServer;
+
+public class ExampleDistributedJTATestCase {
+	private static LookupProvider lookupProvider = new MyLookupProvider();
+	private static LocalServer[] localServers = new LocalServer[3];
+	private static RemoteServer[] remoteServers = new RemoteServer[3];
+
+	@BeforeClass
+	public static void setup() throws SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException, ClassNotFoundException,
+			CoreEnvironmentBeanException, IOException, IllegalArgumentException, NoSuchFieldException {
+		for (int i = 0; i < localServers.length; i++) {
+			ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+			IsolatableServersClassLoader classLoader = new IsolatableServersClassLoader("com.arjuna.jta.distributed.example.server", contextClassLoader);
+			localServers[i] = (LocalServer) classLoader.loadClass("com.arjuna.jta.distributed.example.server.impl.ServerImpl").newInstance();
+			Thread.currentThread().setContextClassLoader(localServers[i].getClass().getClassLoader());
+			localServers[i].initialise(lookupProvider, (i + 1) * 1000);
+			remoteServers[i] = localServers[i].connectTo();
+			Thread.currentThread().setContextClassLoader(contextClassLoader);
+		}
+	}
+
+	@Test
+	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()) {
+			file.delete();
+		}
+		int startingTimeout = 0;
+		List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 1000, 2000, 3000, 2000, 1000, 2000, 3000, 1000, 3000 }));
+
+		// Start out at the first server
+		CompletionCounter 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;
+			}
+		};
+		int totalNodeCount = nodesToFlowTo.size();
+		int startingServer = nodesToFlowTo.remove(0);
+		LocalServer originalServer = getLocalServer(startingServer);
+		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+		Thread.currentThread().setContextClassLoader(originalServer.getClass().getClassLoader());
+		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));
+
+		if (!nodesToFlowTo.isEmpty()) {
+			Integer nextServerNodeName = nodesToFlowTo.get(0);
+
+			// FLOW THE TRANSACTION
+			remainingTimeout = (int) (originalServer.getTimeLeftBeforeTransactionTimeout() / 1000);
+
+			// SUSPEND THE TRANSACTION
+			Xid currentXid = originalServer.getCurrentXid();
+			originalServer.storeRootTransaction();
+			transactionManager.suspend();
+			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 = originalServer.generateProxyXAResource(lookupProvider, originalServer.getNodeName(), nextServerNodeName);
+				transaction.enlistResource(proxyXAResource);
+				transaction.registerSynchronization(originalServer.generateProxySynchronization(lookupProvider, originalServer.getNodeName(),
+						nextServerNodeName, currentXid));
+			}
+			originalServer.removeRootTransaction(currentXid);
+		}
+		transactionManager.commit();
+		assertTrue(counter.getCommitCount() == totalNodeCount);
+		Thread.currentThread().setContextClassLoader(classLoader);
+	}
+
+	private boolean performTransactionalWork(CompletionCounter counter, List<Integer> nodesToFlowTo, int remainingTimeout, Xid toMigrate)
+			throws RollbackException, InvalidTransactionException, IllegalStateException, XAException, SystemException, NotSupportedException {
+		Integer currentServerName = nodesToFlowTo.remove(0);
+		LocalServer currentServer = getLocalServer(currentServerName);
+
+		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+		Thread.currentThread().setContextClassLoader(currentServer.getClass().getClassLoader());
+
+		boolean requiresProxyAtPreviousServer = !currentServer.getAndResumeTransaction(remainingTimeout, toMigrate);
+		// Perform work on the migrated transaction
+		TransactionManager transactionManager = currentServer.getTransactionManager();
+		Transaction transaction = transactionManager.getTransaction();
+		transaction.registerSynchronization(new TestSynchronization(currentServer.getNodeName()));
+		transaction.enlistResource(new TestResource(counter, currentServer.getNodeName(), false));
+
+		if (!nodesToFlowTo.isEmpty()) {
+			Integer nextServerNodeName = nodesToFlowTo.get(0);
+
+			// FLOW THE TRANSACTION
+			remainingTimeout = (int) (currentServer.getTimeLeftBeforeTransactionTimeout() / 1000);
+
+			// SUSPEND THE TRANSACTION
+			Xid currentXid = currentServer.getCurrentXid();
+			transactionManager.suspend();
+			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);
+				transaction.registerSynchronization(currentServer.generateProxySynchronization(lookupProvider, currentServer.getNodeName(), nextServerNodeName,
+						toMigrate));
+			}
+		}
+
+		// SUSPEND THE TRANSACTION WHEN YOU ARE READY TO RETURN TO YOUR CALLER
+		transactionManager.suspend();
+
+		Thread.currentThread().setContextClassLoader(classLoader);
+		return requiresProxyAtPreviousServer;
+	}
+
+	private static LocalServer getLocalServer(Integer jndiName) {
+		int index = (jndiName / 1000) - 1;
+		return localServers[index];
+	}
+
+	private static class MyLookupProvider implements LookupProvider {
+
+		@Override
+		public RemoteServer lookup(Integer jndiName) {
+			int index = (jndiName / 1000) - 1;
+			return remoteServers[index];
+		}
+
+	}
+}

Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/SimpleIsolatedServers.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/SimpleIsolatedServers.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/SimpleIsolatedServers.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -1,344 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package com.arjuna.jta.distributed.example;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import com.arjuna.ats.arjuna.common.CoreEnvironmentBeanException;
-import com.arjuna.ats.jta.distributed.server.CompletionCounter;
-import com.arjuna.ats.jta.distributed.server.IsolatableServersClassLoader;
-import com.arjuna.ats.jta.distributed.server.LocalServer;
-import com.arjuna.ats.jta.distributed.server.LookupProvider;
-import com.arjuna.ats.jta.distributed.server.RemoteServer;
-
-public class SimpleIsolatedServers {
-	private static LookupProvider lookupProvider = new MyLookupProvider();
-	private static LocalServer[] localServers = new LocalServer[3];
-	private static RemoteServer[] remoteServers = new RemoteServer[3];
-
-	@BeforeClass
-	public static void setup() throws SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException, ClassNotFoundException,
-			CoreEnvironmentBeanException, IOException, IllegalArgumentException, NoSuchFieldException {
-		for (int i = 0; i < localServers.length; i++) {
-			ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
-			IsolatableServersClassLoader classLoader = new IsolatableServersClassLoader("com.arjuna.jta.distributed.example.server", contextClassLoader);
-			localServers[i] = (LocalServer) classLoader.loadClass("com.arjuna.jta.distributed.example.server.impl.ServerImpl").newInstance();
-			Thread.currentThread().setContextClassLoader(localServers[i].getClass().getClassLoader());
-			localServers[i].initialise(lookupProvider, (i + 1) * 1000);
-			remoteServers[i] = localServers[i].connectTo();
-			Thread.currentThread().setContextClassLoader(contextClassLoader);
-		}
-	}
-
-	@Test
-	public void testRecovery() throws IOException {
-		assertTrue(getLocalServer(3000).getCompletionCounter().getCommitCount() == 0);
-		assertTrue(getLocalServer(2000).getCompletionCounter().getCommitCount() == 0);
-		assertTrue(getLocalServer(1000).getCompletionCounter().getCommitCount() == 0);
-		// Start out at the first server
-		// getLocalServer(3000).doRecoveryManagerScan();
-		// getLocalServer(2000).doRecoveryManagerScan();
-		getLocalServer(1000).doRecoveryManagerScan();
-
-		assertTrue(getLocalServer(1000).getCompletionCounter().getCommitCount() == 3);
-		assertTrue(getLocalServer(2000).getCompletionCounter().getCommitCount() == 3);
-		assertTrue(getLocalServer(3000).getCompletionCounter().getCommitCount() == 3);
-	}
-
-	@Test
-	public void testMigrateTransactionCommit() throws NotSupportedException, SystemException, IllegalStateException, RollbackException,
-			InvalidTransactionException, XAException, SecurityException, HeuristicMixedException, HeuristicRollbackException {
-
-		File file = new File(System.getProperty("user.dir") + "/tmp/");
-		if (file.exists()) {
-			file.delete();
-		}
-		int startingTimeout = 0;
-		List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 1000, 2000, 3000, 2000, 1000, 2000, 3000, 1000, 3000 }));
-		doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, true);
-	}
-
-	@Test
-	public void testMigrateTransactionCommitDiamond() throws NotSupportedException, SystemException, IllegalStateException, RollbackException,
-			InvalidTransactionException, XAException, SecurityException, HeuristicMixedException, HeuristicRollbackException {
-
-		File file = new File(System.getProperty("user.dir") + "/tmp/");
-		if (file.exists()) {
-			file.delete();
-		}
-		int startingTimeout = 0;
-		List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 1000, 2000, 1000, 3000, 1000, 2000, 3000 }));
-		doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, true);
-	}
-
-	@Test
-	public void testMigrateTransactionRollback() throws NotSupportedException, SystemException, IllegalStateException, RollbackException,
-			InvalidTransactionException, XAException, SecurityException, HeuristicMixedException, HeuristicRollbackException {
-
-		File file = new File(System.getProperty("user.dir") + "/tmp/");
-		if (file.exists()) {
-			file.delete();
-		}
-		int startingTimeout = 0;
-		List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 1000, 2000, 3000, 2000, 1000, 2000, 3000, 1000, 3000 }));
-		doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, false);
-	}
-
-	@Test
-	public void testMigrateTransactionRollbackDiamond() throws NotSupportedException, SystemException, IllegalStateException, RollbackException,
-			InvalidTransactionException, XAException, SecurityException, HeuristicMixedException, HeuristicRollbackException {
-
-		File file = new File(System.getProperty("user.dir") + "/tmp/");
-		if (file.exists()) {
-			file.delete();
-		}
-		int startingTimeout = 0;
-		List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 1000, 2000, 1000, 3000, 1000, 2000, 3000 }));
-		doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, false);
-	}
-
-	@Test
-	public void testMigrateTransactionSubordinateTimeout() throws NotSupportedException, SystemException, IllegalStateException, RollbackException,
-			InvalidTransactionException, XAException, SecurityException, HeuristicMixedException, HeuristicRollbackException, InterruptedException {
-
-		File file = new File(System.getProperty("user.dir") + "/tmp/");
-		if (file.exists()) {
-			file.delete();
-		}
-		int rootTimeout = 10000;
-		int subordinateTimeout = 1;
-
-		// Start out at the first server
-		CompletionCounter 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;
-			}
-		};
-		LocalServer originalServer = getLocalServer(1000);
-		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-		Thread.currentThread().setContextClassLoader(originalServer.getClass().getClassLoader());
-		TransactionManager transactionManager = originalServer.getTransactionManager();
-		transactionManager.setTransactionTimeout(rootTimeout);
-		transactionManager.begin();
-		Transaction originalTransaction = transactionManager.getTransaction();
-		Xid toMigrate = originalServer.getCurrentXid();
-		originalServer.storeRootTransaction();
-		originalTransaction.enlistResource(new TestResource(counter, originalServer.getNodeName(), false));
-		transactionManager.suspend();
-
-		// Migrate a transaction
-		LocalServer currentServer = getLocalServer(2000);
-		ClassLoader parentsClassLoader = Thread.currentThread().getContextClassLoader();
-		Thread.currentThread().setContextClassLoader(currentServer.getClass().getClassLoader());
-		currentServer.getAndResumeTransaction(subordinateTimeout, toMigrate);
-		currentServer.getTransactionManager().getTransaction().enlistResource(new TestResource(counter, currentServer.getNodeName(), false));
-		currentServer.getTransactionManager().suspend();
-		Thread.currentThread().setContextClassLoader(parentsClassLoader);
-
-		// Complete the transaction at the original server
-		transactionManager.resume(originalTransaction);
-		XAResource proxyXAResource = originalServer.generateProxyXAResource(lookupProvider, originalServer.getNodeName(), 2000);
-		originalTransaction.enlistResource(proxyXAResource);
-		originalServer.removeRootTransaction(toMigrate);
-		Thread.currentThread().sleep((subordinateTimeout + 1) * 1000);
-		try {
-			transactionManager.commit();
-		} catch (RollbackException rbe) {
-			// GOOD!
-			assertTrue(counter.getRollbackCount() == 2);
-		} finally {
-			Thread.currentThread().setContextClassLoader(classLoader);
-		}
-	}
-
-	private void doRecursiveTransactionalWork(int startingTimeout, List<Integer> nodesToFlowTo, boolean commit) throws NotSupportedException, SystemException,
-			RollbackException, InvalidTransactionException, IllegalStateException, XAException, SecurityException, HeuristicMixedException,
-			HeuristicRollbackException {
-
-		// Start out at the first server
-		CompletionCounter 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;
-			}
-		};
-		int totalNodeCount = nodesToFlowTo.size();
-		int startingServer = nodesToFlowTo.get(0);
-		LocalServer originalServer = getLocalServer(startingServer);
-		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-		Thread.currentThread().setContextClassLoader(originalServer.getClass().getClassLoader());
-		TransactionManager transactionManager = originalServer.getTransactionManager();
-		transactionManager.setTransactionTimeout(startingTimeout);
-		transactionManager.begin();
-		Transaction originalTransaction = transactionManager.getTransaction();
-		int remainingTimeout = (int) (originalServer.getTimeLeftBeforeTransactionTimeout() / 1000);
-		Xid currentXid = originalServer.getCurrentXid();
-		originalServer.storeRootTransaction();
-		transactionManager.suspend();
-		performTransactionalWork(counter, nodesToFlowTo, remainingTimeout, currentXid);
-		transactionManager.resume(originalTransaction);
-		originalServer.removeRootTransaction(currentXid);
-		if (commit) {
-			transactionManager.commit();
-			assertTrue(counter.getCommitCount() == totalNodeCount);
-		} else {
-			transactionManager.rollback();
-			assertTrue(counter.getRollbackCount() == totalNodeCount);
-		}
-		Thread.currentThread().setContextClassLoader(classLoader);
-	}
-
-	private boolean performTransactionalWork(CompletionCounter counter, List<Integer> nodesToFlowTo, int remainingTimeout, Xid toMigrate)
-			throws RollbackException, InvalidTransactionException, IllegalStateException, XAException, SystemException, NotSupportedException {
-		Integer currentServerName = nodesToFlowTo.remove(0);
-		LocalServer currentServer = getLocalServer(currentServerName);
-
-		ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-		Thread.currentThread().setContextClassLoader(currentServer.getClass().getClassLoader());
-
-		boolean requiresProxyAtPreviousServer = !currentServer.getAndResumeTransaction(remainingTimeout, toMigrate);
-		// Perform work on the migrated transaction
-		TransactionManager transactionManager = currentServer.getTransactionManager();
-		Transaction transaction = transactionManager.getTransaction();
-		transaction.registerSynchronization(new TestSynchronization(currentServer.getNodeName()));
-		transaction.enlistResource(new TestResource(counter, currentServer.getNodeName(), false));
-
-		if (!nodesToFlowTo.isEmpty()) {
-			Integer nextServerNodeName = nodesToFlowTo.get(0);
-
-			// FLOW THE TRANSACTION
-			remainingTimeout = (int) (currentServer.getTimeLeftBeforeTransactionTimeout() / 1000);
-
-			// SUSPEND THE TRANSACTION
-			Xid currentXid = currentServer.getCurrentXid();
-			transactionManager.suspend();
-			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);
-				transaction.registerSynchronization(currentServer.generateProxySynchronization(lookupProvider, currentServer.getNodeName(), nextServerNodeName,
-						toMigrate));
-			}
-		}
-
-		// SUSPEND THE TRANSACTION WHEN YOU ARE READY TO RETURN TO YOUR CALLER
-		transactionManager.suspend();
-
-		Thread.currentThread().setContextClassLoader(classLoader);
-		return requiresProxyAtPreviousServer;
-	}
-
-	private static LocalServer getLocalServer(Integer jndiName) {
-		int index = (jndiName / 1000) - 1;
-		return localServers[index];
-	}
-
-	private static class MyLookupProvider implements LookupProvider {
-
-		@Override
-		public RemoteServer lookup(Integer jndiName) {
-			int index = (jndiName / 1000) - 1;
-			return remoteServers[index];
-		}
-
-	}
-}

Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResource.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResource.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResource.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -34,7 +34,7 @@
 import javax.transaction.xa.Xid;
 
 import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.jta.distributed.server.CompletionCounter;
+import com.arjuna.jta.distributed.example.server.CompletionCounter;
 
 public class TestResource implements XAResource {
 	private Xid xid;

Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResourceRecovery.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResourceRecovery.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResourceRecovery.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -30,7 +30,7 @@
 
 import org.jboss.tm.XAResourceRecovery;
 
-import com.arjuna.ats.jta.distributed.server.CompletionCounter;
+import com.arjuna.jta.distributed.example.server.CompletionCounter;
 
 public class TestResourceRecovery implements XAResourceRecovery {
 

Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/CompletionCounter.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/CompletionCounter.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/CompletionCounter.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -19,7 +19,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package com.arjuna.ats.jta.distributed.server;
+package com.arjuna.jta.distributed.example.server;
 
 public interface CompletionCounter {
 	public void incrementCommit();

Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/DummyRemoteException.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/DummyRemoteException.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/DummyRemoteException.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -19,7 +19,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package com.arjuna.ats.jta.distributed.server;
+package com.arjuna.jta.distributed.example.server;
 
 public class DummyRemoteException extends Exception {
 	public DummyRemoteException(String message) {

Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/IsolatableServersClassLoader.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/IsolatableServersClassLoader.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/IsolatableServersClassLoader.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -19,7 +19,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package com.arjuna.ats.jta.distributed.server;
+package com.arjuna.jta.distributed.example.server;
 
 import java.io.IOException;
 import java.net.MalformedURLException;

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/ats/jta/distributed/server/LocalServer.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/LocalServer.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -19,7 +19,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package com.arjuna.ats.jta.distributed.server;
+package com.arjuna.jta.distributed.example.server;
 
 import java.io.IOException;
 

Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/LookupProvider.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/LookupProvider.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/LookupProvider.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -19,7 +19,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package com.arjuna.ats.jta.distributed.server;
+package com.arjuna.jta.distributed.example.server;
 
 public interface LookupProvider {
 	public RemoteServer lookup(Integer jndiName);

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/ats/jta/distributed/server/RemoteServer.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/RemoteServer.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -19,7 +19,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
-package com.arjuna.ats.jta.distributed.server;
+package com.arjuna.jta.distributed.example.server;
 
 import javax.transaction.SystemException;
 import javax.transaction.xa.XAException;

Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxySynchronization.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxySynchronization.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxySynchronization.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package com.arjuna.ats.jta.distributed.server.impl;
-
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.Xid;
-
-import com.arjuna.ats.jta.distributed.server.DummyRemoteException;
-import com.arjuna.ats.jta.distributed.server.LookupProvider;
-
-public class ProxySynchronization implements Synchronization {
-
-	private int localServerName;
-	private int remoteServerName;
-	private Xid toRegisterAgainst;
-	private LookupProvider lookupProvider;
-
-	public ProxySynchronization(LookupProvider lookupProvider, int localServerName, int remoteServerName, Xid toRegisterAgainst) {
-		this.lookupProvider = lookupProvider;
-		this.localServerName = localServerName;
-		this.remoteServerName = remoteServerName;
-		this.toRegisterAgainst = toRegisterAgainst;
-	}
-
-	@Override
-	public void beforeCompletion() {
-		System.out.println("ProxySynchronization (" + localServerName + ":" + remoteServerName + ") beforeCompletion");
-		try {
-			lookupProvider.lookup(remoteServerName).propagateBeforeCompletion(toRegisterAgainst);
-		} catch (XAException e) {
-			e.printStackTrace();
-		} catch (SystemException e) {
-			e.printStackTrace();
-		} catch (DummyRemoteException e) {
-			e.printStackTrace();
-		}
-	}
-
-	@Override
-	public void afterCompletion(int status) {
-		// These are not proxied but are handled during local commits
-	}
-}

Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxySynchronization.java (from rev 37599, labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxySynchronization.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxySynchronization.java	                        (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxySynchronization.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.jta.distributed.example.server.impl;
+
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.Xid;
+
+import com.arjuna.jta.distributed.example.server.DummyRemoteException;
+import com.arjuna.jta.distributed.example.server.LookupProvider;
+
+public class ProxySynchronization implements Synchronization {
+
+	private int localServerName;
+	private int remoteServerName;
+	private Xid toRegisterAgainst;
+	private LookupProvider lookupProvider;
+
+	public ProxySynchronization(LookupProvider lookupProvider, int localServerName, int remoteServerName, Xid toRegisterAgainst) {
+		this.lookupProvider = lookupProvider;
+		this.localServerName = localServerName;
+		this.remoteServerName = remoteServerName;
+		this.toRegisterAgainst = toRegisterAgainst;
+	}
+
+	@Override
+	public void beforeCompletion() {
+		System.out.println("ProxySynchronization (" + localServerName + ":" + remoteServerName + ") beforeCompletion");
+		try {
+			lookupProvider.lookup(remoteServerName).propagateBeforeCompletion(toRegisterAgainst);
+		} catch (XAException e) {
+			e.printStackTrace();
+		} catch (SystemException e) {
+			e.printStackTrace();
+		} catch (DummyRemoteException e) {
+			e.printStackTrace();
+		}
+	}
+
+	@Override
+	public void afterCompletion(int status) {
+		// These are not proxied but are handled during local commits
+	}
+}

Deleted: 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/ats/jta/distributed/server/impl/ProxyXAResource.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResource.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -1,287 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package com.arjuna.ats.jta.distributed.server.impl;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import org.jboss.tm.XAResourceWrapper;
-
-import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
-import com.arjuna.ats.jta.distributed.server.DummyRemoteException;
-import com.arjuna.ats.jta.distributed.server.LookupProvider;
-
-public class ProxyXAResource implements XAResource, XAResourceWrapper {
-
-	private int transactionTimeout;
-	private Integer remoteServerName = -1;
-	private File file;
-	private Integer localServerName;
-	private LookupProvider lookupProvider;
-	private Xid xid;
-
-	public ProxyXAResource(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName) {
-		this.lookupProvider = lookupProvider;
-		this.localServerName = localServerName;
-		this.remoteServerName = remoteServerName;
-	}
-
-	public ProxyXAResource(LookupProvider lookupProvider, Integer localServerName, File file) throws IOException {
-		this.lookupProvider = lookupProvider;
-		this.localServerName = localServerName;
-		this.file = file;
-		DataInputStream fis = new DataInputStream(new FileInputStream(file));
-		this.remoteServerName = fis.readInt();
-		final int formatId = fis.readInt();
-		int gtrid_length = fis.readInt();
-		final byte[] gtrid = new byte[gtrid_length];
-		fis.read(gtrid, 0, gtrid_length);
-		int bqual_length = fis.readInt();
-		final byte[] bqual = new byte[bqual_length];
-		fis.read(bqual, 0, bqual_length);
-		this.xid = new Xid() {
-			@Override
-			public byte[] getBranchQualifier() {
-				return bqual;
-			}
-
-			@Override
-			public int getFormatId() {
-				return formatId;
-			}
-
-			@Override
-			public byte[] getGlobalTransactionId() {
-				return gtrid;
-			}
-		};
-	}
-
-	@Override
-	public void start(Xid xid, int flags) throws XAException {
-		System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_START   [" + xid + "]");
-		this.xid = xid;
-	}
-
-	@Override
-	public void end(Xid xid, int flags) throws XAException {
-		System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_END     [" + xid + "]");
-		this.xid = null;
-	}
-
-	@Override
-	public synchronized int prepare(Xid xid) throws XAException {
-		System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_PREPARE [" + xid + "]");
-
-		try {
-			File dir = new File(System.getProperty("user.dir") + "/tmp/ProxyXAResource/" + localServerName + "/");
-			dir.mkdirs();
-			file = new File(dir, new Uid().fileStringForm());
-			file.createNewFile();
-			DataOutputStream fos = new DataOutputStream(new FileOutputStream(file));
-			fos.writeInt(remoteServerName);
-			fos.writeInt(xid.getFormatId());
-			fos.writeInt(xid.getGlobalTransactionId().length);
-			fos.write(xid.getGlobalTransactionId());
-			fos.writeInt(xid.getBranchQualifier().length);
-			fos.write(xid.getBranchQualifier());
-		} catch (IOException e) {
-			e.printStackTrace();
-			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);
-		}
-
-	}
-
-	/**
-	 * The remote side will not accept a one phase optimization.
-	 */
-	@Override
-	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) {
-			file.delete();
-		}
-	}
-
-	@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) {
-			file.delete();
-		}
-	}
-
-	@Override
-	public Xid[] recover(int flag) throws XAException {
-		Xid[] recovered = null;
-		if ((flag & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN) {
-			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVER [XAResource.TMSTARTRSCAN]: "
-					+ remoteServerName);
-		}
-		if ((flag & XAResource.TMENDRSCAN) == XAResource.TMENDRSCAN) {
-			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVER [XAResource.TMENDRSCAN]: "
-					+ remoteServerName);
-		}
-
-		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);
-			}
-		}
-
-		for (int i = 0; i < recovered.length; i++) {
-			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") recovered: " + recovered[i]);
-		}
-
-		Xid[] toReturn = null;
-		if ((flag & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN) {
-			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVERD[XAResource.TMSTARTRSCAN]: "
-					+ remoteServerName);
-			toReturn = new Xid[] { xid };
-		}
-		if ((flag & XAResource.TMENDRSCAN) == XAResource.TMENDRSCAN) {
-			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVERD[XAResource.TMENDRSCAN]: "
-					+ remoteServerName);
-		}
-		return toReturn;
-	}
-
-	@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);
-		}
-	}
-
-	@Override
-	public int getTransactionTimeout() throws XAException {
-		return transactionTimeout;
-	}
-
-	@Override
-	public boolean setTransactionTimeout(int seconds) throws XAException {
-		this.transactionTimeout = seconds;
-		return true;
-	}
-
-	@Override
-	public boolean isSameRM(XAResource xares) throws XAException {
-		boolean toReturn = false;
-		if (xares instanceof ProxyXAResource) {
-			if (((ProxyXAResource) xares).remoteServerName == remoteServerName) {
-				toReturn = true;
-			}
-		}
-		return toReturn;
-	}
-
-	/**
-	 * I don't think this is used by TM.
-	 */
-	@Override
-	public XAResource getResource() {
-		return null;
-	}
-
-	/**
-	 * I don't think this is used by TM.
-	 */
-	@Override
-	public String getProductName() {
-		return null;
-	}
-
-	/**
-	 * I don't think this is used by TM.
-	 */
-	@Override
-	public String getProductVersion() {
-		return null;
-	}
-
-	@Override
-	public String getJndiName() {
-		return "ProxyXAResource";
-	}
-
-	public Xid getXid() {
-		return xid;
-	}
-}

Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResource.java (from rev 37599, labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResource.java	                        (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResource.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -0,0 +1,287 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.jta.distributed.example.server.impl;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+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;
+
+public class ProxyXAResource implements XAResource, XAResourceWrapper {
+
+	private int transactionTimeout;
+	private Integer remoteServerName = -1;
+	private File file;
+	private Integer localServerName;
+	private LookupProvider lookupProvider;
+	private Xid xid;
+
+	public ProxyXAResource(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName) {
+		this.lookupProvider = lookupProvider;
+		this.localServerName = localServerName;
+		this.remoteServerName = remoteServerName;
+	}
+
+	public ProxyXAResource(LookupProvider lookupProvider, Integer localServerName, File file) throws IOException {
+		this.lookupProvider = lookupProvider;
+		this.localServerName = localServerName;
+		this.file = file;
+		DataInputStream fis = new DataInputStream(new FileInputStream(file));
+		this.remoteServerName = fis.readInt();
+		final int formatId = fis.readInt();
+		int gtrid_length = fis.readInt();
+		final byte[] gtrid = new byte[gtrid_length];
+		fis.read(gtrid, 0, gtrid_length);
+		int bqual_length = fis.readInt();
+		final byte[] bqual = new byte[bqual_length];
+		fis.read(bqual, 0, bqual_length);
+		this.xid = new Xid() {
+			@Override
+			public byte[] getBranchQualifier() {
+				return bqual;
+			}
+
+			@Override
+			public int getFormatId() {
+				return formatId;
+			}
+
+			@Override
+			public byte[] getGlobalTransactionId() {
+				return gtrid;
+			}
+		};
+	}
+
+	@Override
+	public void start(Xid xid, int flags) throws XAException {
+		System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_START   [" + xid + "]");
+		this.xid = xid;
+	}
+
+	@Override
+	public void end(Xid xid, int flags) throws XAException {
+		System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_END     [" + xid + "]");
+		this.xid = null;
+	}
+
+	@Override
+	public synchronized int prepare(Xid xid) throws XAException {
+		System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_PREPARE [" + xid + "]");
+
+		try {
+			File dir = new File(System.getProperty("user.dir") + "/tmp/ProxyXAResource/" + localServerName + "/");
+			dir.mkdirs();
+			file = new File(dir, new Uid().fileStringForm());
+			file.createNewFile();
+			DataOutputStream fos = new DataOutputStream(new FileOutputStream(file));
+			fos.writeInt(remoteServerName);
+			fos.writeInt(xid.getFormatId());
+			fos.writeInt(xid.getGlobalTransactionId().length);
+			fos.write(xid.getGlobalTransactionId());
+			fos.writeInt(xid.getBranchQualifier().length);
+			fos.write(xid.getBranchQualifier());
+		} catch (IOException e) {
+			e.printStackTrace();
+			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);
+		}
+
+	}
+
+	/**
+	 * The remote side will not accept a one phase optimization.
+	 */
+	@Override
+	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) {
+			file.delete();
+		}
+	}
+
+	@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) {
+			file.delete();
+		}
+	}
+
+	@Override
+	public Xid[] recover(int flag) throws XAException {
+		Xid[] recovered = null;
+		if ((flag & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN) {
+			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVER [XAResource.TMSTARTRSCAN]: "
+					+ remoteServerName);
+		}
+		if ((flag & XAResource.TMENDRSCAN) == XAResource.TMENDRSCAN) {
+			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVER [XAResource.TMENDRSCAN]: "
+					+ remoteServerName);
+		}
+
+		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);
+			}
+		}
+
+		for (int i = 0; i < recovered.length; i++) {
+			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") recovered: " + recovered[i]);
+		}
+
+		Xid[] toReturn = null;
+		if ((flag & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN) {
+			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVERD[XAResource.TMSTARTRSCAN]: "
+					+ remoteServerName);
+			toReturn = new Xid[] { xid };
+		}
+		if ((flag & XAResource.TMENDRSCAN) == XAResource.TMENDRSCAN) {
+			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVERD[XAResource.TMENDRSCAN]: "
+					+ remoteServerName);
+		}
+		return toReturn;
+	}
+
+	@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);
+		}
+	}
+
+	@Override
+	public int getTransactionTimeout() throws XAException {
+		return transactionTimeout;
+	}
+
+	@Override
+	public boolean setTransactionTimeout(int seconds) throws XAException {
+		this.transactionTimeout = seconds;
+		return true;
+	}
+
+	@Override
+	public boolean isSameRM(XAResource xares) throws XAException {
+		boolean toReturn = false;
+		if (xares instanceof ProxyXAResource) {
+			if (((ProxyXAResource) xares).remoteServerName == remoteServerName) {
+				toReturn = true;
+			}
+		}
+		return toReturn;
+	}
+
+	/**
+	 * I don't think this is used by TM.
+	 */
+	@Override
+	public XAResource getResource() {
+		return null;
+	}
+
+	/**
+	 * I don't think this is used by TM.
+	 */
+	@Override
+	public String getProductName() {
+		return null;
+	}
+
+	/**
+	 * I don't think this is used by TM.
+	 */
+	@Override
+	public String getProductVersion() {
+		return null;
+	}
+
+	@Override
+	public String getJndiName() {
+		return "ProxyXAResource";
+	}
+
+	public Xid getXid() {
+		return xid;
+	}
+}

Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResourceRecovery.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResourceRecovery.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResourceRecovery.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package com.arjuna.ats.jta.distributed.server.impl;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.transaction.xa.XAResource;
-
-import org.jboss.tm.XAResourceRecovery;
-
-import com.arjuna.ats.jta.distributed.server.LookupProvider;
-
-public class ProxyXAResourceRecovery implements XAResourceRecovery {
-
-	private List<ProxyXAResource> resources = new ArrayList<ProxyXAResource>();
-
-	public ProxyXAResourceRecovery(LookupProvider lookupProvider, int id) throws IOException {
-		File file = new File(System.getProperty("user.dir") + "/tmp/ProxyXAResource/" + id + "/");
-		if (file.exists() && file.isDirectory()) {
-			File[] listFiles = file.listFiles();
-			for (int i = 0; i < listFiles.length; i++) {
-				File currentFile = listFiles[i];
-				resources.add(new ProxyXAResource(lookupProvider, id, currentFile));
-			}
-		}
-	}
-
-	@Override
-	public XAResource[] getXAResources() {
-		return resources.toArray(new XAResource[] {});
-	}
-
-}

Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResourceRecovery.java (from rev 37599, labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResourceRecovery.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResourceRecovery.java	                        (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResourceRecovery.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.jta.distributed.example.server.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.transaction.xa.XAResource;
+
+import org.jboss.tm.XAResourceRecovery;
+
+import com.arjuna.jta.distributed.example.server.LookupProvider;
+
+public class ProxyXAResourceRecovery implements XAResourceRecovery {
+
+	private List<ProxyXAResource> resources = new ArrayList<ProxyXAResource>();
+
+	public ProxyXAResourceRecovery(LookupProvider lookupProvider, int id) throws IOException {
+		File file = new File(System.getProperty("user.dir") + "/tmp/ProxyXAResource/" + id + "/");
+		if (file.exists() && file.isDirectory()) {
+			File[] listFiles = file.listFiles();
+			for (int i = 0; i < listFiles.length; i++) {
+				File currentFile = listFiles[i];
+				resources.add(new ProxyXAResource(lookupProvider, id, currentFile));
+			}
+		}
+	}
+
+	@Override
+	public XAResource[] getXAResources() {
+		return resources.toArray(new XAResource[] {});
+	}
+
+}

Deleted: 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/ats/jta/distributed/server/impl/ServerImpl.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -1,356 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package com.arjuna.ats.jta.distributed.server.impl;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.RollbackException;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import javax.transaction.xa.XAException;
-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;
-import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean;
-import com.arjuna.ats.arjuna.common.RecoveryEnvironmentBean;
-import com.arjuna.ats.arjuna.coordinator.TxControl;
-import com.arjuna.ats.arjuna.recovery.RecoveryManager;
-import com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBrowser;
-import com.arjuna.ats.internal.jbossatx.jta.XAResourceRecordWrappingPluginImpl;
-import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple;
-import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction;
-import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateXidImple;
-import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinationManager;
-import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple;
-import com.arjuna.ats.jbossatx.jta.RecoveryManagerService;
-import com.arjuna.ats.jbossatx.jta.TransactionManagerService;
-import com.arjuna.ats.jta.common.JTAEnvironmentBean;
-import com.arjuna.ats.jta.distributed.server.CompletionCounter;
-import com.arjuna.ats.jta.distributed.server.DummyRemoteException;
-import com.arjuna.ats.jta.distributed.server.LocalServer;
-import com.arjuna.ats.jta.distributed.server.LookupProvider;
-import com.arjuna.ats.jta.distributed.server.RemoteServer;
-import com.arjuna.jta.distributed.example.TestResourceRecovery;
-
-public class ServerImpl implements LocalServer, RemoteServer {
-
-	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);
-
-		recoveryEnvironmentBean.setRecoveryInetAddress(InetAddress.getByName("localhost"));
-		recoveryEnvironmentBean.setRecoveryPort(4712 + nodeName);
-		recoveryEnvironmentBean.setTransactionStatusManagerInetAddress(InetAddress.getByName("localhost"));
-		recoveryEnvironmentBean.setTransactionStatusManagerPort(4713 + nodeName);
-		List<String> recoveryModuleClassNames = new ArrayList<String>();
-
-		recoveryModuleClassNames.add("com.arjuna.ats.internal.arjuna.recovery.AtomicActionRecoveryModule");
-		recoveryModuleClassNames.add("com.arjuna.ats.internal.txoj.recovery.TORecoveryModule");
-		recoveryModuleClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule");
-		recoveryEnvironmentBean.setRecoveryModuleClassNames(recoveryModuleClassNames);
-		List<String> expiryScannerClassNames = new ArrayList<String>();
-		expiryScannerClassNames.add("com.arjuna.ats.internal.arjuna.recovery.ExpiredTransactionStatusManagerScanner");
-		recoveryEnvironmentBean.setExpiryScannerClassNames(expiryScannerClassNames);
-		recoveryEnvironmentBean.setRecoveryActivators(null);
-
-		CoreEnvironmentBean coreEnvironmentBean = com.arjuna.ats.arjuna.common.arjPropertyManager.getCoreEnvironmentBean();
-		coreEnvironmentBean.setSocketProcessIdPort(4714 + nodeName);
-		coreEnvironmentBean.setNodeIdentifier(nodeName);
-		coreEnvironmentBean.setSocketProcessIdMaxPorts(1);
-
-		CoordinatorEnvironmentBean coordinatorEnvironmentBean = com.arjuna.ats.arjuna.common.arjPropertyManager.getCoordinatorEnvironmentBean();
-		coordinatorEnvironmentBean.setEnableStatistics(false);
-		coordinatorEnvironmentBean.setDefaultTimeout(300);
-		coordinatorEnvironmentBean.setTransactionStatusManagerEnable(false);
-		coordinatorEnvironmentBean.setDefaultTimeout(0);
-
-		ObjectStoreEnvironmentBean actionStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(
-				com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "default");
-		actionStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/tmp/tx-object-store/" + nodeName);
-
-		ObjectStoreEnvironmentBean stateStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(
-				com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "stateStore");
-		stateStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/tmp/tx-object-store/" + nodeName);
-
-		ObjectStoreEnvironmentBean communicationStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator
-				.getNamedInstance(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "communicationStore");
-		communicationStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/tmp/tx-object-store/" + nodeName);
-
-		ObjStoreBrowser objStoreBrowser = new ObjStoreBrowser();
-		Map<String, String> types = new HashMap<String, String>();
-		types.put("StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction", "com.arjuna.ats.internal.jta.tools.osb.mbean.jta.JTAActionBean");
-		objStoreBrowser.setTypes(types);
-
-		JTAEnvironmentBean jTAEnvironmentBean = com.arjuna.ats.jta.common.jtaPropertyManager.getJTAEnvironmentBean();
-		jTAEnvironmentBean.setLastResourceOptimisationInterface(org.jboss.tm.LastResource.class);
-		jTAEnvironmentBean.setTransactionManagerClassName("com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate");
-		jTAEnvironmentBean.setUserTransactionClassName("com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple");
-		jTAEnvironmentBean
-				.setTransactionSynchronizationRegistryClassName("com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple");
-		List<Integer> xaRecoveryNodes = new ArrayList<Integer>();
-		xaRecoveryNodes.add(nodeName);
-		jTAEnvironmentBean.setXaRecoveryNodes(xaRecoveryNodes);
-
-		List<String> xaResourceOrphanFilterClassNames = new ArrayList<String>();
-
-		xaResourceOrphanFilterClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter");
-		xaResourceOrphanFilterClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter");
-		xaResourceOrphanFilterClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinateJTAXAResourceOrphanFilter");
-		jTAEnvironmentBean.setXaResourceOrphanFilterClassNames(xaResourceOrphanFilterClassNames);
-		jTAEnvironmentBean.setXAResourceRecordWrappingPlugin(new XAResourceRecordWrappingPluginImpl());
-
-		recoveryManagerService = new RecoveryManagerService();
-		recoveryManagerService.create();
-		recoveryManagerService.addXAResourceRecovery(new ProxyXAResourceRecovery(lookupProvider, nodeName));
-		recoveryManagerService.addXAResourceRecovery(new TestResourceRecovery(counter, nodeName));
-		
-		// recoveryManagerService.start();
-		_recoveryManager = RecoveryManager.manager();
-		RecoveryManager.manager().initialize();
-
-		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();
-	}
-
-	@Override
-	public boolean getAndResumeTransaction(int remainingTimeout, Xid toResume) throws XAException, InvalidTransactionException, IllegalStateException,
-			SystemException {
-		boolean existed = true;
-		Transaction transaction = transactions.get(new SubordinateXidImple(toResume));
-		if (transaction == null) {
-			transaction = SubordinationManager.getTransactionImporter().getImportedTransaction(toResume);
-			if (transaction == null) {
-				transaction = SubordinationManager.getTransactionImporter().importTransaction(toResume, remainingTimeout);
-				existed = false;
-			}
-		}
-		transactionManagerService.getTransactionManager().resume(transaction);
-		return existed;
-	}
-
-	@Override
-	public Integer getNodeName() {
-		return nodeName;
-	}
-
-	@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();
-		transactions.put(new SubordinateXidImple(txId), transaction);
-	}
-
-	@Override
-	public Xid getCurrentXid() throws SystemException {
-		TransactionImple transaction = ((TransactionImple) transactionManagerService.getTransactionManager().getTransaction());
-		return transaction.getTxId();
-	}
-
-	@Override
-	public void removeRootTransaction(Xid toMigrate) {
-		transactions.remove(new SubordinateXidImple(toMigrate));
-	}
-
-	@Override
-	public ProxyXAResource generateProxyXAResource(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName) {
-		return new ProxyXAResource(lookupProvider, localServerName, remoteServerName);
-	}
-
-	@Override
-	public Synchronization generateProxySynchronization(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName, Xid toRegisterAgainst) {
-		return new ProxySynchronization(lookupProvider, localServerName, remoteServerName, toRegisterAgainst);
-	}
-
-	@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);
-		}
-		SubordinateTransaction tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
-		return SubordinationManager.getXATerminator().prepare(xid);
-	}
-
-	@Override
-	public void propagateCommit(Xid xid) throws XAException, DummyRemoteException {
-		if (offline) {
-			throw new DummyRemoteException("Connection refused to: " + nodeName);
-		}
-		SubordinationManager.getXATerminator().commit(xid, false);
-	}
-
-	@Override
-	public void propagateRollback(Xid xid) throws XAException, DummyRemoteException {
-		if (offline) {
-			throw new DummyRemoteException("Connection refused to: " + nodeName);
-		}
-		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]);
-				}
-			}
-		}
-		return toReturn.toArray(new Xid[0]);
-	}
-
-	@Override
-	public void propagateForget(Xid xid) throws XAException, DummyRemoteException {
-		if (offline) {
-			throw new DummyRemoteException("Connection refused to: " + nodeName);
-		}
-		SubordinationManager.getXATerminator().forget(xid);
-
-	}
-
-	@Override
-	public void propagateBeforeCompletion(Xid xid) throws XAException, SystemException, DummyRemoteException {
-		if (offline) {
-			throw new DummyRemoteException("Connection refused to: " + nodeName);
-		}
-		((XATerminatorImple) SubordinationManager.getXATerminator()).beforeCompletion(xid);
-	}
-
-	@Override
-	public Xid extractXid(XAResource xaResource) {
-		ProxyXAResource proxyXAResource = (ProxyXAResource) xaResource;
-		return proxyXAResource.getXid();
-	}
-
-	@Override
-	public CompletionCounter getCompletionCounter() {
-		return counter;
-	}
-}

Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java (from rev 37599, labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java	                        (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -0,0 +1,356 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.jta.distributed.example.server.impl;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.RollbackException;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAException;
+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;
+import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean;
+import com.arjuna.ats.arjuna.common.RecoveryEnvironmentBean;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
+import com.arjuna.ats.arjuna.recovery.RecoveryManager;
+import com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBrowser;
+import com.arjuna.ats.internal.jbossatx.jta.XAResourceRecordWrappingPluginImpl;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateXidImple;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinationManager;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple;
+import com.arjuna.ats.jbossatx.jta.RecoveryManagerService;
+import com.arjuna.ats.jbossatx.jta.TransactionManagerService;
+import com.arjuna.ats.jta.common.JTAEnvironmentBean;
+import com.arjuna.jta.distributed.example.TestResourceRecovery;
+import com.arjuna.jta.distributed.example.server.CompletionCounter;
+import com.arjuna.jta.distributed.example.server.DummyRemoteException;
+import com.arjuna.jta.distributed.example.server.LocalServer;
+import com.arjuna.jta.distributed.example.server.LookupProvider;
+import com.arjuna.jta.distributed.example.server.RemoteServer;
+
+public class ServerImpl implements LocalServer, RemoteServer {
+
+	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);
+
+		recoveryEnvironmentBean.setRecoveryInetAddress(InetAddress.getByName("localhost"));
+		recoveryEnvironmentBean.setRecoveryPort(4712 + nodeName);
+		recoveryEnvironmentBean.setTransactionStatusManagerInetAddress(InetAddress.getByName("localhost"));
+		recoveryEnvironmentBean.setTransactionStatusManagerPort(4713 + nodeName);
+		List<String> recoveryModuleClassNames = new ArrayList<String>();
+
+		recoveryModuleClassNames.add("com.arjuna.ats.internal.arjuna.recovery.AtomicActionRecoveryModule");
+		recoveryModuleClassNames.add("com.arjuna.ats.internal.txoj.recovery.TORecoveryModule");
+		recoveryModuleClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule");
+		recoveryEnvironmentBean.setRecoveryModuleClassNames(recoveryModuleClassNames);
+		List<String> expiryScannerClassNames = new ArrayList<String>();
+		expiryScannerClassNames.add("com.arjuna.ats.internal.arjuna.recovery.ExpiredTransactionStatusManagerScanner");
+		recoveryEnvironmentBean.setExpiryScannerClassNames(expiryScannerClassNames);
+		recoveryEnvironmentBean.setRecoveryActivators(null);
+
+		CoreEnvironmentBean coreEnvironmentBean = com.arjuna.ats.arjuna.common.arjPropertyManager.getCoreEnvironmentBean();
+		coreEnvironmentBean.setSocketProcessIdPort(4714 + nodeName);
+		coreEnvironmentBean.setNodeIdentifier(nodeName);
+		coreEnvironmentBean.setSocketProcessIdMaxPorts(1);
+
+		CoordinatorEnvironmentBean coordinatorEnvironmentBean = com.arjuna.ats.arjuna.common.arjPropertyManager.getCoordinatorEnvironmentBean();
+		coordinatorEnvironmentBean.setEnableStatistics(false);
+		coordinatorEnvironmentBean.setDefaultTimeout(300);
+		coordinatorEnvironmentBean.setTransactionStatusManagerEnable(false);
+		coordinatorEnvironmentBean.setDefaultTimeout(0);
+
+		ObjectStoreEnvironmentBean actionStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(
+				com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "default");
+		actionStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/tmp/tx-object-store/" + nodeName);
+
+		ObjectStoreEnvironmentBean stateStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(
+				com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "stateStore");
+		stateStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/tmp/tx-object-store/" + nodeName);
+
+		ObjectStoreEnvironmentBean communicationStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator
+				.getNamedInstance(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "communicationStore");
+		communicationStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/tmp/tx-object-store/" + nodeName);
+
+		ObjStoreBrowser objStoreBrowser = new ObjStoreBrowser();
+		Map<String, String> types = new HashMap<String, String>();
+		types.put("StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction", "com.arjuna.ats.internal.jta.tools.osb.mbean.jta.JTAActionBean");
+		objStoreBrowser.setTypes(types);
+
+		JTAEnvironmentBean jTAEnvironmentBean = com.arjuna.ats.jta.common.jtaPropertyManager.getJTAEnvironmentBean();
+		jTAEnvironmentBean.setLastResourceOptimisationInterface(org.jboss.tm.LastResource.class);
+		jTAEnvironmentBean.setTransactionManagerClassName("com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate");
+		jTAEnvironmentBean.setUserTransactionClassName("com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple");
+		jTAEnvironmentBean
+				.setTransactionSynchronizationRegistryClassName("com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple");
+		List<Integer> xaRecoveryNodes = new ArrayList<Integer>();
+		xaRecoveryNodes.add(nodeName);
+		jTAEnvironmentBean.setXaRecoveryNodes(xaRecoveryNodes);
+
+		List<String> xaResourceOrphanFilterClassNames = new ArrayList<String>();
+
+		xaResourceOrphanFilterClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter");
+		xaResourceOrphanFilterClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter");
+		xaResourceOrphanFilterClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinateJTAXAResourceOrphanFilter");
+		jTAEnvironmentBean.setXaResourceOrphanFilterClassNames(xaResourceOrphanFilterClassNames);
+		jTAEnvironmentBean.setXAResourceRecordWrappingPlugin(new XAResourceRecordWrappingPluginImpl());
+
+		recoveryManagerService = new RecoveryManagerService();
+		recoveryManagerService.create();
+		recoveryManagerService.addXAResourceRecovery(new ProxyXAResourceRecovery(lookupProvider, nodeName));
+		recoveryManagerService.addXAResourceRecovery(new TestResourceRecovery(counter, nodeName));
+		
+		// recoveryManagerService.start();
+		_recoveryManager = RecoveryManager.manager();
+		RecoveryManager.manager().initialize();
+
+		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();
+	}
+
+	@Override
+	public boolean getAndResumeTransaction(int remainingTimeout, Xid toResume) throws XAException, InvalidTransactionException, IllegalStateException,
+			SystemException {
+		boolean existed = true;
+		Transaction transaction = transactions.get(new SubordinateXidImple(toResume));
+		if (transaction == null) {
+			transaction = SubordinationManager.getTransactionImporter().getImportedTransaction(toResume);
+			if (transaction == null) {
+				transaction = SubordinationManager.getTransactionImporter().importTransaction(toResume, remainingTimeout);
+				existed = false;
+			}
+		}
+		transactionManagerService.getTransactionManager().resume(transaction);
+		return existed;
+	}
+
+	@Override
+	public Integer getNodeName() {
+		return nodeName;
+	}
+
+	@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();
+		transactions.put(new SubordinateXidImple(txId), transaction);
+	}
+
+	@Override
+	public Xid getCurrentXid() throws SystemException {
+		TransactionImple transaction = ((TransactionImple) transactionManagerService.getTransactionManager().getTransaction());
+		return transaction.getTxId();
+	}
+
+	@Override
+	public void removeRootTransaction(Xid toMigrate) {
+		transactions.remove(new SubordinateXidImple(toMigrate));
+	}
+
+	@Override
+	public ProxyXAResource generateProxyXAResource(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName) {
+		return new ProxyXAResource(lookupProvider, localServerName, remoteServerName);
+	}
+
+	@Override
+	public Synchronization generateProxySynchronization(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName, Xid toRegisterAgainst) {
+		return new ProxySynchronization(lookupProvider, localServerName, remoteServerName, toRegisterAgainst);
+	}
+
+	@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);
+		}
+		SubordinateTransaction tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
+		return SubordinationManager.getXATerminator().prepare(xid);
+	}
+
+	@Override
+	public void propagateCommit(Xid xid) throws XAException, DummyRemoteException {
+		if (offline) {
+			throw new DummyRemoteException("Connection refused to: " + nodeName);
+		}
+		SubordinationManager.getXATerminator().commit(xid, false);
+	}
+
+	@Override
+	public void propagateRollback(Xid xid) throws XAException, DummyRemoteException {
+		if (offline) {
+			throw new DummyRemoteException("Connection refused to: " + nodeName);
+		}
+		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]);
+				}
+			}
+		}
+		return toReturn.toArray(new Xid[0]);
+	}
+
+	@Override
+	public void propagateForget(Xid xid) throws XAException, DummyRemoteException {
+		if (offline) {
+			throw new DummyRemoteException("Connection refused to: " + nodeName);
+		}
+		SubordinationManager.getXATerminator().forget(xid);
+
+	}
+
+	@Override
+	public void propagateBeforeCompletion(Xid xid) throws XAException, SystemException, DummyRemoteException {
+		if (offline) {
+			throw new DummyRemoteException("Connection refused to: " + nodeName);
+		}
+		((XATerminatorImple) SubordinationManager.getXATerminator()).beforeCompletion(xid);
+	}
+
+	@Override
+	public Xid extractXid(XAResource xaResource) {
+		ProxyXAResource proxyXAResource = (ProxyXAResource) xaResource;
+		return proxyXAResource.getXid();
+	}
+
+	@Override
+	public CompletionCounter getCompletionCounter() {
+		return counter;
+	}
+}

Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/server/impl/ProxySynchronization.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxySynchronization.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/server/impl/ProxySynchronization.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package com.arjuna.ats.jta.distributed.server.impl;
-
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.Xid;
-
-import com.arjuna.ats.jta.distributed.server.DummyRemoteException;
-import com.arjuna.ats.jta.distributed.server.LookupProvider;
-
-public class ProxySynchronization implements Synchronization {
-
-	private int localServerName;
-	private int remoteServerName;
-	private Xid toRegisterAgainst;
-	private LookupProvider lookupProvider;
-
-	public ProxySynchronization(LookupProvider lookupProvider, int localServerName, int remoteServerName, Xid toRegisterAgainst) {
-		this.lookupProvider = lookupProvider;
-		this.localServerName = localServerName;
-		this.remoteServerName = remoteServerName;
-		this.toRegisterAgainst = toRegisterAgainst;
-	}
-
-	@Override
-	public void beforeCompletion() {
-		System.out.println("ProxySynchronization (" + localServerName + ":" + remoteServerName + ") beforeCompletion");
-		try {
-			lookupProvider.lookup(remoteServerName).propagateBeforeCompletion(toRegisterAgainst);
-		} catch (XAException e) {
-			e.printStackTrace();
-		} catch (SystemException e) {
-			e.printStackTrace();
-		} catch (DummyRemoteException e) {
-			e.printStackTrace();
-		}
-	}
-
-	@Override
-	public void afterCompletion(int status) {
-		// These are not proxied but are handled during local commits
-	}
-}

Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/server/impl/ProxyXAResource.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/server/impl/ProxyXAResource.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -1,287 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package com.arjuna.ats.jta.distributed.server.impl;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import org.jboss.tm.XAResourceWrapper;
-
-import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
-import com.arjuna.ats.jta.distributed.server.DummyRemoteException;
-import com.arjuna.ats.jta.distributed.server.LookupProvider;
-
-public class ProxyXAResource implements XAResource, XAResourceWrapper {
-
-	private int transactionTimeout;
-	private Integer remoteServerName = -1;
-	private File file;
-	private Integer localServerName;
-	private LookupProvider lookupProvider;
-	private Xid xid;
-
-	public ProxyXAResource(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName) {
-		this.lookupProvider = lookupProvider;
-		this.localServerName = localServerName;
-		this.remoteServerName = remoteServerName;
-	}
-
-	public ProxyXAResource(LookupProvider lookupProvider, Integer localServerName, File file) throws IOException {
-		this.lookupProvider = lookupProvider;
-		this.localServerName = localServerName;
-		this.file = file;
-		DataInputStream fis = new DataInputStream(new FileInputStream(file));
-		this.remoteServerName = fis.readInt();
-		final int formatId = fis.readInt();
-		int gtrid_length = fis.readInt();
-		final byte[] gtrid = new byte[gtrid_length];
-		fis.read(gtrid, 0, gtrid_length);
-		int bqual_length = fis.readInt();
-		final byte[] bqual = new byte[bqual_length];
-		fis.read(bqual, 0, bqual_length);
-		this.xid = new Xid() {
-			@Override
-			public byte[] getBranchQualifier() {
-				return bqual;
-			}
-
-			@Override
-			public int getFormatId() {
-				return formatId;
-			}
-
-			@Override
-			public byte[] getGlobalTransactionId() {
-				return gtrid;
-			}
-		};
-	}
-
-	@Override
-	public void start(Xid xid, int flags) throws XAException {
-		System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_START   [" + xid + "]");
-		this.xid = xid;
-	}
-
-	@Override
-	public void end(Xid xid, int flags) throws XAException {
-		System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_END     [" + xid + "]");
-		this.xid = null;
-	}
-
-	@Override
-	public synchronized int prepare(Xid xid) throws XAException {
-		System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_PREPARE [" + xid + "]");
-
-		try {
-			File dir = new File(System.getProperty("user.dir") + "/tmp/ProxyXAResource/" + localServerName + "/");
-			dir.mkdirs();
-			file = new File(dir, new Uid().fileStringForm());
-			file.createNewFile();
-			DataOutputStream fos = new DataOutputStream(new FileOutputStream(file));
-			fos.writeInt(remoteServerName);
-			fos.writeInt(xid.getFormatId());
-			fos.writeInt(xid.getGlobalTransactionId().length);
-			fos.write(xid.getGlobalTransactionId());
-			fos.writeInt(xid.getBranchQualifier().length);
-			fos.write(xid.getBranchQualifier());
-		} catch (IOException e) {
-			e.printStackTrace();
-			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);
-		}
-
-	}
-
-	/**
-	 * The remote side will not accept a one phase optimization.
-	 */
-	@Override
-	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) {
-			file.delete();
-		}
-	}
-
-	@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) {
-			file.delete();
-		}
-	}
-
-	@Override
-	public Xid[] recover(int flag) throws XAException {
-		Xid[] recovered = null;
-		if ((flag & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN) {
-			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVER [XAResource.TMSTARTRSCAN]: "
-					+ remoteServerName);
-		}
-		if ((flag & XAResource.TMENDRSCAN) == XAResource.TMENDRSCAN) {
-			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVER [XAResource.TMENDRSCAN]: "
-					+ remoteServerName);
-		}
-
-		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);
-			}
-		}
-
-		for (int i = 0; i < recovered.length; i++) {
-			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") recovered: " + recovered[i]);
-		}
-
-		Xid[] toReturn = null;
-		if ((flag & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN) {
-			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVERD[XAResource.TMSTARTRSCAN]: "
-					+ remoteServerName);
-			toReturn = new Xid[] { xid };
-		}
-		if ((flag & XAResource.TMENDRSCAN) == XAResource.TMENDRSCAN) {
-			System.out.println("     ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVERD[XAResource.TMENDRSCAN]: "
-					+ remoteServerName);
-		}
-		return toReturn;
-	}
-
-	@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);
-		}
-	}
-
-	@Override
-	public int getTransactionTimeout() throws XAException {
-		return transactionTimeout;
-	}
-
-	@Override
-	public boolean setTransactionTimeout(int seconds) throws XAException {
-		this.transactionTimeout = seconds;
-		return true;
-	}
-
-	@Override
-	public boolean isSameRM(XAResource xares) throws XAException {
-		boolean toReturn = false;
-		if (xares instanceof ProxyXAResource) {
-			if (((ProxyXAResource) xares).remoteServerName == remoteServerName) {
-				toReturn = true;
-			}
-		}
-		return toReturn;
-	}
-
-	/**
-	 * I don't think this is used by TM.
-	 */
-	@Override
-	public XAResource getResource() {
-		return null;
-	}
-
-	/**
-	 * I don't think this is used by TM.
-	 */
-	@Override
-	public String getProductName() {
-		return null;
-	}
-
-	/**
-	 * I don't think this is used by TM.
-	 */
-	@Override
-	public String getProductVersion() {
-		return null;
-	}
-
-	@Override
-	public String getJndiName() {
-		return "ProxyXAResource";
-	}
-
-	public Xid getXid() {
-		return xid;
-	}
-}

Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/server/impl/ProxyXAResourceRecovery.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResourceRecovery.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/server/impl/ProxyXAResourceRecovery.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package com.arjuna.ats.jta.distributed.server.impl;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.transaction.xa.XAResource;
-
-import org.jboss.tm.XAResourceRecovery;
-
-import com.arjuna.ats.jta.distributed.server.LookupProvider;
-
-public class ProxyXAResourceRecovery implements XAResourceRecovery {
-
-	private List<ProxyXAResource> resources = new ArrayList<ProxyXAResource>();
-
-	public ProxyXAResourceRecovery(LookupProvider lookupProvider, int id) throws IOException {
-		File file = new File(System.getProperty("user.dir") + "/tmp/ProxyXAResource/" + id + "/");
-		if (file.exists() && file.isDirectory()) {
-			File[] listFiles = file.listFiles();
-			for (int i = 0; i < listFiles.length; i++) {
-				File currentFile = listFiles[i];
-				resources.add(new ProxyXAResource(lookupProvider, id, currentFile));
-			}
-		}
-	}
-
-	@Override
-	public XAResource[] getXAResources() {
-		return resources.toArray(new XAResource[] {});
-	}
-
-}

Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/server/impl/ServerImpl.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java	2011-10-19 08:37:36 UTC (rev 37599)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/server/impl/ServerImpl.java	2011-10-19 08:49:49 UTC (rev 37600)
@@ -1,356 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package com.arjuna.ats.jta.distributed.server.impl;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.RollbackException;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import javax.transaction.xa.XAException;
-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;
-import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean;
-import com.arjuna.ats.arjuna.common.RecoveryEnvironmentBean;
-import com.arjuna.ats.arjuna.coordinator.TxControl;
-import com.arjuna.ats.arjuna.recovery.RecoveryManager;
-import com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBrowser;
-import com.arjuna.ats.internal.jbossatx.jta.XAResourceRecordWrappingPluginImpl;
-import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple;
-import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction;
-import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateXidImple;
-import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinationManager;
-import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple;
-import com.arjuna.ats.jbossatx.jta.RecoveryManagerService;
-import com.arjuna.ats.jbossatx.jta.TransactionManagerService;
-import com.arjuna.ats.jta.common.JTAEnvironmentBean;
-import com.arjuna.ats.jta.distributed.server.CompletionCounter;
-import com.arjuna.ats.jta.distributed.server.DummyRemoteException;
-import com.arjuna.ats.jta.distributed.server.LocalServer;
-import com.arjuna.ats.jta.distributed.server.LookupProvider;
-import com.arjuna.ats.jta.distributed.server.RemoteServer;
-import com.arjuna.jta.distributed.example.TestResourceRecovery;
-
-public class ServerImpl implements LocalServer, RemoteServer {
-
-	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);
-
-		recoveryEnvironmentBean.setRecoveryInetAddress(InetAddress.getByName("localhost"));
-		recoveryEnvironmentBean.setRecoveryPort(4712 + nodeName);
-		recoveryEnvironmentBean.setTransactionStatusManagerInetAddress(InetAddress.getByName("localhost"));
-		recoveryEnvironmentBean.setTransactionStatusManagerPort(4713 + nodeName);
-		List<String> recoveryModuleClassNames = new ArrayList<String>();
-
-		recoveryModuleClassNames.add("com.arjuna.ats.internal.arjuna.recovery.AtomicActionRecoveryModule");
-		recoveryModuleClassNames.add("com.arjuna.ats.internal.txoj.recovery.TORecoveryModule");
-		recoveryModuleClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule");
-		recoveryEnvironmentBean.setRecoveryModuleClassNames(recoveryModuleClassNames);
-		List<String> expiryScannerClassNames = new ArrayList<String>();
-		expiryScannerClassNames.add("com.arjuna.ats.internal.arjuna.recovery.ExpiredTransactionStatusManagerScanner");
-		recoveryEnvironmentBean.setExpiryScannerClassNames(expiryScannerClassNames);
-		recoveryEnvironmentBean.setRecoveryActivators(null);
-
-		CoreEnvironmentBean coreEnvironmentBean = com.arjuna.ats.arjuna.common.arjPropertyManager.getCoreEnvironmentBean();
-		coreEnvironmentBean.setSocketProcessIdPort(4714 + nodeName);
-		coreEnvironmentBean.setNodeIdentifier(nodeName);
-		coreEnvironmentBean.setSocketProcessIdMaxPorts(1);
-
-		CoordinatorEnvironmentBean coordinatorEnvironmentBean = com.arjuna.ats.arjuna.common.arjPropertyManager.getCoordinatorEnvironmentBean();
-		coordinatorEnvironmentBean.setEnableStatistics(false);
-		coordinatorEnvironmentBean.setDefaultTimeout(300);
-		coordinatorEnvironmentBean.setTransactionStatusManagerEnable(false);
-		coordinatorEnvironmentBean.setDefaultTimeout(0);
-
-		ObjectStoreEnvironmentBean actionStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(
-				com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "default");
-		actionStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/tmp/tx-object-store/" + nodeName);
-
-		ObjectStoreEnvironmentBean stateStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(
-				com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "stateStore");
-		stateStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/tmp/tx-object-store/" + nodeName);
-
-		ObjectStoreEnvironmentBean communicationStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator
-				.getNamedInstance(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "communicationStore");
-		communicationStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/tmp/tx-object-store/" + nodeName);
-
-		ObjStoreBrowser objStoreBrowser = new ObjStoreBrowser();
-		Map<String, String> types = new HashMap<String, String>();
-		types.put("StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction", "com.arjuna.ats.internal.jta.tools.osb.mbean.jta.JTAActionBean");
-		objStoreBrowser.setTypes(types);
-
-		JTAEnvironmentBean jTAEnvironmentBean = com.arjuna.ats.jta.common.jtaPropertyManager.getJTAEnvironmentBean();
-		jTAEnvironmentBean.setLastResourceOptimisationInterface(org.jboss.tm.LastResource.class);
-		jTAEnvironmentBean.setTransactionManagerClassName("com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate");
-		jTAEnvironmentBean.setUserTransactionClassName("com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple");
-		jTAEnvironmentBean
-				.setTransactionSynchronizationRegistryClassName("com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple");
-		List<Integer> xaRecoveryNodes = new ArrayList<Integer>();
-		xaRecoveryNodes.add(nodeName);
-		jTAEnvironmentBean.setXaRecoveryNodes(xaRecoveryNodes);
-
-		List<String> xaResourceOrphanFilterClassNames = new ArrayList<String>();
-
-		xaResourceOrphanFilterClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter");
-		xaResourceOrphanFilterClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter");
-		xaResourceOrphanFilterClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinateJTAXAResourceOrphanFilter");
-		jTAEnvironmentBean.setXaResourceOrphanFilterClassNames(xaResourceOrphanFilterClassNames);
-		jTAEnvironmentBean.setXAResourceRecordWrappingPlugin(new XAResourceRecordWrappingPluginImpl());
-
-		recoveryManagerService = new RecoveryManagerService();
-		recoveryManagerService.create();
-		recoveryManagerService.addXAResourceRecovery(new ProxyXAResourceRecovery(lookupProvider, nodeName));
-		recoveryManagerService.addXAResourceRecovery(new TestResourceRecovery(counter, nodeName));
-		
-		// recoveryManagerService.start();
-		_recoveryManager = RecoveryManager.manager();
-		RecoveryManager.manager().initialize();
-
-		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();
-	}
-
-	@Override
-	public boolean getAndResumeTransaction(int remainingTimeout, Xid toResume) throws XAException, InvalidTransactionException, IllegalStateException,
-			SystemException {
-		boolean existed = true;
-		Transaction transaction = transactions.get(new SubordinateXidImple(toResume));
-		if (transaction == null) {
-			transaction = SubordinationManager.getTransactionImporter().getImportedTransaction(toResume);
-			if (transaction == null) {
-				transaction = SubordinationManager.getTransactionImporter().importTransaction(toResume, remainingTimeout);
-				existed = false;
-			}
-		}
-		transactionManagerService.getTransactionManager().resume(transaction);
-		return existed;
-	}
-
-	@Override
-	public Integer getNodeName() {
-		return nodeName;
-	}
-
-	@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();
-		transactions.put(new SubordinateXidImple(txId), transaction);
-	}
-
-	@Override
-	public Xid getCurrentXid() throws SystemException {
-		TransactionImple transaction = ((TransactionImple) transactionManagerService.getTransactionManager().getTransaction());
-		return transaction.getTxId();
-	}
-
-	@Override
-	public void removeRootTransaction(Xid toMigrate) {
-		transactions.remove(new SubordinateXidImple(toMigrate));
-	}
-
-	@Override
-	public ProxyXAResource generateProxyXAResource(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName) {
-		return new ProxyXAResource(lookupProvider, localServerName, remoteServerName);
-	}
-
-	@Override
-	public Synchronization generateProxySynchronization(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName, Xid toRegisterAgainst) {
-		return new ProxySynchronization(lookupProvider, localServerName, remoteServerName, toRegisterAgainst);
-	}
-
-	@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);
-		}
-		SubordinateTransaction tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
-		return SubordinationManager.getXATerminator().prepare(xid);
-	}
-
-	@Override
-	public void propagateCommit(Xid xid) throws XAException, DummyRemoteException {
-		if (offline) {
-			throw new DummyRemoteException("Connection refused to: " + nodeName);
-		}
-		SubordinationManager.getXATerminator().commit(xid, false);
-	}
-
-	@Override
-	public void propagateRollback(Xid xid) throws XAException, DummyRemoteException {
-		if (offline) {
-			throw new DummyRemoteException("Connection refused to: " + nodeName);
-		}
-		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]);
-				}
-			}
-		}
-		return toReturn.toArray(new Xid[0]);
-	}
-
-	@Override
-	public void propagateForget(Xid xid) throws XAException, DummyRemoteException {
-		if (offline) {
-			throw new DummyRemoteException("Connection refused to: " + nodeName);
-		}
-		SubordinationManager.getXATerminator().forget(xid);
-
-	}
-
-	@Override
-	public void propagateBeforeCompletion(Xid xid) throws XAException, SystemException, DummyRemoteException {
-		if (offline) {
-			throw new DummyRemoteException("Connection refused to: " + nodeName);
-		}
-		((XATerminatorImple) SubordinationManager.getXATerminator()).beforeCompletion(xid);
-	}
-
-	@Override
-	public Xid extractXid(XAResource xaResource) {
-		ProxyXAResource proxyXAResource = (ProxyXAResource) xaResource;
-		return proxyXAResource.getXid();
-	}
-
-	@Override
-	public CompletionCounter getCompletionCounter() {
-		return counter;
-	}
-}



More information about the jboss-svn-commits mailing list