geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r927980 - in /geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1: ./ geronimo-connector/src/main/java/org/apache/geronimo/connector/ geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ geronimo-transac...
Date Fri, 26 Mar 2010 17:39:21 GMT
Author: djencks
Date: Fri Mar 26 17:39:20 2010
New Revision: 927980

URL: http://svn.apache.org/viewvc?rev=927980&view=rev
Log:
GERONIMO-5152 port retry work from trunk

Added:
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/ActivationSpecNamedXAResourceFactory.java
      - copied unchanged from r911974, geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/ActivationSpecNamedXAResourceFactory.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/OutboundNamedXAResourceFactory.java
      - copied unchanged from r911974, geronimo/components/txmanager/trunk/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/OutboundNamedXAResourceFactory.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/CommitTask.java
      - copied, changed from r912058, geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/CommitTask.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/ExponentialtIntervalRetryScheduler.java
      - copied, changed from r912058, geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/ExponentialtIntervalRetryScheduler.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/NamedXAResourceFactory.java
      - copied unchanged from r911974, geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/NamedXAResourceFactory.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverTask.java
      - copied, changed from r912058, geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverTask.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RetryScheduler.java
      - copied, changed from r912058, geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RetryScheduler.java
Modified:
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/   (props changed)
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/ActivationSpecWrapper.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/ResourceAdapterWrapper.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/log/HOWLLog.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/log/UnrecoverableLog.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverableTransactionManager.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/Recovery.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoveryImpl.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionLog.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/XidImporter.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/AbstractRecoveryTest.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockLog.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockResource.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockResourceManager.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/RecoveryTest.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/TransactionManagerImplTest.java
    geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/XATransactionTester.java

