geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: rev 55410 - in geronimo/trunk/modules/transaction/src: java/org/apache/geronimo/transaction java/org/apache/geronimo/transaction/context java/org/apache/geronimo/transaction/manager test/org/apache/geronimo/transaction test/org/apache/geronimo/transaction/manager
Date Sun, 24 Oct 2004 02:14:58 GMT
Author: djencks
Date: Sat Oct 23 19:14:58 2004
New Revision: 55410

Added:
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/ExtendedTransactionManager.java
Modified:
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/GeronimoTransactionManager.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/OnlineUserTransaction.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/TransactionManagerProxy.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/BeanTransactionContext.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContextManager.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java
   geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XidImporter.java
   geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/TransactionManagerProxyTest.java
   geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/XidImporterTest.java
Log:
transaction end cancels timer (geronimo-390). Added begin(timeout) method, which is called
from UT.  Simplified tx importing, which now uses timeouts if specified.  This may break other
parts, will test after commit

Added: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/ExtendedTransactionManager.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/ExtendedTransactionManager.java
Sat Oct 23 19:14:58 2004
@@ -0,0 +1,14 @@
+package org.apache.geronimo.transaction;
+
+import javax.transaction.TransactionManager;
+import javax.transaction.NotSupportedException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
+/**
+ */
+public interface ExtendedTransactionManager extends TransactionManager {
+
+    Transaction begin(long transactionTimeoutMilliseconds) throws NotSupportedException,
SystemException ;
+
+}

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/GeronimoTransactionManager.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/GeronimoTransactionManager.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/GeronimoTransactionManager.java
Sat Oct 23 19:14:58 2004
@@ -52,7 +52,7 @@
         if (transactionLog == null) {
             transactionLog = new UnrecoverableLog();
         }