Propchange: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 26 17:39:20 2010
@@ -1 +1 @@
-/geronimo/components/txmanager/trunk:900557
+/geronimo/components/txmanager/trunk:900557,911974,912058,912297,912468

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/ActivationSpecWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/ActivationSpecWrapper.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/ActivationSpecWrapper.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/ActivationSpecWrapper.java Fri Mar 26 17:39:20 2010
@@ -101,6 +101,7 @@ public class ActivationSpecWrapper {
     public void deactivate(final MessageEndpointFactory messageEndpointFactory) {
         ResourceAdapter resourceAdapter = activationSpec.getResourceAdapter();
         if (resourceAdapter != null) {
+            resourceAdapterWrapper.deregisterRecovery(containerId);
             resourceAdapterWrapper.endpointDeactivation(messageEndpointFactory, activationSpec);
         } else {
             //this should never happen, activation spec should have been registered with r.a.

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/ResourceAdapterWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/ResourceAdapterWrapper.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/ResourceAdapterWrapper.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/ResourceAdapterWrapper.java Fri Mar 26 17:39:20 2010
@@ -30,6 +30,7 @@ import javax.transaction.SystemException
 import javax.transaction.xa.XAResource;
 
 import org.apache.geronimo.transaction.manager.NamedXAResource;
+import org.apache.geronimo.transaction.manager.NamedXAResourceFactory;
 import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
 import org.apache.geronimo.transaction.manager.WrapperNamedXAResource;
 
@@ -124,17 +125,11 @@ public class ResourceAdapterWrapper impl
     }
 
     public void doRecovery(ActivationSpec activationSpec, String containerId) {
-        try {
-            XAResource[] xaResources = getXAResources(new ActivationSpec[]{activationSpec});
-            if (xaResources == null || xaResources.length == 0) {
-                return;
-            }
-            NamedXAResource xaResource = new WrapperNamedXAResource(xaResources[0], containerId);
-            transactionManager.recoverResourceManager(xaResource);
-        } catch (ResourceException e) {
-            transactionManager.recoveryError((SystemException) new SystemException("Could not get XAResource for recovery for mdb: " + containerId).initCause(e));
-        }
+        transactionManager.registerNamedXAResourceFactory(new ActivationSpecNamedXAResourceFactory(containerId, activationSpec, resourceAdapter));
+    }
 
+    public void deregisterRecovery(String containerId) {
+        transactionManager.unregisterNamedXAResourceFactory(containerId);
     }
 
     public void endpointDeactivation(final MessageEndpointFactory messageEndpointFactory, final ActivationSpec activationSpec) {

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java Fri Mar 26 17:39:20 2010
@@ -26,6 +26,7 @@ import javax.transaction.SystemException
 
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport;
 import org.apache.geronimo.transaction.manager.NamedXAResource;
+import org.apache.geronimo.transaction.manager.NamedXAResourceFactory;
 import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
 
 /**
@@ -34,16 +35,19 @@ import org.apache.geronimo.transaction.m
 public abstract class AbstractConnectionManager implements ConnectionManagerContainer, ConnectionManager, LazyAssociatableConnectionManager, PoolingAttributes {
     protected final Interceptors interceptors;
     private final RecoverableTransactionManager transactionManager;
+    private final String name;
 
-    //default constructor for use as endpoint
+    //default constructor to support externalizable subclasses
     public AbstractConnectionManager() {
         interceptors = null;
         transactionManager = null;
+        this.name = null;
     }
 
-    public AbstractConnectionManager(Interceptors interceptors, RecoverableTransactionManager transactionManager) {
+    public AbstractConnectionManager(Interceptors interceptors, RecoverableTransactionManager transactionManager, String name) {
         this.interceptors = interceptors;
         this.transactionManager = transactionManager;
+        this.name = name;
     }
 
     public Object createConnectionFactory(ManagedConnectionFactory mcf) throws ResourceException {
@@ -53,26 +57,12 @@ public abstract class AbstractConnection
     protected ConnectionManager getConnectionManager() {
         return this;
     }
-    
+
     public void doRecovery(ManagedConnectionFactory managedConnectionFactory) {
-        try {
-            if (!getIsRecoverable()) {
-                return;
-            }
-            ManagedConnectionInfo mci = new ManagedConnectionInfo(managedConnectionFactory, null);
-
-            ConnectionInfo recoveryConnectionInfo = new ConnectionInfo(mci);
-            getRecoveryStack().getConnection(recoveryConnectionInfo);
-
-            // For pooled resources, we may now have a new MCI (not the one constructed above). Make sure we use the correct MCI
-            NamedXAResource xaResource = (NamedXAResource) recoveryConnectionInfo.getManagedConnectionInfo().getXAResource();
-            if (xaResource != null) {
-                transactionManager.recoverResourceManager(xaResource);
-                getRecoveryStack().returnConnection(recoveryConnectionInfo, ConnectionReturnAction.DESTROY);
-            }
-        } catch (ResourceException e) {
-            transactionManager.recoveryError((SystemException)new SystemException("Could not obtain recovery XAResource for managedConnectionFactory " + managedConnectionFactory).initCause(e));
+        if (!getIsRecoverable()) {
+            return;
         }
+        transactionManager.registerNamedXAResourceFactory(new OutboundNamedXAResourceFactory(name, getRecoveryStack(), managedConnectionFactory));
     }
 
     /**
@@ -191,10 +181,12 @@ public abstract class AbstractConnection
     }
 
     public void doStop() throws Exception {
+        transactionManager.unregisterNamedXAResourceFactory(name);
         interceptors.getStack().destroy();
     }
 
     public void doFail() {
+        transactionManager.unregisterNamedXAResourceFactory(name);
         interceptors.getStack().destroy();
     }
 }

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java Fri Mar 26 17:39:20 2010
@@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
 public class GenericConnectionManager extends AbstractConnectionManager {
     protected static final Logger log = LoggerFactory.getLogger(AbstractSinglePoolConnectionInterceptor.class);
 
-    //default constructor for use as endpoint
+    //default constructor to support externalizable subclasses
     public GenericConnectionManager() {
         super();
     }
@@ -58,7 +58,7 @@ public class GenericConnectionManager ex
                                     RecoverableTransactionManager transactionManager,
                                     String name,
                                     ClassLoader classLoader) {
-        super(new InterceptorsImpl(transactionSupport, pooling, subjectSource, name, connectionTracker, transactionManager, classLoader), transactionManager);
+        super(new InterceptorsImpl(transactionSupport, pooling, subjectSource, name, connectionTracker, transactionManager, classLoader), transactionManager, name);
     }
 
     private static class InterceptorsImpl implements AbstractConnectionManager.Interceptors {

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/log/HOWLLog.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/log/HOWLLog.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/log/HOWLLog.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/log/HOWLLog.java Fri Mar 26 17:39:20 2010
@@ -67,7 +67,7 @@ public class HOWLLog implements Transact
     private final XALogger logger;
     private final Configuration configuration = new Configuration();
     private boolean started = false;
-    private HashMap recovered;
+    private HashMap<Xid, Recovery.XidBranchesPair> recovered;
 
     public HOWLLog(String bufferClassName,
                    int bufferSize,
@@ -219,7 +219,7 @@ public class HOWLLog implements Transact
         started = true;
         setLogFileDir(logFileDir);
         log.debug("Initiating transaction manager recovery");
-        recovered = new HashMap();
+        recovered = new HashMap<Xid, Recovery.XidBranchesPair>();
 
         logger.open(null);
 
@@ -241,15 +241,14 @@ public class HOWLLog implements Transact
     public void begin(Xid xid) throws LogException {
     }
 
-    public Object prepare(Xid xid, List branches) throws LogException {
+    public Object prepare(Xid xid, List<? extends TransactionBranchInfo> branches) throws LogException {
         int branchCount = branches.size();
         byte[][] data = new byte[3 + 2 * branchCount][];
         data[0] = intToBytes(xid.getFormatId());
         data[1] = xid.getGlobalTransactionId();
         data[2] = xid.getBranchQualifier();
         int i = 3;
-        for (Iterator iterator = branches.iterator(); iterator.hasNext();) {
-            TransactionBranchInfo transactionBranchInfo = (TransactionBranchInfo) iterator.next();
+        for (TransactionBranchInfo transactionBranchInfo : branches) {
             data[i++] = transactionBranchInfo.getBranchXid().getBranchQualifier();
             data[i++] = transactionBranchInfo.getResourceName().getBytes();
         }
@@ -315,9 +314,9 @@ public class HOWLLog implements Transact
         }
     }
 
-    public Collection recover(XidFactory xidFactory) throws LogException {
+    public Collection<Recovery.XidBranchesPair> recover(XidFactory xidFactory) throws LogException {
         log.debug("Initiating transaction manager recovery");
-        Map recovered = new HashMap();
+        Map<Xid, Recovery.XidBranchesPair> recovered = new HashMap<Xid, Recovery.XidBranchesPair>();
         ReplayListener replayListener = new GeronimoReplayListener(xidFactory, recovered);
         logger.replayActiveTx(replayListener);
         log.debug("In doubt transactions recovered from log");
@@ -352,9 +351,9 @@ public class HOWLLog implements Transact
     private class GeronimoReplayListener implements ReplayListener {
 
         private final XidFactory xidFactory;
-        private final Map recoveredTx;
+        private final Map<Xid, Recovery.XidBranchesPair> recoveredTx;
 
-        public GeronimoReplayListener(XidFactory xidFactory, Map recoveredTx) {
+        public GeronimoReplayListener(XidFactory xidFactory, Map<Xid, Recovery.XidBranchesPair> recoveredTx) {
             this.xidFactory = xidFactory;
             this.recoveredTx = recoveredTx;
         }

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/log/UnrecoverableLog.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/log/UnrecoverableLog.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/log/UnrecoverableLog.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/log/UnrecoverableLog.java Fri Mar 26 17:39:20 2010
@@ -24,6 +24,7 @@ import java.util.List;
 import javax.transaction.xa.Xid;
 
 import org.apache.geronimo.transaction.manager.LogException;
+import org.apache.geronimo.transaction.manager.TransactionBranchInfo;
 import org.apache.geronimo.transaction.manager.TransactionLog;
 import org.apache.geronimo.transaction.manager.XidFactory;
 
@@ -38,7 +39,7 @@ public class UnrecoverableLog implements
     public void begin(Xid xid) throws LogException {
     }
 
-    public Object prepare(Xid xid, List branches) throws LogException {
+    public Object prepare(Xid xid, List<? extends TransactionBranchInfo> branches) throws LogException {
         return null;
     }
 

Copied: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/CommitTask.java (from r912058, geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/CommitTask.java)
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/CommitTask.java?p2=geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/CommitTask.java&p1=geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/CommitTask.java&r1=912058&r2=927980&rev=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/CommitTask.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/CommitTask.java Fri Mar 26 17:39:20 2010
@@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory;
 /**
  * @version $Rev$ $Date$
  */
-public class CommitTask extends TimerTask {
+public class CommitTask implements Runnable {
     private static final Logger log = LoggerFactory.getLogger(CommitTask.class);
     private final Xid xid;
     private final List<TransactionBranch> rms;

Copied: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/ExponentialtIntervalRetryScheduler.java (from r912058, geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/ExponentialtIntervalRetryScheduler.java)
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/ExponentialtIntervalRetryScheduler.java?p2=geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/ExponentialtIntervalRetryScheduler.java&p1=geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/ExponentialtIntervalRetryScheduler.java&r1=912058&r2=927980&rev=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/ExponentialtIntervalRetryScheduler.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/ExponentialtIntervalRetryScheduler.java Fri Mar 26 17:39:20 2010
@@ -32,8 +32,22 @@ public class ExponentialtIntervalRetrySc
 
     private final int base = 2;
 
-    public void retry(TimerTask task, int count) {
+    public void retry(Runnable task, int count) {
         long interval = Math.round(Math.pow(base, count)) * 1000;
-        timer.schedule(task, interval);
+        timer.schedule(new TaskWrapper(task), interval);
+    }
+
+    private static class TaskWrapper extends TimerTask {
+
+        private final Runnable delegate;
+
+        private TaskWrapper(Runnable delegate) {
+            this.delegate = delegate;
+        }
+
+        @Override
+        public void run() {
+            delegate.run();
+        }
     }
 }

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java Fri Mar 26 17:39:20 2010
@@ -30,6 +30,8 @@ import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 
 /**
+ * Adds implementations of XATerminator and XAWork interfaces to basic TransactionManagerImpl
+ *
  * @version $Rev$ $Date$
  */
 public class GeronimoTransactionManager extends TransactionManagerImpl implements XATerminator, XAWork {
@@ -195,7 +197,7 @@ public class GeronimoTransactionManager 
                 throw new XAException("No imported transaction for xid: " + xid);
             }
             if (importedTransaction != getTransaction()) {
-                throw new XAException("Imported transaction is not associated with the curren thread xid: " + xid);
+                throw new XAException("Imported transaction is not associated with the current thread xid: " + xid);
             }
             suspend();
         }

Copied: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverTask.java (from r912058, geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverTask.java)
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverTask.java?p2=geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverTask.java&p1=geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverTask.java&r1=912058&r2=927980&rev=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverTask.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverTask.java Fri Mar 26 17:39:20 2010
@@ -28,7 +28,7 @@ import javax.transaction.xa.XAException;
 /**
  * @version $Rev$ $Date$
  */
-public class RecoverTask extends TimerTask {
+public class RecoverTask implements Runnable {
 
     private final RetryScheduler retryScheduler;
     private final NamedXAResourceFactory namedXAResourceFactory;

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverableTransactionManager.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverableTransactionManager.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverableTransactionManager.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoverableTransactionManager.java Fri Mar 26 17:39:20 2010
@@ -28,5 +28,7 @@ import javax.transaction.TransactionMana
 public interface RecoverableTransactionManager extends TransactionManager {
     void recoveryError(Exception e);
 
-    void recoverResourceManager(NamedXAResource xaResource);
+    void registerNamedXAResourceFactory(NamedXAResourceFactory namedXAResourceFactory);
+
+    void unregisterNamedXAResourceFactory(String namedXAResourceFactoryName);
 }

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/Recovery.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/Recovery.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/Recovery.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/Recovery.java Fri Mar 26 17:39:20 2010
@@ -47,13 +47,13 @@ public interface Recovery {
     //hard to implement.. needs ExternalTransaction to have a reference to externalXids.
 //    boolean remoteRecoveryComplete();
 
-    Map getExternalXids();
+    Map<Xid, TransactionImpl> getExternalXids();
 
     public static class XidBranchesPair {
         private final Xid xid;
 
         //set of TransactionBranchInfo
-        private final Set branches = new HashSet();
+        private final Set<TransactionBranchInfo> branches = new HashSet<TransactionBranchInfo>();
 
         private final Object mark;
 
@@ -66,7 +66,7 @@ public interface Recovery {
             return xid;
         }
 
-        public Set getBranches() {
+        public Set<TransactionBranchInfo> getBranches() {
             return branches;
         }
 

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoveryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoveryImpl.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoveryImpl.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RecoveryImpl.java Fri Mar 26 17:39:20 2010
@@ -50,42 +50,43 @@ public class RecoveryImpl implements Rec
 
     private final TransactionLog txLog;
     private final XidFactory xidFactory;
+    private final RetryScheduler retryScheduler;
 
-    private final Map externalXids = new HashMap();
-    private final Map ourXids = new HashMap();
-    private final Map nameToOurTxMap = new HashMap();
-    private final Map externalGlobalIdMap = new HashMap();
+    private final Map<Xid, TransactionImpl> externalXids = new HashMap<Xid, TransactionImpl>();
+    private final Map<ByteArrayWrapper, XidBranchesPair> ourXids = new HashMap<ByteArrayWrapper, XidBranchesPair>();
+    private final Map<String, Set<XidBranchesPair>> nameToOurTxMap = new HashMap<String, Set<XidBranchesPair>>();
+    private final Map<byte[], TransactionImpl> externalGlobalIdMap = new HashMap<byte[], TransactionImpl>();
 
-    private final List recoveryErrors = new ArrayList();
+    private final List<Exception> recoveryErrors = new ArrayList<Exception>();
 
-    public RecoveryImpl(final TransactionLog txLog, final XidFactory xidFactory) {
+    public RecoveryImpl(final TransactionLog txLog, final XidFactory xidFactory, RetryScheduler retryScheduler) {
         this.txLog = txLog;
         this.xidFactory = xidFactory;
+        this.retryScheduler = retryScheduler;
     }
 
     public synchronized void recoverLog() throws XAException {
-        Collection preparedXids = null;
+        Collection<XidBranchesPair> preparedXids;
         try {
             preparedXids = txLog.recover(xidFactory);
         } catch (LogException e) {
             throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e);
         }
-        for (Iterator iterator = preparedXids.iterator(); iterator.hasNext();) {
-            XidBranchesPair xidBranchesPair = (Recovery.XidBranchesPair) iterator.next();
+        for (XidBranchesPair xidBranchesPair : preparedXids) {
             Xid xid = xidBranchesPair.getXid();
             if (xidFactory.matchesGlobalId(xid.getGlobalTransactionId())) {
                 ourXids.put(new ByteArrayWrapper(xid.getGlobalTransactionId()), xidBranchesPair);
-                for (Iterator branches = xidBranchesPair.getBranches().iterator(); branches.hasNext();) {
-                    String name = ((TransactionBranchInfo) branches.next()).getResourceName();
-                    Set transactionsForName = (Set)nameToOurTxMap.get(name);
+                for (TransactionBranchInfo transactionBranchInfo : xidBranchesPair.getBranches()) {
+                    String name = transactionBranchInfo.getResourceName();
+                    Set<XidBranchesPair> transactionsForName = nameToOurTxMap.get(name);
                     if (transactionsForName == null) {
-                        transactionsForName = new HashSet();
+                        transactionsForName = new HashSet<XidBranchesPair>();
                         nameToOurTxMap.put(name, transactionsForName);
                     }
                     transactionsForName.add(xidBranchesPair);
                 }
             } else {
-                TransactionImpl externalTx = new ExternalTransaction(xid, txLog, xidBranchesPair.getBranches());
+                TransactionImpl externalTx = new ExternalTransaction(xid, txLog, retryScheduler, xidBranchesPair.getBranches());
                 externalXids.put(xid, externalTx);
                 externalGlobalIdMap.put(xid.getGlobalTransactionId(), externalTx);
             }
@@ -99,7 +100,7 @@ public class RecoveryImpl implements Rec
         for (int i = 0; prepared != null && i < prepared.length; i++) {
             Xid xid = prepared[i];
             ByteArrayWrapper globalIdWrapper = new ByteArrayWrapper(xid.getGlobalTransactionId());
-            XidBranchesPair xidNamesPair = (XidBranchesPair) ourXids.get(globalIdWrapper);
+            XidBranchesPair xidNamesPair = ourXids.get(globalIdWrapper);
             
             if (xidNamesPair != null) {
                 
@@ -125,7 +126,7 @@ public class RecoveryImpl implements Rec
                 }
             } else if (xidFactory.matchesBranchId(xid.getBranchQualifier())) {
                 //our branch, but we did not start this tx.
-                TransactionImpl externalTx = (TransactionImpl) externalGlobalIdMap.get(xid.getGlobalTransactionId());
+                TransactionImpl externalTx = externalGlobalIdMap.get(xid.getGlobalTransactionId());
                 if (externalTx == null) {
                     //we did not prepare this branch, rollback.
                     try {
@@ -141,18 +142,16 @@ public class RecoveryImpl implements Rec
             }
             //else we had nothing to do with this xid.
         }
-        Set transactionsForName = (Set)nameToOurTxMap.get(name);
+        Set<XidBranchesPair> transactionsForName = nameToOurTxMap.get(name);
         if (transactionsForName != null) {
-            for (Iterator transactions = transactionsForName.iterator(); transactions.hasNext();) {
-                XidBranchesPair xidBranchesPair = (XidBranchesPair) transactions.next();
+            for (XidBranchesPair xidBranchesPair : transactionsForName) {
                 removeNameFromTransaction(xidBranchesPair, name, false);
             }
         }
     }
 
     private boolean isNameInTransaction(XidBranchesPair xidBranchesPair, String name) {
-        for (Iterator branches = xidBranchesPair.getBranches().iterator(); branches.hasNext();) {
-            TransactionBranchInfo transactionBranchInfo = (TransactionBranchInfo) branches.next();
+        for (TransactionBranchInfo transactionBranchInfo : xidBranchesPair.getBranches()) {
             if (name.equals(transactionBranchInfo.getResourceName())) {
                 return true;
             }
@@ -187,7 +186,7 @@ public class RecoveryImpl implements Rec
         return !recoveryErrors.isEmpty();
     }
 
-    public synchronized List getRecoveryErrors() {
+    public synchronized List<Exception> getRecoveryErrors() {
         return Collections.unmodifiableList(recoveryErrors);
     }
 
@@ -203,8 +202,8 @@ public class RecoveryImpl implements Rec
 //    public boolean remoteRecoveryComplete() {
 //    }
 
-    public synchronized Map getExternalXids() {
-        return new HashMap(externalXids);
+    public synchronized Map<Xid, TransactionImpl> getExternalXids() {
+        return new HashMap<Xid, TransactionImpl>(externalXids);
     }
 
     private static class ByteArrayWrapper {
@@ -215,8 +214,8 @@ public class RecoveryImpl implements Rec
             assert bytes != null;
             this.bytes = bytes;
             int hash = 0;
-            for (int i = 0; i < bytes.length; i++) {
-                hash += 37 * bytes[i];
+            for (byte aByte : bytes) {
+                hash += 37 * aByte;
             }
             hashCode = hash;
         }
@@ -234,11 +233,13 @@ public class RecoveryImpl implements Rec
     }
 
     private static class ExternalTransaction extends TransactionImpl {
-        private Set resourceNames;
+        private final Set<String> resourceNames = new HashSet<String>();
 
-        public ExternalTransaction(Xid xid, TransactionLog txLog, Set resourceNames) {
-            super(xid, txLog);
-            this.resourceNames = resourceNames;
+        public ExternalTransaction(Xid xid, TransactionLog txLog, RetryScheduler retryScheduler, Set<TransactionBranchInfo> resourceNames) {
+            super(xid, txLog, retryScheduler);
+            for (TransactionBranchInfo info: resourceNames) {
+                this.resourceNames.add(info.getResourceName());
+            }
         }
 
         public boolean hasName(String name) {

Copied: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RetryScheduler.java (from r912058, geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RetryScheduler.java)
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RetryScheduler.java?p2=geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RetryScheduler.java&p1=geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RetryScheduler.java&r1=912058&r2=927980&rev=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/trunk/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RetryScheduler.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/RetryScheduler.java Fri Mar 26 17:39:20 2010
@@ -27,5 +27,5 @@ import java.util.TimerTask;
  */
 public interface RetryScheduler {
 
-    void retry(TimerTask task, int count);
+    void retry(Runnable task, int count);
 }

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java Fri Mar 26 17:39:20 2010
@@ -17,9 +17,6 @@
 
 package org.apache.geronimo.transaction.manager;
 
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.Writer;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.IdentityHashMap;
@@ -39,7 +36,6 @@ import javax.transaction.Transaction;
 import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -55,24 +51,26 @@ public class TransactionImpl implements 
     private final XidFactory xidFactory;
     private final Xid xid;
     private final TransactionLog txnLog;
+    private final RetryScheduler retryScheduler;
     private final long timeout;
-    private final List syncList = new ArrayList(5);
-    private final List interposedSyncList = new ArrayList(3);
-    private final LinkedList resourceManagers = new LinkedList();
-    private final IdentityHashMap activeXaResources = new IdentityHashMap(3);
-    private final IdentityHashMap suspendedXaResources = new IdentityHashMap(3);
+    private final List<Synchronization> syncList = new ArrayList<Synchronization>(5);
+    private final List<Synchronization> interposedSyncList = new ArrayList<Synchronization>(3);
+    private final LinkedList<TransactionBranch> resourceManagers = new LinkedList<TransactionBranch>();
+    private final IdentityHashMap<XAResource, TransactionBranch> activeXaResources = new IdentityHashMap<XAResource, TransactionBranch>(3);
+    private final IdentityHashMap<XAResource, TransactionBranch> suspendedXaResources = new IdentityHashMap<XAResource, TransactionBranch>(3);
     private int status = Status.STATUS_NO_TRANSACTION;
     private Object logMark;
 
-    private final Map resources = new HashMap();
+    private final Map<Object, Object> resources = new HashMap<Object, Object>();
 
-    TransactionImpl(XidFactory xidFactory, TransactionLog txnLog, long transactionTimeoutMilliseconds) throws SystemException {
-        this(xidFactory.createXid(), xidFactory, txnLog, transactionTimeoutMilliseconds);
+    TransactionImpl(XidFactory xidFactory, TransactionLog txnLog, RetryScheduler retryScheduler, long transactionTimeoutMilliseconds) throws SystemException {
+        this(xidFactory.createXid(), xidFactory, txnLog, retryScheduler, transactionTimeoutMilliseconds);
     }
 
-    TransactionImpl(Xid xid, XidFactory xidFactory, TransactionLog txnLog, long transactionTimeoutMilliseconds) throws SystemException {
+    TransactionImpl(Xid xid, XidFactory xidFactory, TransactionLog txnLog, RetryScheduler retryScheduler, long transactionTimeoutMilliseconds) throws SystemException {
         this.xidFactory = xidFactory;
         this.txnLog = txnLog;
+        this.retryScheduler = retryScheduler;
         this.xid = xid;
         this.timeout = transactionTimeoutMilliseconds + TransactionTimer.getCurrentTime();
         try {
@@ -87,10 +85,11 @@ public class TransactionImpl implements 
     }
 
     //reconstruct a tx for an external tx found in recovery
-    public TransactionImpl(Xid xid, TransactionLog txLog) {
+    public TransactionImpl(Xid xid, TransactionLog txLog, RetryScheduler retryScheduler) {
         this.xidFactory = null;
         this.txnLog = txLog;
         this.xid = xid;
+        this.retryScheduler = retryScheduler;
         status = Status.STATUS_PREPARED;
         //TODO is this a good idea?
         this.timeout = Long.MAX_VALUE;
@@ -551,7 +550,7 @@ public class TransactionImpl implements 
         endResources(suspendedXaResources);
     }
 
-    private void endResources(IdentityHashMap resourceMap) {
+    private void endResources(IdentityHashMap<XAResource, TransactionBranch> resourceMap) {
         while (true) {
             XAResource xaRes;
             TransactionBranch manager;
@@ -578,7 +577,7 @@ public class TransactionImpl implements 
         }
     }
 
-    private void rollbackResources(List rms) throws SystemException {
+    private void rollbackResources(List<TransactionBranch> rms) throws SystemException {
         SystemException cause = null;
         synchronized (this) {
             status = Status.STATUS_ROLLING_BACK;
@@ -618,7 +617,7 @@ public class TransactionImpl implements 
         }
     }
 
-    private void rollbackResourcesDuringCommit(List rms, boolean everRb) throws HeuristicMixedException, RollbackException, SystemException {
+    private void rollbackResourcesDuringCommit(List<TransactionBranch> rms, boolean everRb) throws HeuristicMixedException, RollbackException, SystemException {
         XAException cause = null;
         boolean everRolledback = everRb;
         synchronized (this) {
@@ -746,71 +745,91 @@ public class TransactionImpl implements 
         }
     }
     
-    private void commitResources(List rms) throws HeuristicRollbackException, HeuristicMixedException, SystemException {
-        XAException cause = null;
-        boolean evercommit = false;
+    private void commitResources(List<TransactionBranch> rms) throws HeuristicRollbackException, HeuristicMixedException, SystemException {
+        //TODO there's some logic removed about dealing with a heuristic rollback on the first resource.
+        CommitTask commitTask = new CommitTask(xid, rms, logMark, retryScheduler, txnLog);
         synchronized (this) {
             status = Status.STATUS_COMMITTING;
         }
-        try {
-            for (Iterator i = rms.iterator(); i.hasNext();) {
-                TransactionBranch manager = (TransactionBranch) i.next();
-                try {
-                    manager.getCommitter().commit(manager.getBranchId(), false);
-                    evercommit = true;
-                } catch (XAException e) {
-                    log.error("Unexpected exception committing " + manager.getCommitter() + "; continuing to commit other RMs", e);
-                    
-                    if (e.errorCode == XAException.XA_HEURRB) {
-                        log.info("Transaction has been heuristically rolled back");
-                        cause = e;
-                        manager.getCommitter().forget(manager.getBranchId());
-                    } else if (e.errorCode == XAException.XA_HEURMIX) {
-                        log.info("Transaction has been heuristically committed and rolled back");
-                        cause = e;
-                        evercommit = true;
-                        manager.getCommitter().forget(manager.getBranchId());
-                    } else if (e.errorCode == XAException.XA_HEURCOM) {
-                        // let's not throw an exception as the transaction has been committed
-                        log.info("Transaction has been heuristically committed");
-                        evercommit = true;
-                        manager.getCommitter().forget(manager.getBranchId());
-                    } else {
-                        cause = e;
-                    }
-                }
-            }
-        } catch (XAException e) {
-            if (e.errorCode == XAException.XAER_NOTA) {
-                // NOTA in response to forget, means the resource already forgot the transaction
-                // ignore
-            } else {
-                throw (SystemException) new SystemException("Error during two phase commit").initCause(e);
-            }
-        }
-        //if all resources were read only, we didn't write a prepare record.
-        if (!rms.isEmpty()) {
-            try {
-                txnLog.commit(xid, logMark);
-            } catch (LogException e) {
-                log.error("Unexpected exception logging commit completion for xid " + xid, e);
-                throw (SystemException) new SystemException("Unexpected error logging commit completion for xid " + xid).initCause(e);
-            }
-        }
+        commitTask.run();
         synchronized (this) {
-            status = Status.STATUS_COMMITTED;
+            status = commitTask.getStatus();
         }
+        XAException cause = commitTask.getCause();
         if (cause != null) {
-            if (cause.errorCode == XAException.XA_HEURRB && !evercommit) {
+            if (cause.errorCode == XAException.XA_HEURRB) {
                 throw (HeuristicRollbackException) new HeuristicRollbackException("Error during two phase commit").initCause(cause);
-            } else if (cause.errorCode == XAException.XA_HEURRB && evercommit) {
+            } else if (cause.errorCode == XAException.XA_HEURRB) {
                 throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
             } else if (cause.errorCode == XAException.XA_HEURMIX) {
                 throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
             } else {
                 throw (SystemException) new SystemException("Error during two phase commit").initCause(cause);
-            } 
+            }
         }
+
+
+//        XAException cause = null;
+//        boolean evercommit = false;
+//        try {
+//            for (Iterator i = rms.iterator(); i.hasNext();) {
+//                TransactionBranch manager = (TransactionBranch) i.next();
+//                try {
+//                    manager.getCommitter().commit(manager.getBranchId(), false);
+//                    evercommit = true;
+//                } catch (XAException e) {
+//                    log.error("Unexpected exception committing " + manager.getCommitter() + "; continuing to commit other RMs", e);
+//
+//                    if (e.errorCode == XAException.XA_HEURRB) {
+//                        log.info("Transaction has been heuristically rolled back");
+//                        cause = e;
+//                        manager.getCommitter().forget(manager.getBranchId());
+//                    } else if (e.errorCode == XAException.XA_HEURMIX) {
+//                        log.info("Transaction has been heuristically committed and rolled back");
+//                        cause = e;
+//                        evercommit = true;
+//                        manager.getCommitter().forget(manager.getBranchId());
+//                    } else if (e.errorCode == XAException.XA_HEURCOM) {
+//                        // let's not throw an exception as the transaction has been committed
+//                        log.info("Transaction has been heuristically committed");
+//                        evercommit = true;
+//                        manager.getCommitter().forget(manager.getBranchId());
+//                    } else {
+//                        cause = e;
+//                    }
+//                }
+//            }
+//        } catch (XAException e) {
+//            if (e.errorCode == XAException.XAER_NOTA) {
+//                // NOTA in response to forget, means the resource already forgot the transaction
+//                // ignore
+//            } else {
+//                throw (SystemException) new SystemException("Error during two phase commit").initCause(e);
+//            }
+//        }
+//        //if all resources were read only, we didn't write a prepare record.
+//        if (!rms.isEmpty()) {
+//            try {
+//                txnLog.commit(xid, logMark);
+//            } catch (LogException e) {
+//                log.error("Unexpected exception logging commit completion for xid " + xid, e);
+//                throw (SystemException) new SystemException("Unexpected error logging commit completion for xid " + xid).initCause(e);
+//            }
+//        }
+//        synchronized (this) {
+//            status = Status.STATUS_COMMITTED;
+//        }
+//        if (cause != null) {
+//            if (cause.errorCode == XAException.XA_HEURRB && !evercommit) {
+//                throw (HeuristicRollbackException) new HeuristicRollbackException("Error during two phase commit").initCause(cause);
+//            } else if (cause.errorCode == XAException.XA_HEURRB && evercommit) {
+//                throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
+//            } else if (cause.errorCode == XAException.XA_HEURMIX) {
+//                throw (HeuristicMixedException) new HeuristicMixedException("Error during two phase commit").initCause(cause);
+//            } else {
+//                throw (SystemException) new SystemException("Error during two phase commit").initCause(cause);
+//            }
+//        }
     }
 
     private static String getStateString(int status) {
@@ -857,7 +876,7 @@ public class TransactionImpl implements 
         return manager;
     }
 
-    private static class TransactionBranch implements TransactionBranchInfo {
+    static class TransactionBranch implements TransactionBranchInfo {
         private final XAResource committer;
         private final Xid branchId;
 

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionLog.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionLog.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionLog.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionLog.java Fri Mar 26 17:39:20 2010
@@ -36,9 +36,10 @@ public interface TransactionLog {
      * log prepare for the global xid xid and the list of TransactionBranchInfo branches
      * @param xid global xid for the transactions
      * @param branches List of TransactionBranchInfo
-     * @throws LogException
+     * @return log mark to use in commit/rollback calls.
+     * @throws LogException on error
      */
-    Object prepare(Xid xid, List branches) throws LogException;
+    Object prepare(Xid xid, List<? extends TransactionBranchInfo> branches) throws LogException;
 
     void commit(Xid xid, Object logMark) throws LogException;
 
@@ -48,11 +49,11 @@ public interface TransactionLog {
      * Recovers the log, returning a map of (top level) xid to List of TransactionBranchInfo for the branches.
      * Uses the XidFactory to reconstruct the xids.
      *
-     * @param xidFactory
+     * @param xidFactory Xid factory
      * @return Map of recovered xid to List of TransactionBranchInfo representing the branches.
-     * @throws LogException
+     * @throws LogException on error
      */
-    Collection recover(XidFactory xidFactory) throws LogException;
+    Collection<Recovery.XidBranchesPair> recover(XidFactory xidFactory) throws LogException;
 
     String getXMLStats();
 

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java Fri Mar 26 17:39:20 2010
@@ -19,7 +19,6 @@ package org.apache.geronimo.transaction.
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -41,19 +40,22 @@ import org.slf4j.LoggerFactory;
  */
 public class TransactionManagerImpl implements TransactionManager, UserTransaction, TransactionSynchronizationRegistry, XidImporter, MonitorableTransactionManager, RecoverableTransactionManager {
     private static final Logger log = LoggerFactory.getLogger(TransactionManagerImpl.class);
+    private static final Logger recoveryLog = LoggerFactory.getLogger("RecoveryController");
+
     protected static final int DEFAULT_TIMEOUT = 600;
     protected static final byte[] DEFAULT_TM_ID = new byte[] {71,84,77,73,68};
 
     final TransactionLog transactionLog;
     final XidFactory xidFactory;
     private final int defaultTransactionTimeoutMilliseconds;
-    private final ThreadLocal transactionTimeoutMilliseconds = new ThreadLocal();
-    private final ThreadLocal threadTx = new ThreadLocal();
-    private final ConcurrentHashMap associatedTransactions = new ConcurrentHashMap();
-    private static final Logger recoveryLog = LoggerFactory.getLogger("RecoveryController");
+    private final ThreadLocal<Long> transactionTimeoutMilliseconds = new ThreadLocal<Long>();
+    private final ThreadLocal<Transaction> threadTx = new ThreadLocal<Transaction>();
+    private final ConcurrentHashMap<Transaction, Thread> associatedTransactions = new ConcurrentHashMap<Transaction, Thread>();
     final Recovery recovery;
-    private final CopyOnWriteArrayList transactionAssociationListeners = new CopyOnWriteArrayList();
-    private List recoveryErrors = new ArrayList();
+    private final Map<String, NamedXAResourceFactory> namedXAResourceFactories = new ConcurrentHashMap<String, NamedXAResourceFactory>();
+    private final CopyOnWriteArrayList<TransactionManagerMonitor> transactionAssociationListeners = new CopyOnWriteArrayList<TransactionManagerMonitor>();
+    private final List<Exception> recoveryErrors = new ArrayList<Exception>();
+    private final RetryScheduler retryScheduler = new ExponentialtIntervalRetryScheduler();
     // statistics
     private AtomicLong totalCommits = new AtomicLong(0);
     private AtomicLong totalRollBacks = new AtomicLong(0);
@@ -98,12 +100,12 @@ public class TransactionManagerImpl impl
             this.xidFactory = new XidFactoryImpl(DEFAULT_TM_ID);
         }
 
-        recovery = new RecoveryImpl(this.transactionLog, this.xidFactory);
+        recovery = new RecoveryImpl(this.transactionLog, this.xidFactory, retryScheduler);
         recovery.recoverLog();
     }
 
     public Transaction getTransaction() {
-        return (Transaction) threadTx.get();
+        return threadTx.get();
     }
 
     private void associate(TransactionImpl tx) throws InvalidTransactionException {
@@ -137,7 +139,7 @@ public class TransactionManagerImpl impl
         if (seconds == 0) {
             transactionTimeoutMilliseconds.set(null);
         } else {
-            transactionTimeoutMilliseconds.set(new Long(seconds * 1000));
+            transactionTimeoutMilliseconds.set((long) seconds * 1000);
         }
     }
 
@@ -154,7 +156,7 @@ public class TransactionManagerImpl impl
         if (getStatus() != Status.STATUS_NO_TRANSACTION) {
             throw new NotSupportedException("Nested Transactions are not supported");
         }
-        TransactionImpl tx = new TransactionImpl(xidFactory, transactionLog, getTransactionTimeoutMilliseconds(transactionTimeoutMilliseconds));
+        TransactionImpl tx = new TransactionImpl(xidFactory, transactionLog, retryScheduler, getTransactionTimeoutMilliseconds(transactionTimeoutMilliseconds));
 //        timeoutTimer.schedule(tx, getTransactionTimeoutMilliseconds(transactionTimeoutMilliseconds));
         try {
             associate(tx);
@@ -226,7 +228,7 @@ public class TransactionManagerImpl impl
 
     /**
      * jta 1.1 method so the jpa implementations can be told to flush their caches.
-     * @param synchronization
+     * @param synchronization interposed synchronization
      */
     public void registerInterposedSynchronization(Synchronization synchronization) {
         TransactionImpl tx = getActiveTransactionImpl();
@@ -272,8 +274,7 @@ public class TransactionManagerImpl impl
         if (transactionTimeoutMilliseconds < 0) {
             throw new SystemException("transaction timeout must be positive or 0 to reset to default");
         }
-        TransactionImpl tx = new TransactionImpl(xid, xidFactory, transactionLog, getTransactionTimeoutMilliseconds(transactionTimeoutMilliseconds));
-        return tx;
+        return new TransactionImpl(xid, xidFactory, transactionLog, retryScheduler, getTransactionTimeoutMilliseconds(transactionTimeoutMilliseconds));
     }
 
     public void commit(Transaction tx, boolean onePhase) throws XAException {
@@ -334,9 +335,9 @@ public class TransactionManagerImpl impl
         if (transactionTimeoutMilliseconds != 0) {
             return transactionTimeoutMilliseconds;
         }
-        Long timeout = (Long) this.transactionTimeoutMilliseconds.get();
+        Long timeout = this.transactionTimeoutMilliseconds.get();
         if (timeout != null) {
-            return timeout.longValue();
+            return timeout;
         }
         return defaultTransactionTimeoutMilliseconds;
     }
@@ -347,16 +348,17 @@ public class TransactionManagerImpl impl
         recoveryErrors.add(e);
     }
 
-    public void recoverResourceManager(NamedXAResource xaResource) {
-        try {
-            recovery.recoverResourceManager(xaResource);
-        } catch (XAException e) {
-            recoveryError(e);
-        }
+    public void registerNamedXAResourceFactory(NamedXAResourceFactory namedXAResourceFactory) {
+        namedXAResourceFactories.put(namedXAResourceFactory.getName(), namedXAResourceFactory);
+        new RecoverTask(retryScheduler, namedXAResourceFactory, recovery, this).run();
+    }
+
+    public void unregisterNamedXAResourceFactory(String namedXAResourceFactoryName) {
+        namedXAResourceFactories.remove(namedXAResourceFactoryName);
     }
 
-    public Map getExternalXids() {
-        return new HashMap(recovery.getExternalXids());
+    public Map<Xid, TransactionImpl> getExternalXids() {
+        return new HashMap<Xid, TransactionImpl>(recovery.getExternalXids());
     }
 
     public void addTransactionAssociationListener(TransactionManagerMonitor listener) {
@@ -368,8 +370,7 @@ public class TransactionManagerImpl impl
     }
 
     protected void fireThreadAssociated(Transaction tx) {
-        for (Iterator iterator = transactionAssociationListeners.iterator(); iterator.hasNext();) {
-            TransactionManagerMonitor listener = (TransactionManagerMonitor) iterator.next();
+        for (TransactionManagerMonitor listener : transactionAssociationListeners) {
             try {
                 listener.threadAssociated(tx);
             } catch (Exception e) {
@@ -379,8 +380,7 @@ public class TransactionManagerImpl impl
     }
 
     protected void fireThreadUnassociated(Transaction tx) {
-        for (Iterator iterator = transactionAssociationListeners.iterator(); iterator.hasNext();) {
-            TransactionManagerMonitor listener = (TransactionManagerMonitor) iterator.next();
+        for (TransactionManagerMonitor listener : transactionAssociationListeners) {
             try {
                 listener.threadUnassociated(tx);
             } catch (Exception e) {
@@ -391,6 +391,7 @@ public class TransactionManagerImpl impl
 
     /**
      * Returns the number of active transactions.
+     * @return the count of active transactions
      */
     public long getActiveCount() {
         return activeCount.longValue();
@@ -398,6 +399,7 @@ public class TransactionManagerImpl impl
 
     /**
      * Return the number of total commits
+     * @return the number of commits since statistics were reset
      */
     public long getTotalCommits() {
         return totalCommits.longValue();
@@ -405,6 +407,7 @@ public class TransactionManagerImpl impl
 
     /**
      * Returns the number of total rollbacks
+     * @return the number of rollbacks since statistics were reset
      */
     public long getTotalRollbacks() {
         return totalRollBacks.longValue();

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/XidImporter.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/XidImporter.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/XidImporter.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/XidImporter.java Fri Mar 26 17:39:20 2010
@@ -39,5 +39,5 @@ public interface XidImporter {
     int prepare(Transaction tx) throws XAException;
     void rollback(Transaction tx) throws XAException;
 
-    Map getExternalXids();
+    Map<Xid, TransactionImpl> getExternalXids();
 }

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/AbstractRecoveryTest.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/AbstractRecoveryTest.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/AbstractRecoveryTest.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/AbstractRecoveryTest.java Fri Mar 26 17:39:20 2010
@@ -38,6 +38,7 @@ public abstract class AbstractRecoveryTe
     protected TransactionLog txLog;
 
     protected final XidFactory xidFactory = new XidFactoryImpl();
+    protected final RetryScheduler retryScheduler = new ExponentialtIntervalRetryScheduler();
     private static final String RM1 = "rm1";
     private static final String RM2 = "rm2";
     private static final String RM3 = "rm3";
@@ -55,7 +56,7 @@ public abstract class AbstractRecoveryTe
         addBranch(txInfos, xares2);
         prepareLog(txLog, txInfos);
         prepareForReplay();
-        Recovery recovery = new RecoveryImpl(txLog, xidFactory);
+        Recovery recovery = new RecoveryImpl(txLog, xidFactory, retryScheduler);
         recovery.recoverLog();
         assertTrue(!recovery.hasRecoveryErrors());
         assertTrue(recovery.getExternalXids().isEmpty());
@@ -104,7 +105,7 @@ public abstract class AbstractRecoveryTe
         addBranch(txInfos23, xares3);
         prepareLog(txLog, txInfos23);
         prepareForReplay();
-        Recovery recovery = new RecoveryImpl(txLog, xidFactory);
+        Recovery recovery = new RecoveryImpl(txLog, xidFactory, retryScheduler);
         recovery.recoverLog();
         assertTrue(!recovery.hasRecoveryErrors());
         assertTrue(recovery.getExternalXids().isEmpty());

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockLog.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockLog.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockLog.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockLog.java Fri Mar 26 17:39:20 2010
@@ -40,7 +40,7 @@ public class MockLog implements Transact
     public void begin(Xid xid) throws LogException {
     }
 
-    public Object prepare(Xid xid, List branches) throws LogException {
+    public Object prepare(Xid xid, List<? extends TransactionBranchInfo> branches) throws LogException {
         Object mark = new Object();
         Recovery.XidBranchesPair xidBranchesPair = new Recovery.XidBranchesPair(xid, mark);
         xidBranchesPair.getBranches().addAll(branches);

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockResource.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockResource.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockResource.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockResource.java Fri Mar 26 17:39:20 2010
@@ -20,6 +20,7 @@ package org.apache.geronimo.transaction.
 import java.util.Set;
 import java.util.HashSet;
 
+import javax.transaction.SystemException;
 import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
@@ -27,7 +28,7 @@ import javax.transaction.xa.Xid;
 /**
  * @version $Rev$ $Date$
  */
-public class MockResource implements NamedXAResource {
+public class MockResource implements NamedXAResource, NamedXAResourceFactory {
     private String xaResourceName = "mockResource";
     private Xid currentXid;
     private MockResourceManager manager;
@@ -153,4 +154,12 @@ public class MockResource implements Nam
         return xaResourceName;
     }
 
+    public NamedXAResource getNamedXAResource() throws SystemException {
+        return this;
+    }
+
+    public void returnNamedXAResource(NamedXAResource namedXAResource) {
+        if (this != namedXAResource) throw new RuntimeException("Wrong NamedXAResource returned: expected: " + this + " actual: " + namedXAResource);
+    }
+
 }

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockResourceManager.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockResourceManager.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockResourceManager.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/MockResourceManager.java Fri Mar 26 17:39:20 2010
@@ -36,15 +36,12 @@ public class MockResourceManager {
     private boolean willCommit;
     private Map xids = new HashMap();
 
-    private NamedXAResource resources;
-
     public MockResourceManager(boolean willCommit) {
         this.willCommit = willCommit;
     }
 
     public MockResource getResource(String xaResourceName) {
         MockResource mockResource =  new MockResource(this, xaResourceName);
-        resources = mockResource;
         return mockResource;
     }
 
@@ -71,8 +68,4 @@ public class MockResourceManager {
         }
     }
 
-    public void doRecovery(RecoverableTransactionManager transactionManager) throws SystemException {
-        transactionManager.recoverResourceManager(resources);
-    }
-
 }

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/RecoveryTest.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/RecoveryTest.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/RecoveryTest.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/RecoveryTest.java Fri Mar 26 17:39:20 2010
@@ -36,6 +36,7 @@ import junit.framework.TestCase;
 public class RecoveryTest extends TestCase {
 
     XidFactory xidFactory = new XidFactoryImpl();
+    protected final RetryScheduler retryScheduler = new ExponentialtIntervalRetryScheduler();
     private final String RM1 = "rm1";
     private final String RM2 = "rm2";
     private final String RM3 = "rm3";
@@ -51,7 +52,7 @@ public class RecoveryTest extends TestCa
         MockTransactionInfo[] txInfos = makeTxInfos(xids);
         addBranch(txInfos, xares1);
         prepareLog(mockLog, txInfos);
-        Recovery recovery = new RecoveryImpl(mockLog, xidFactory);
+        Recovery recovery = new RecoveryImpl(mockLog, xidFactory, retryScheduler);
         recovery.recoverLog();
         assertTrue(!recovery.hasRecoveryErrors());
         assertTrue(recovery.getExternalXids().isEmpty());
@@ -71,7 +72,7 @@ public class RecoveryTest extends TestCa
         addBranch(txInfos, xares1);
         addBranch(txInfos, xares2);
         prepareLog(mockLog, txInfos);
-        Recovery recovery = new RecoveryImpl(mockLog, xidFactory);
+        Recovery recovery = new RecoveryImpl(mockLog, xidFactory, retryScheduler);
         recovery.recoverLog();
         assertTrue(!recovery.hasRecoveryErrors());
         assertTrue(recovery.getExternalXids().isEmpty());
@@ -137,7 +138,7 @@ public class RecoveryTest extends TestCa
         addBranch(txInfos23, xares2);
         addBranch(txInfos23, xares3);
         prepareLog(mockLog, txInfos23);
-        Recovery recovery = new RecoveryImpl(mockLog, xidFactory);
+        Recovery recovery = new RecoveryImpl(mockLog, xidFactory, retryScheduler);
         recovery.recoverLog();
         assertTrue(!recovery.hasRecoveryErrors());
         assertTrue(recovery.getExternalXids().isEmpty());

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/TransactionManagerImplTest.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/TransactionManagerImplTest.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/TransactionManagerImplTest.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/TransactionManagerImplTest.java Fri Mar 26 17:39:20 2010
@@ -256,14 +256,21 @@ public class TransactionManagerImplTest 
         tm.prepare(tx);
         //recover
         tm.recovery.recoverLog();
-        rm1.doRecovery(tm);
+        recover(r1_1);
+        recover(r1_2);
         assertTrue(r1_2.isCommitted());
         assertTrue(!r2_2.isCommitted());
-        rm2.doRecovery(tm);
+        recover(r2_1);
+        recover(r2_2);
         assertTrue(r2_2.isCommitted());
         assertTrue(tm.recovery.localRecoveryComplete());
     }
 
+    private void recover(MockResource mr) {
+        tm.registerNamedXAResourceFactory(mr);
+        tm.unregisterNamedXAResourceFactory(mr.getName());
+    }
+
     public void testImportedXidRecovery() throws Exception {
         //create a transaction from an external transaction manager.
         XidFactory xidFactory2 = new XidFactoryImpl("tm2".getBytes());
@@ -279,10 +286,12 @@ public class TransactionManagerImplTest 
         tm.prepare(tx);
         //recover
         tm.recovery.recoverLog();
-        rm1.doRecovery(tm);
+        recover(r1_1);
+        recover(r1_2);
         assertTrue(!r1_2.isCommitted());
         assertTrue(!r2_2.isCommitted());
-        rm2.doRecovery(tm);
+        recover(r2_1);
+        recover(r2_2);
         assertTrue(!r2_2.isCommitted());
         //there are no transactions started here, so local recovery is complete
         assertTrue(tm.recovery.localRecoveryComplete());

Modified: geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/XATransactionTester.java
URL: http://svn.apache.org/viewvc/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/XATransactionTester.java?rev=927980&r1=927979&r2=927980&view=diff
==============================================================================
--- geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/XATransactionTester.java (original)
+++ geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.1/geronimo-transaction/src/test/java/org/apache/geronimo/transaction/manager/XATransactionTester.java Fri Mar 26 17:39:20 2010
@@ -103,7 +103,7 @@ public class XATransactionTester {
             XATransactionTester.this.xid = xid;
         }
 
-        public Object prepare(Xid xid, List branches) throws LogException {
+        public Object prepare(Xid xid, List<? extends TransactionBranchInfo> branches) throws LogException {
             return new Object();
         }
 
@@ -113,8 +113,8 @@ public class XATransactionTester {
         public void rollback(Xid xid, Object logMark) throws LogException {
         }
 
-        public Collection recover(XidFactory xidFactory) throws LogException {
-            return new ArrayList();
+        public Collection<Recovery.XidBranchesPair> recover(XidFactory xidFactory) throws LogException {
+            return new ArrayList<Recovery.XidBranchesPair>();
         }
 
         public String getXMLStats() {



Mime
View raw message