-        TransactionManager delegate = new TransactionManagerImpl(defaultTransactionTimeoutSeconds,
transactionLog, xidFactory);
+        ExtendedTransactionManager delegate = new TransactionManagerImpl(defaultTransactionTimeoutSeconds,
transactionLog, xidFactory);
         Recovery recovery = new RecoveryImpl(transactionLog, xidFactory);
         params.delegate = delegate;
         params.xidImporter = (XidImporter) delegate;

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/OnlineUserTransaction.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/OnlineUserTransaction.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/OnlineUserTransaction.java
Sat Oct 23 19:14:58 2004
@@ -19,6 +19,7 @@
 public final class OnlineUserTransaction implements UserTransaction, Serializable {
     private transient TransactionContextManager transactionContextManager;
     private transient TrackedConnectionAssociator trackedConnectionAssociator;
+    private long transactionTimeoutMilliseconds = 0L;
 
     boolean isActive() {
         return transactionContextManager != null;
@@ -39,11 +40,14 @@
     }
 
     public void setTransactionTimeout(int seconds) throws SystemException {
-        transactionContextManager.setTransactionTimeout(seconds);
+        if (seconds < 0) {
+            throw new SystemException("transaction timeout must be positive or 0, not " +
seconds);
+        }
+        transactionTimeoutMilliseconds = seconds * 1000;
     }
 
     public void begin() throws NotSupportedException, SystemException {
-        transactionContextManager.newBeanTransactionContext();
+        transactionContextManager.newBeanTransactionContext(transactionTimeoutMilliseconds);
 
         if(trackedConnectionAssociator != null) {
             try {

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/TransactionManagerProxy.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/TransactionManagerProxy.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/TransactionManagerProxy.java
Sat Oct 23 19:14:58 2004
@@ -57,10 +57,11 @@
  *
  * @version $Rev$ $Date$
  */
-public class TransactionManagerProxy implements TransactionManager, XidImporter, Recovery,
GBeanLifecycle {
+
+public class TransactionManagerProxy implements ExtendedTransactionManager, XidImporter,
Recovery, GBeanLifecycle {
     private static final Log recoveryLog = LogFactory.getLog("RecoveryController");
 
-    private final TransactionManager delegate;
+    private final ExtendedTransactionManager delegate;
     private final XidImporter importer;
     private final ThreadLocal threadTx = new ThreadLocal();
     private final Recovery recovery;
@@ -72,7 +73,7 @@
      *
      * @param delegate the TransactionManager that should be wrapped
      */
-    public TransactionManagerProxy(TransactionManager delegate, XidImporter importer, Recovery
recovery, Collection resourceManagers) {
+    public TransactionManagerProxy(ExtendedTransactionManager delegate, XidImporter importer,
Recovery recovery, Collection resourceManagers) {
         assert delegate != null;
         assert importer != null;
         assert recovery != null;
@@ -84,7 +85,7 @@
     }
 
     public static class ConstructorParams {
-        TransactionManager delegate;
+        ExtendedTransactionManager delegate;
         XidImporter xidImporter;
         Recovery recovery;
         ReferenceCollection resourceManagers;
@@ -149,9 +150,14 @@
         delegate.setTransactionTimeout(timeout);
     }
 
+    public Transaction begin(long transactionTimeoutMilliseconds) throws NotSupportedException,
SystemException {
+        Transaction tx = new TransactionProxy(delegate.begin(transactionTimeoutMilliseconds));
+        threadTx.set(tx);
+        return tx;
+    }
+
     public void begin() throws NotSupportedException, SystemException {
-        delegate.begin();
-        threadTx.set(new TransactionProxy(delegate.getTransaction()));
+        begin(0L);
     }
 
     public int getStatus() throws SystemException {
@@ -214,11 +220,11 @@
 
     //XidImporter implementation. Wrap and unwrap TransactionProxy.
     //the importer functions should not affect the thread context.
-    public Transaction importXid(Xid xid) throws XAException, SystemException {
+    public Transaction importXid(Xid xid, long transactionTimeoutMillis) throws XAException,
SystemException {
 //        if (threadTx.get() != null) {
 //            throw new XAException("Transaction already associated with current thread");
 //        }
-        TransactionProxy transactionProxy = new TransactionProxy(importer.importXid(xid));
+        TransactionProxy transactionProxy = new TransactionProxy(importer.importXid(xid,
transactionTimeoutMillis));
 //        threadTx.set(transactionProxy);
         return transactionProxy;
     }
@@ -240,10 +246,6 @@
         importer.rollback(((TransactionProxy) tx).getDelegate());
     }
 
-    public void setTransactionTimeout(long milliseconds) {
-        importer.setTransactionTimeout(milliseconds);
-    }
-
     //Recovery implementation
     //TODO make an interface of only getExternalIds since other methods don't work.
     //Or, decide to expose the other methods.
@@ -287,7 +289,7 @@
     static {
         GBeanInfoFactory infoFactory = new GBeanInfoFactory(TransactionManagerProxy.class);
 
-        infoFactory.addReference("delegate", TransactionManager.class);
+        infoFactory.addReference("delegate", ExtendedTransactionManager.class);
         infoFactory.addReference("xidImporter", XidImporter.class);
         infoFactory.addReference("recovery", Recovery.class);
         infoFactory.addReference("resourceManagers", ResourceManager.class);

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/BeanTransactionContext.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/BeanTransactionContext.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/BeanTransactionContext.java
Sat Oct 23 19:14:58 2004
@@ -25,7 +25,8 @@
 import javax.transaction.Status;
 import javax.transaction.SystemException;
 import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
+
+import org.apache.geronimo.transaction.ExtendedTransactionManager;
 
 /**
  *
@@ -33,12 +34,12 @@
  * @version $Rev$ $Date$
  */
 public class BeanTransactionContext extends InheritableTransactionContext {
-    private final TransactionManager txnManager;
+    private final ExtendedTransactionManager txnManager;
     private final UnspecifiedTransactionContext oldContext;
     private Transaction transaction;
 
 
-    public BeanTransactionContext(TransactionManager txnManager, UnspecifiedTransactionContext
oldContext) {
+    public BeanTransactionContext(ExtendedTransactionManager txnManager, UnspecifiedTransactionContext
oldContext) {
         this.txnManager = txnManager;
         this.oldContext = oldContext;
     }
@@ -47,9 +48,8 @@
         return oldContext;
     }
 
-    public void begin() throws SystemException, NotSupportedException {
-        txnManager.begin();
-        transaction = txnManager.getTransaction();
+    public void begin(long transactionTimeoutMilliseconds) throws SystemException, NotSupportedException
{
+        transaction = txnManager.begin(transactionTimeoutMilliseconds);
     }
 
     public void suspend() throws SystemException {

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContextManager.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContextManager.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContextManager.java
Sat Oct 23 19:14:58 2004
@@ -26,13 +26,13 @@
 import javax.transaction.Status;
 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.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoFactory;
+import org.apache.geronimo.transaction.ExtendedTransactionManager;
 import org.apache.geronimo.transaction.ImportedTransactionActiveException;
 import org.apache.geronimo.transaction.XAWork;
 import org.apache.geronimo.transaction.manager.Recovery;
@@ -47,7 +47,7 @@
     private static final boolean IN_RECOVERY = true;
 
 
-    private final TransactionManager transactionManager;
+    private final ExtendedTransactionManager transactionManager;
     private final XidImporter importer;
     private final Recovery recovery;
     private final Map importedTransactions = new HashMap();
@@ -59,7 +59,7 @@
         this(null, null, null);
     }
 
-    public TransactionContextManager(TransactionManager transactionManager, XidImporter importer,
Recovery recovery) {
+    public TransactionContextManager(ExtendedTransactionManager transactionManager, XidImporter
importer, Recovery recovery) {
         this.transactionManager = transactionManager;
         this.importer = importer;
         this.recovery = recovery;
@@ -79,7 +79,7 @@
         return transactionContext;
     }
 
-    public BeanTransactionContext newBeanTransactionContext() throws NotSupportedException,
SystemException {
+    public BeanTransactionContext newBeanTransactionContext(long transactionTimeoutMilliseconds)
throws NotSupportedException, SystemException {
         TransactionContext ctx = TransactionContext.getContext();
         if (ctx instanceof UnspecifiedTransactionContext == false) {
             throw new NotSupportedException("Previous Transaction has not been committed");
@@ -88,7 +88,7 @@
         BeanTransactionContext transactionContext = new BeanTransactionContext(transactionManager,
oldContext);
         oldContext.suspend();
         try {
-            transactionContext.begin();
+            transactionContext.begin(transactionTimeoutMilliseconds);
         } catch (SystemException e) {
             oldContext.resume();
             throw e;
@@ -114,10 +114,6 @@
         transactionManager.setRollbackOnly();
     }
 
-    public void setTransactionTimeout(int seconds) throws SystemException {
-        transactionManager.setTransactionTimeout(seconds);
-    }
-
 
     /**
      * TODO write and use ImportedTransactionContext for this!
@@ -248,7 +244,7 @@
             containerTransactionContext = (ContainerTransactionContext) importedTransactions.get(xid);
             if (containerTransactionContext == null) {
                 //this does not associate tx with current thread.
-                Transaction transaction = importer.importXid(xid);
+                Transaction transaction = importer.importXid(xid, txTimeoutMillis);
                 containerTransactionContext = new ContainerTransactionContext(transactionManager,
transaction);
                 importedTransactions.put(xid, containerTransactionContext);
             } else {
@@ -258,7 +254,6 @@
             }
             containerTransactionContext.resume();
         }
-        importer.setTransactionTimeout(txTimeoutMillis);
         TransactionContext.setContext(containerTransactionContext);
     }
 
@@ -284,13 +279,12 @@
         infoFactory.addOperation("getContext");
         infoFactory.addOperation("setContext", new Class[]{TransactionContext.class});
         infoFactory.addOperation("newContainerTransactionContext");
-        infoFactory.addOperation("newBeanTransactionContext");
+        infoFactory.addOperation("newBeanTransactionContext", new Class[] {long.class});
         infoFactory.addOperation("newUnspecifiedTransactionContext");
         infoFactory.addOperation("getStatus");
         infoFactory.addOperation("setRollbackOnly");
-        infoFactory.addOperation("setTransactionTimeout", new Class[] {int.class});
 
-        infoFactory.addReference("TransactionManager", TransactionManager.class);
+        infoFactory.addReference("TransactionManager", ExtendedTransactionManager.class);
         infoFactory.addReference("XidImporter", XidImporter.class);
         infoFactory.addReference("Recovery", Recovery.class);
 

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
Sat Oct 23 19:14:58 2004
@@ -18,14 +18,13 @@
 package org.apache.geronimo.transaction.manager;
 
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.IdentityHashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.IdentityHashMap;
-
+import java.util.TimerTask;
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
 import javax.transaction.RollbackException;
@@ -45,7 +44,7 @@
  *
  * @version $Rev$ $Date$
  */
-public class TransactionImpl implements Transaction {
+public class TransactionImpl extends TimerTask implements Transaction {
     private static final Log log = LogFactory.getLog("Transaction");
 
     private final XidFactory xidFactory;
@@ -58,6 +57,8 @@
     private int status = Status.STATUS_NO_TRANSACTION;
     private Object logMark;
 
+    private Thread currentThread;
+
     TransactionImpl(XidFactory xidFactory, TransactionLog txnLog) throws SystemException
{
         this(xidFactory.createXid(), xidFactory, txnLog);
     }
@@ -222,6 +223,7 @@
         try {
             if (status == Status.STATUS_MARKED_ROLLBACK) {
                 rollbackResources(resourceManagers);
+                cancel();
                 throw new RollbackException("Unable to commit");
             }
             synchronized (this) {
@@ -246,6 +248,7 @@
                 synchronized (this) {
                     status = Status.STATUS_COMMITTED;
                 }
+                cancel();
                 return;
             }
 
@@ -253,6 +256,7 @@
             if (resourceManagers.size() == 1) {
                 TransactionBranch manager = (TransactionBranch) resourceManagers.getFirst();
                 try {
+                    cancel();
                     manager.getCommitter().commit(manager.getBranchId(), true);
                     synchronized (this) {
                         status = Status.STATUS_COMMITTED;
@@ -262,9 +266,7 @@
                     synchronized (this) {
                         status = Status.STATUS_ROLLEDBACK;
                     }
-                    RollbackException ex = new RollbackException("Error during one-phase
commit");
-                    ex.initCause(e);
-                    throw ex;
+                    throw (RollbackException) new RollbackException("Error during one-phase
commit").initCause(e);
                 }
             }
 
@@ -296,6 +298,7 @@
                 if (status == Status.STATUS_ACTIVE) {
                     if (resourceManagers.size() == 0) {
                         // nothing to commit
+                        cancel();
                         status = Status.STATUS_COMMITTED;
                         return result;
                     } else {
@@ -395,6 +398,8 @@
                 status = Status.STATUS_PREPARED;
             }
         }
+        //cancel timeout.
+        cancel();
 
         // log our decision
         if (willCommit && !resourceManagers.isEmpty()) {
@@ -413,6 +418,7 @@
     }
 
     public void rollback() throws IllegalStateException, SystemException {
+        cancel();
         List rms;
         synchronized (this) {
             switch (status) {
@@ -616,6 +622,23 @@
         TransactionBranch manager = new TransactionBranch(xaRes, branchId);
         resourceManagers.add(manager);
         return manager;
+    }
+
+
+    //TimerTask implementation
+    public synchronized void run() {
+        try {
+            setRollbackOnly();
+            if (currentThread != null) {
+                currentThread.interrupt();
+            }
+        } catch (SystemException e) {
+            //in the wrong state.
+        }
+    }
+
+    public synchronized void setCurrentThread(Thread currentThread) {
+        this.currentThread = currentThread;
     }
 
     private static class TransactionBranch implements TransactionBranchInfo {

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java
Sat Oct 23 19:14:58 2004
@@ -18,7 +18,6 @@
 package org.apache.geronimo.transaction.manager;
 
 import java.util.Timer;
-import java.util.TimerTask;
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
 import javax.transaction.InvalidTransactionException;
@@ -32,6 +31,7 @@
 import javax.transaction.xa.Xid;
 
 import org.apache.geronimo.transaction.log.UnrecoverableLog;
+import org.apache.geronimo.transaction.ExtendedTransactionManager;
 
 /**
  * Simple implementation of a transaction manager.
@@ -40,7 +40,7 @@
  *
  * @version $Rev$ $Date$
  */
-public class TransactionManagerImpl implements TransactionManager, XidImporter {
+public class TransactionManagerImpl implements ExtendedTransactionManager, XidImporter {
     private final TransactionLog txnLog;
     private final XidFactory xidFactory;
     private final int defaultTransactionTimeoutMilliseconds;
@@ -86,17 +86,25 @@
     }
 
     public void begin() throws NotSupportedException, SystemException {
+        begin(transactionTimeoutMilliseconds);
+    }
+
+    public Transaction begin(long transactionTimeoutMilliseconds) throws NotSupportedException,
SystemException {
         if (getStatus() != Status.STATUS_NO_TRANSACTION) {
             throw new NotSupportedException("Nested Transactions are not supported");
         }
         TransactionImpl tx = new TransactionImpl(xidFactory, txnLog);
-        TimerTask timeout = new TransactionTimeout(tx);
-        timeoutTimer.schedule(timeout, transactionTimeoutMilliseconds);
+        timeoutTimer.schedule(tx, transactionTimeoutMilliseconds == 0? this.transactionTimeoutMilliseconds:
transactionTimeoutMilliseconds);
         threadTx.set(tx);
+        ((TransactionImpl)tx).setCurrentThread(Thread.currentThread());
+        return tx;
     }
 
     public Transaction suspend() throws SystemException {
         Transaction tx = getTransaction();
+        if (tx != null) {
+            ((TransactionImpl)tx).setCurrentThread(null);
+        }
         threadTx.set(null);
         return tx;
     }
@@ -109,6 +117,7 @@
             throw new InvalidTransactionException("Cannot resume foreign transaction: " +
tx);
         }
         threadTx.set(tx);
+        ((TransactionImpl)tx).setCurrentThread(Thread.currentThread());
     }
 
     public void setRollbackOnly() throws IllegalStateException, SystemException {
@@ -128,6 +137,7 @@
             tx.commit();
         } finally {
             threadTx.set(null);
+            ((TransactionImpl)tx).setCurrentThread(null);
         }
     }
 
@@ -140,12 +150,17 @@
             tx.rollback();
         } finally {
             threadTx.set(null);
+            ((TransactionImpl)tx).setCurrentThread(null);
         }
     }
 
     //XidImporter implementation
-    public Transaction importXid(Xid xid) throws XAException, SystemException {
+    public Transaction importXid(Xid xid, long transactionTimeoutMilliseconds) throws XAException,
SystemException {
         TransactionImpl tx = new TransactionImpl(xid, xidFactory, txnLog);
+        if (transactionTimeoutMilliseconds == 0) {
+            transactionTimeoutMilliseconds = this.transactionTimeoutMilliseconds;
+        }
+        timeoutTimer.schedule(tx, transactionTimeoutMilliseconds);
         return tx;
     }
 
@@ -154,35 +169,36 @@
             try {
                 tx.commit();
             } catch (HeuristicMixedException e) {
-                throw new XAException();
+                throw (XAException) new XAException().initCause(e);
             } catch (HeuristicRollbackException e) {
-                throw new XAException();
+                throw (XAException) new XAException().initCause(e);
             } catch (RollbackException e) {
-                throw new XAException();
+                throw (XAException) new XAException().initCause(e);
             } catch (SecurityException e) {
-                throw new XAException();
+                throw (XAException) new XAException().initCause(e);
             } catch (SystemException e) {
-                throw new XAException();
+                throw (XAException) new XAException().initCause(e);
             }
         } else {
             try {
                 ((TransactionImpl) tx).preparedCommit();
             } catch (SystemException e) {
-                throw new XAException();
+                throw (XAException) new XAException().initCause(e);
             }
         }
     }
 
     public void forget(Transaction tx) throws XAException {
+        //TODO implement this!
     }
 
     public int prepare(Transaction tx) throws XAException {
         try {
             return ((TransactionImpl) tx).prepare();
         } catch (SystemException e) {
-            throw new XAException();
+            throw (XAException) new XAException().initCause(e);
         } catch (RollbackException e) {
-            throw new XAException();
+            throw (XAException) new XAException().initCause(e);
         }
     }
 
@@ -190,31 +206,9 @@
         try {
             tx.rollback();
         } catch (IllegalStateException e) {
-            throw new XAException();
+            throw (XAException) new XAException().initCause(e);
         } catch (SystemException e) {
-            throw new XAException();
-        }
-    }
-
-    public void setTransactionTimeout(long milliseconds) {
-    }
-
-    private static class TransactionTimeout extends TimerTask {
-
-        private final TransactionImpl tx;
-
-        public TransactionTimeout(TransactionImpl tx) {
-            this.tx = tx;
-        }
-
-        public void run() {
-            try {
-                tx.setRollbackOnly();
-            } catch (SystemException e) {
-                //??
-            } catch (IllegalStateException ise) {
-                //transaction was committed
-            }
+            throw (XAException) new XAException().initCause(e);
         }
     }
 

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XidImporter.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XidImporter.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XidImporter.java
Sat Oct 23 19:14:58 2004
@@ -32,11 +32,10 @@
  * */
 public interface XidImporter {
 
-    Transaction importXid(Xid xid) throws XAException, SystemException;
+    Transaction importXid(Xid xid, long transactionTimeoutMillis) throws XAException, SystemException;
 
     void commit(Transaction tx, boolean onePhase) throws XAException;
     void forget(Transaction tx) throws XAException;
     int prepare(Transaction tx) throws XAException;
     void rollback(Transaction tx) throws XAException;
-    void setTransactionTimeout(long milliseconds);
 }

Modified: geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/TransactionManagerProxyTest.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/TransactionManagerProxyTest.java
(original)
+++ geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/TransactionManagerProxyTest.java
Sat Oct 23 19:14:58 2004
@@ -262,7 +262,7 @@
     public void testSimpleRecovery() throws Exception {
         //create a transaction in our own transaction manager
         Xid xid = xidFactory.createXid();
-        Transaction tx = tm.importXid(xid);
+        Transaction tx = tm.importXid(xid, 0);
         tm.resume(tx);
         assertSame(tx, tm.getTransaction());
         tx.enlistResource(r1_2);
@@ -285,7 +285,7 @@
         //create a transaction from an external transaction manager.
         XidFactory xidFactory2 = new XidFactoryImpl("tm2".getBytes());
         Xid xid = xidFactory2.createXid();
-        Transaction tx = tm.importXid(xid);
+        Transaction tx = tm.importXid(xid, 0);
         tm.resume(tx);
         assertSame(tx, tm.getTransaction());
         tx.enlistResource(r1_2);

Modified: geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/XidImporterTest.java
==============================================================================
--- geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/XidImporterTest.java
(original)
+++ geronimo/trunk/modules/transaction/src/test/org/apache/geronimo/transaction/manager/XidImporterTest.java
Sat Oct 23 19:14:58 2004
@@ -45,28 +45,28 @@
 
     public void testImportXid() throws Exception {
         Xid externalXid = xidFactory.createXid();
-        Transaction tx = tm.importXid(externalXid);
+        Transaction tx = tm.importXid(externalXid, 0);
         assertNotNull(tx);
         assertEquals(Status.STATUS_ACTIVE, tx.getStatus());
     }
 
     public void testNoResourcesCommitOnePhase() throws Exception {
         Xid externalXid = xidFactory.createXid();
-        Transaction tx = tm.importXid(externalXid);
+        Transaction tx = tm.importXid(externalXid, 0);
         tm.commit(tx, true);
         assertEquals(Status.STATUS_NO_TRANSACTION, tx.getStatus());
     }
 
     public void testNoResourcesCommitTwoPhase() throws Exception {
         Xid externalXid = xidFactory.createXid();
-        Transaction tx = tm.importXid(externalXid);
+        Transaction tx = tm.importXid(externalXid, 0);
         assertEquals(XAResource.XA_RDONLY, tm.prepare(tx));
         assertEquals(Status.STATUS_NO_TRANSACTION, tx.getStatus());
     }
 
     public void testNoResourcesMarkRollback() throws Exception {
         Xid externalXid = xidFactory.createXid();
-        Transaction tx = tm.importXid(externalXid);
+        Transaction tx = tm.importXid(externalXid, 0);
         tx.setRollbackOnly();
         try {
             tm.prepare(tx);
@@ -78,14 +78,14 @@
 
     public void testNoResourcesRollback() throws Exception {
         Xid externalXid = xidFactory.createXid();
-        Transaction tx = tm.importXid(externalXid);
+        Transaction tx = tm.importXid(externalXid, 0);
         tm.rollback(tx);
         assertEquals(Status.STATUS_NO_TRANSACTION, tx.getStatus());
     }
 
     public void testOneResourceOnePhaseCommit() throws Exception {
         Xid externalXid = xidFactory.createXid();
-        Transaction tx = tm.importXid(externalXid);
+        Transaction tx = tm.importXid(externalXid, 0);
         tx.enlistResource(r1_1);
         tx.delistResource(r1_1, XAResource.TMSUCCESS);
         tm.commit(tx, true);
@@ -94,7 +94,7 @@
 
     public void testOneResourceTwoPhaseCommit() throws Exception {
         Xid externalXid = xidFactory.createXid();
-        Transaction tx = tm.importXid(externalXid);
+        Transaction tx = tm.importXid(externalXid, 0);
         tx.enlistResource(r1_1);
         tx.delistResource(r1_1, XAResource.TMSUCCESS);
         assertEquals(XAResource.XA_OK, tm.prepare(tx));
@@ -110,7 +110,7 @@
 
     public void testFourResourceTwoPhaseCommit() throws Exception {
         Xid externalXid = xidFactory.createXid();
-        Transaction tx = tm.importXid(externalXid);
+        Transaction tx = tm.importXid(externalXid, 0);
         tx.enlistResource(r1_1);
         tx.enlistResource(r1_2);
         tx.enlistResource(r2_1);

Mime
View raw message