geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r155839 - in geronimo/trunk/modules: axis/src/test/org/apache/geronimo/axis/testUtils/ client/src/java/org/apache/geronimo/client/ connector/src/java/org/apache/geronimo/connector/outbound/ connector/src/test/org/apache/geronimo/connector/outbound/ connector/src/test/org/apache/geronimo/connector/outbound/connectiontracking/ jetty-builder/src/java/org/apache/geronimo/jetty/deployment/ jetty/src/java/org/apache/geronimo/jetty/ jetty/src/java/org/apache/geronimo/jetty/interceptor/ jetty/src/test/org/apache/geronimo/jetty/ timer/src/java/org/apache/geronimo/timer/ timer/src/java/org/apache/geronimo/timer/jdbc/ timer/src/java/org/apache/geronimo/timer/vm/ timer/src/test/org/apache/geronimo/timer/ tomcat/src/java/org/apache/geronimo/tomcat/ tomcat/src/java/org/apache/geronimo/tomcat/deployment/ tomcat/src/java/org/apache/geronimo/tomcat/valve/ tomcat/src/test/org/apache/geronimo/tomcat/ transaction/src/java/org/apache/geronimo/transaction/ transaction/src/java/org/apache/geronimo/transaction/context/
Date Tue, 01 Mar 2005 23:30:19 GMT
Author: dain
Date: Tue Mar  1 15:30:08 2005
New Revision: 155839

URL: http://svn.apache.org/viewcvs?view=rev&rev=155839
Log:
Extraced interface for TransactionContext
Implementations of TransactionContext are now hidden (they are now considered internal details of the TransactionContextManager)
Added methods to the TransactionContextManager to support the complex operations of suspending and resuming bean manged transactions 

Added:
    geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/AbstractTransactionContext.java
    geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/DoubleKeyedHashMap.java
      - copied unchanged from r155688, geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/DoubleKeyedHashMap.java
    geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/OnlineUserTransaction.java
      - copied, changed from r155688, geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/OnlineUserTransaction.java
    geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/UserTransactionImpl.java
      - copied, changed from r155688, geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/UserTransactionImpl.java
Removed:
    geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/DoubleKeyedHashMap.java
    geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/OnlineUserTransaction.java
    geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/UserTransactionImpl.java
Modified:
    geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/testUtils/TestingUtils.java
    geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java
    geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java
    geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptor.java
    geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java
    geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTest.java
    geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
    geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/TransactionCachingInterceptorTest.java
    geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptorTest.java
    geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/connectiontracking/DefaultComponentInterceptor.java
    geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
    geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/TransactionContextBeforeAfter.java
    geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/AbstractWebModuleTest.java
    geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/NontransactionalExecutorTask.java
    geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/NontransactionalExecutorTaskFactory.java
    geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/ThreadPooledTimer.java
    geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/TransactionalExecutorTask.java
    geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCStoreThreadPooledNonTransactionalTimer.java
    geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/vm/VMStoreThreadPooledNonTransactionalTimer.java
    geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/AbstractThreadPooledTimerTest.java
    geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/NontransactionalThreadPooledTimerTest.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/valve/TransactionContextValve.java
    geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.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/ContainerTransactionContext.java
    geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/InheritableTransactionContext.java
    geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContext.java
    geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContextManager.java
    geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/UnspecifiedTransactionContext.java

Modified: geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/testUtils/TestingUtils.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/testUtils/TestingUtils.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/testUtils/TestingUtils.java (original)
+++ geronimo/trunk/modules/axis/src/test/org/apache/geronimo/axis/testUtils/TestingUtils.java Tue Mar  1 15:30:08 2005
@@ -41,7 +41,7 @@
 import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.config.ConfigurationManager;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
-import org.apache.geronimo.transaction.OnlineUserTransaction;
+import org.apache.geronimo.transaction.context.OnlineUserTransaction;
 import org.apache.geronimo.deployment.DeploymentContext;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.jetty.JettyWebAppContext;

Modified: geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java (original)
+++ geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java Tue Mar  1 15:30:08 2005
@@ -24,7 +24,6 @@
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.transaction.context.TransactionContext;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
-import org.apache.geronimo.transaction.context.UnspecifiedTransactionContext;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 
@@ -80,7 +79,7 @@
         ClassLoader contextClassLoader = thread.getContextClassLoader();
         thread.setContextClassLoader(classLoader);
         TransactionContext oldTransactionContext = transactionContextManager.getContext();
-        UnspecifiedTransactionContext currentTransactionContext = null;
+        TransactionContext currentTransactionContext = null;
         try {
             jndiContext.startClient(appClientModuleName, kernel, classLoader);
             currentTransactionContext = transactionContextManager.newUnspecifiedTransactionContext();

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java (original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java Tue Mar  1 15:30:08 2005
@@ -21,13 +21,11 @@
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
-
 import javax.resource.ResourceException;
 
 import org.apache.geronimo.transaction.ConnectionReleaser;
 import org.apache.geronimo.transaction.context.TransactionContext;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
-import org.apache.geronimo.transaction.context.InheritableTransactionContext;
 
 /**
  * TransactionCachingInterceptor.java
@@ -63,12 +61,11 @@
         //There can be an inactive transaction context when a connection is requested in
         //Synchronization.afterCompletion().
         TransactionContext transactionContext = transactionContextManager.getContext();
-        if ((transactionContext instanceof InheritableTransactionContext) && ((InheritableTransactionContext) transactionContext).isActive()) {
-            InheritableTransactionContext inheritableTransactionContext = ((InheritableTransactionContext) transactionContext);
-            ManagedConnectionInfos managedConnectionInfos = (ManagedConnectionInfos) inheritableTransactionContext.getManagedConnectionInfo(this);
+        if (transactionContext != null && transactionContext.isInheritable() && transactionContext.isActive()) {
+            ManagedConnectionInfos managedConnectionInfos = (ManagedConnectionInfos) transactionContext.getManagedConnectionInfo(this);
             if (managedConnectionInfos == null) {
                 managedConnectionInfos = new ManagedConnectionInfos();
-                inheritableTransactionContext.setManagedConnectionInfo(this, managedConnectionInfos);
+                transactionContext.setManagedConnectionInfo(this, managedConnectionInfos);
             }
             if (connectionInfo.isUnshareable()) {
                 if (!managedConnectionInfos.containsUnshared(connectionInfo.getManagedConnectionInfo())) {
@@ -98,7 +95,7 @@
         }
 
         TransactionContext transactionContext = transactionContextManager.getContext();
-        if ((transactionContext instanceof InheritableTransactionContext) && ((InheritableTransactionContext) transactionContext).isActive()) {
+        if (transactionContext != null && transactionContext.isInheritable() && transactionContext.isActive()) {
             return;
         }
         internalReturn(connectionInfo, connectionReturnAction);

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptor.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptor.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptor.java (original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptor.java Tue Mar  1 15:30:08 2005
@@ -24,7 +24,6 @@
 
 import org.apache.geronimo.transaction.context.TransactionContext;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
-import org.apache.geronimo.transaction.context.InheritableTransactionContext;
 
 /**
  * TransactionEnlistingInterceptor.java
@@ -49,19 +48,14 @@
         try {
             ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
             TransactionContext transactionContext = transactionContextManager.getContext();
-            if ((transactionContext instanceof InheritableTransactionContext)) {
-                InheritableTransactionContext inheritableTransactionContext = ((InheritableTransactionContext) transactionContext);
-                if (inheritableTransactionContext.isActive()) {
-                    XAResource xares = mci.getXAResource();
-                    inheritableTransactionContext.getTransaction().enlistResource(xares);
-                }
+            if (transactionContext != null && transactionContext.isInheritable() && transactionContext.isActive()) {
+                XAResource xares = mci.getXAResource();
+                transactionContext.enlistResource(xares);
             }
-
         } catch (SystemException e) {
             throw new ResourceException("Could not get transaction", e);
         } catch (RollbackException e) {
-            throw new ResourceException("Could not enlist resource in rolled back transaction",
-                    e);
+            throw new ResourceException("Could not enlist resource in rolled back transaction", e);
         }
 
     }
@@ -80,12 +74,9 @@
         try {
             ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
             TransactionContext transactionContext = transactionContextManager.getContext();
-            if ((transactionContext instanceof InheritableTransactionContext)) {
-                InheritableTransactionContext inheritableTransactionContext = ((InheritableTransactionContext) transactionContext);
-                if (inheritableTransactionContext.isActive()) {
-                    XAResource xares = mci.getXAResource();
-                    inheritableTransactionContext.getTransaction().delistResource(xares, XAResource.TMSUSPEND);
-                }
+            if (transactionContext != null && transactionContext.isInheritable() && transactionContext.isActive()) {
+                XAResource xares = mci.getXAResource();
+                transactionContext.delistResource(xares, XAResource.TMSUSPEND);
             }
 
         } catch (SystemException e) {

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java (original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerStressTest.java Tue Mar  1 15:30:08 2005
@@ -19,8 +19,6 @@
 
 import java.util.HashSet;
 
-import org.apache.geronimo.transaction.context.TransactionContext;
-import org.apache.geronimo.transaction.context.UnspecifiedTransactionContext;
 import org.apache.geronimo.transaction.DefaultInstanceContext;
 import org.apache.commons.logging.LogFactory;
 import org.apache.commons.logging.Log;
@@ -48,7 +46,7 @@
     private Exception e = null;
 
     public void testNoTransactionCallOneThread() throws Throwable {
-        TransactionContext.setContext(new UnspecifiedTransactionContext());
+        transactionContextManager.newUnspecifiedTransactionContext();
         for (int i = 0; i < repeatCount; i++) {
             defaultComponentInterceptor.invoke(defaultComponentContext);
         }
@@ -60,7 +58,7 @@
         for (int t = 0; t < threadCount; t++) {
             new Thread() {
                 public void run() {
-                    TransactionContext.setContext(new UnspecifiedTransactionContext());
+                    transactionContextManager.newUnspecifiedTransactionContext();
                     long localStartTime = 0;
                     int localSlowCount = 0;
                     try {

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTest.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTest.java (original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTest.java Tue Mar  1 15:30:08 2005
@@ -21,8 +21,8 @@
 import org.apache.geronimo.connector.mock.MockXAResource;
 import org.apache.geronimo.connector.outbound.connectiontracking.DefaultInterceptor;
 import org.apache.geronimo.transaction.InstanceContext;
-import org.apache.geronimo.transaction.UserTransactionImpl;
-import org.apache.geronimo.transaction.context.ContainerTransactionContext;
+import org.apache.geronimo.transaction.context.TransactionContext;
+import org.apache.geronimo.transaction.context.UserTransactionImpl;
 
 /**
  *
@@ -34,7 +34,7 @@
 
 
     public void testSingleTransactionCall() throws Throwable {
-        ContainerTransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
+        TransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
         defaultComponentInterceptor.invoke(defaultComponentContext);
         MockXAResource mockXAResource = (MockXAResource) mockManagedConnection.getXAResource();
         assertEquals("XAResource should know one xid", 1, mockXAResource.getKnownXids().size());
@@ -52,7 +52,7 @@
     }
 
     public void testOneTransactionTwoCalls() throws Throwable {
-        ContainerTransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
+        TransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
         defaultComponentInterceptor.invoke(defaultComponentContext);
         MockXAResource mockXAResource = (MockXAResource) mockManagedConnection.getXAResource();
         assertEquals("XAResource should know one xid", 1, mockXAResource.getKnownXids().size());
@@ -116,7 +116,7 @@
             }
 
         };
-        ContainerTransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
+        TransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
         defaultComponentInterceptor.invoke(defaultComponentContext);
         MockXAResource mockXAResource = (MockXAResource) mockManagedConnection.getXAResource();
         assertEquals("XAResource should know one xid", 1, mockXAResource.getKnownXids().size());

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java (original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java Tue Mar  1 15:30:08 2005
@@ -37,8 +37,8 @@
 import org.apache.geronimo.security.bridge.RealmBridge;
 import org.apache.geronimo.transaction.DefaultInstanceContext;
 import org.apache.geronimo.transaction.InstanceContext;
-import org.apache.geronimo.transaction.UserTransactionImpl;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
+import org.apache.geronimo.transaction.context.UserTransactionImpl;
 import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
 
 /**

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/TransactionCachingInterceptorTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/TransactionCachingInterceptorTest.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/TransactionCachingInterceptorTest.java (original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/TransactionCachingInterceptorTest.java Tue Mar  1 15:30:08 2005
@@ -19,10 +19,8 @@
 
 import javax.resource.ResourceException;
 
-import org.apache.geronimo.transaction.context.ContainerTransactionContext;
-import org.apache.geronimo.transaction.context.TransactionContext;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
-import org.apache.geronimo.transaction.context.UnspecifiedTransactionContext;
+import org.apache.geronimo.transaction.context.TransactionContext;
 import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
 
 /**
@@ -52,7 +50,7 @@
     }
 
     public void testGetConnectionInTransaction() throws Exception {
-        ContainerTransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
+        TransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
         ConnectionInfo connectionInfo1 = makeConnectionInfo();
         transactionCachingInterceptor.getConnection(connectionInfo1);
         assertTrue("Expected to get an initial connection", obtainedConnectionInfo != null);
@@ -79,7 +77,7 @@
     }
 
     public void testGetUnshareableConnectionsInTransaction() throws Exception {
-        ContainerTransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
+        TransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
         ConnectionInfo connectionInfo1 = makeConnectionInfo();
         connectionInfo1.setUnshareable(true);
         transactionCachingInterceptor.getConnection(connectionInfo1);
@@ -117,12 +115,12 @@
         assertTrue("Expected TransactionContext to report inactive", !transactionContext.isActive());
     }
 
-    private ManagedConnectionInfo getSharedManagedConnectionInfo(ContainerTransactionContext transactionContext) {
+    private ManagedConnectionInfo getSharedManagedConnectionInfo(TransactionContext transactionContext) {
         return ((TransactionCachingInterceptor.ManagedConnectionInfos)transactionContext.getManagedConnectionInfo(transactionCachingInterceptor)).getShared();
     }
 
     public void testGetConnectionOutsideTransaction() throws Exception {
-        TransactionContext.setContext(new UnspecifiedTransactionContext());
+        transactionContextManager.newUnspecifiedTransactionContext();
         ConnectionInfo connectionInfo1 = makeConnectionInfo();
         transactionCachingInterceptor.getConnection(connectionInfo1);
         assertTrue("Expected to get an initial connection", obtainedConnectionInfo != null);
@@ -143,14 +141,14 @@
     }
 
     public void testTransactionIndependence() throws Exception {
-        ContainerTransactionContext transactionContext1 = transactionContextManager.newContainerTransactionContext();
+        TransactionContext transactionContext1 = transactionContextManager.newContainerTransactionContext();
         ConnectionInfo connectionInfo1 = makeConnectionInfo();
         transactionCachingInterceptor.getConnection(connectionInfo1);
         obtainedConnectionInfo = null;
 
         //start a second transaction
         transactionContext1.suspend();
-        ContainerTransactionContext transactionContext2 = transactionContextManager.newContainerTransactionContext();
+        TransactionContext transactionContext2 = transactionContextManager.newContainerTransactionContext();
         ConnectionInfo connectionInfo2 = makeConnectionInfo();
         transactionCachingInterceptor.getConnection(connectionInfo2);
         assertTrue("Expected to get a second connection", obtainedConnectionInfo != null);

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptorTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptorTest.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptorTest.java (original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptorTest.java Tue Mar  1 15:30:08 2005
@@ -22,7 +22,7 @@
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 
-import org.apache.geronimo.transaction.context.ContainerTransactionContext;
+import org.apache.geronimo.transaction.context.TransactionContext;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
 import org.apache.geronimo.transaction.manager.NamedXAResource;
 import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
@@ -71,7 +71,7 @@
     }
 
     public void testTransactionShareableConnection() throws Exception {
-        ContainerTransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
+        TransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
         ConnectionInfo connectionInfo = makeConnectionInfo();
         transactionEnlistingInterceptor.getConnection(connectionInfo);
         assertTrue("Expected started", started);
@@ -86,7 +86,7 @@
     }
 
     public void testTransactionUnshareableConnection() throws Exception {
-        ContainerTransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
+        TransactionContext transactionContext = transactionContextManager.newContainerTransactionContext();
         ConnectionInfo connectionInfo = makeConnectionInfo();
         connectionInfo.setUnshareable(true);
         transactionEnlistingInterceptor.getConnection(connectionInfo);

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/connectiontracking/DefaultComponentInterceptor.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/connectiontracking/DefaultComponentInterceptor.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/connectiontracking/DefaultComponentInterceptor.java (original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/connectiontracking/DefaultComponentInterceptor.java Tue Mar  1 15:30:08 2005
@@ -20,7 +20,6 @@
 import org.apache.geronimo.transaction.InstanceContext;
 import org.apache.geronimo.transaction.TrackedConnectionAssociator;
 import org.apache.geronimo.transaction.context.TransactionContext;
-import org.apache.geronimo.transaction.context.UnspecifiedTransactionContext;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
 
 /**

Modified: geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java (original)
+++ geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java Tue Mar  1 15:30:08 2005
@@ -76,7 +76,7 @@
 import org.apache.geronimo.security.deploy.Security;
 import org.apache.geronimo.security.deployment.SecurityBuilder;
 import org.apache.geronimo.security.util.URLPattern;
-import org.apache.geronimo.transaction.OnlineUserTransaction;
+import org.apache.geronimo.transaction.context.OnlineUserTransaction;
 import org.apache.geronimo.xbeans.geronimo.jetty.JettyWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.jetty.JettyWebAppType;
 import org.apache.geronimo.xbeans.j2ee.DispatcherType;

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java (original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebAppContext.java Tue Mar  1 15:30:08 2005
@@ -55,7 +55,7 @@
 import org.apache.geronimo.jetty.interceptor.TransactionContextBeforeAfter;
 import org.apache.geronimo.jetty.interceptor.WebApplicationContextBeforeAfter;
 import org.apache.geronimo.jetty.interceptor.SecurityContextBeforeAfter;
-import org.apache.geronimo.transaction.OnlineUserTransaction;
+import org.apache.geronimo.transaction.context.OnlineUserTransaction;
 import org.apache.geronimo.transaction.TrackedConnectionAssociator;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
 import org.apache.geronimo.security.deploy.Security;

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/TransactionContextBeforeAfter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/TransactionContextBeforeAfter.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/TransactionContextBeforeAfter.java (original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/interceptor/TransactionContextBeforeAfter.java Tue Mar  1 15:30:08 2005
@@ -21,7 +21,6 @@
 import javax.transaction.RollbackException;
 import javax.transaction.SystemException;
 
-import org.apache.geronimo.transaction.context.InheritableTransactionContext;
 import org.apache.geronimo.transaction.context.TransactionContext;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
 import org.mortbay.http.HttpRequest;
@@ -47,7 +46,7 @@
     public void before(Object[] context, HttpRequest httpRequest, HttpResponse httpResponse) {
         TransactionContext oldTransactionContext = transactionContextManager.getContext();
         TransactionContext newTransactionContext = null;
-        if (oldTransactionContext == null || !(oldTransactionContext instanceof InheritableTransactionContext)) {
+        if (oldTransactionContext == null || !oldTransactionContext.isInheritable()) {
             newTransactionContext = transactionContextManager.newUnspecifiedTransactionContext();
         }
         context[oldTxIndex] = oldTransactionContext;

Modified: geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/AbstractWebModuleTest.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/AbstractWebModuleTest.java (original)
+++ geronimo/trunk/modules/jetty/src/test/org/apache/geronimo/jetty/AbstractWebModuleTest.java Tue Mar  1 15:30:08 2005
@@ -44,7 +44,7 @@
 import org.apache.geronimo.security.jaas.LoginModuleGBean;
 import org.apache.geronimo.security.realm.GenericSecurityRealm;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
-import org.apache.geronimo.transaction.OnlineUserTransaction;
+import org.apache.geronimo.transaction.context.OnlineUserTransaction;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
 import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
 import org.mortbay.jetty.servlet.FormAuthenticator;

Modified: geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/NontransactionalExecutorTask.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/NontransactionalExecutorTask.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/NontransactionalExecutorTask.java (original)
+++ geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/NontransactionalExecutorTask.java Tue Mar  1 15:30:08 2005
@@ -20,7 +20,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.transaction.context.TransactionContext;
-import org.apache.geronimo.transaction.context.UnspecifiedTransactionContext;
+import org.apache.geronimo.transaction.context.TransactionContextManager;
 
 /**
  * @version $Rev$ $Date$
@@ -32,17 +32,18 @@
     private final Runnable userTask;
     private final WorkInfo workInfo;
     private final ThreadPooledTimer threadPooledTimer;
+    private final TransactionContextManager transactionContextManager;
 
-    public NontransactionalExecutorTask(Runnable userTask, WorkInfo workInfo, ThreadPooledTimer threadPooledTimer) {
+    public NontransactionalExecutorTask(Runnable userTask, WorkInfo workInfo, ThreadPooledTimer threadPooledTimer, TransactionContextManager transactionContextManager) {
         this.userTask = userTask;
         this.workInfo = workInfo;
         this.threadPooledTimer = threadPooledTimer;
+        this.transactionContextManager = transactionContextManager;
     }
 
     public void run() {
-        UnspecifiedTransactionContext transactionContext = new UnspecifiedTransactionContext();
-        TransactionContext oldTransactionContext = TransactionContext.getContext();
-        TransactionContext.setContext(transactionContext);
+        TransactionContext oldTransactionContext = transactionContextManager.getContext();
+        TransactionContext transactionContext = transactionContextManager.newUnspecifiedTransactionContext();
         try {
             try {
                 userTask.run();
@@ -58,8 +59,12 @@
                 threadPooledTimer.removeWorkInfo(workInfo);
             }
         } finally {
-            transactionContext.commit();
-            TransactionContext.setContext(oldTransactionContext);
+            try {
+                transactionContext.commit();
+            } catch (Exception e) {
+                log.error("Unable to commit transaction context", e);
+            }
+            transactionContextManager.setContext(oldTransactionContext);
         }
     }
 

Modified: geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/NontransactionalExecutorTaskFactory.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/NontransactionalExecutorTaskFactory.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/NontransactionalExecutorTaskFactory.java (original)
+++ geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/NontransactionalExecutorTaskFactory.java Tue Mar  1 15:30:08 2005
@@ -20,6 +20,7 @@
 import org.apache.geronimo.timer.ExecutorTask;
 import org.apache.geronimo.timer.ExecutorTaskFactory;
 import org.apache.geronimo.timer.NontransactionalExecutorTask;
+import org.apache.geronimo.transaction.context.TransactionContextManager;
 
 
 /**
@@ -29,9 +30,14 @@
  *
  * */
 public class NontransactionalExecutorTaskFactory implements ExecutorTaskFactory {
+    private final TransactionContextManager transactionContextManager;
+
+    public NontransactionalExecutorTaskFactory(TransactionContextManager transactionContextManager) {
+        this.transactionContextManager = transactionContextManager;
+    }
 
     public ExecutorTask createExecutorTask(Runnable userTask, WorkInfo workInfo, ThreadPooledTimer threadPooledTimer) {
-        return new NontransactionalExecutorTask(userTask, workInfo, threadPooledTimer);
+        return new NontransactionalExecutorTask(userTask, workInfo, threadPooledTimer, transactionContextManager);
     }
 
 }

Modified: geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/ThreadPooledTimer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/ThreadPooledTimer.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/ThreadPooledTimer.java (original)
+++ geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/ThreadPooledTimer.java Tue Mar  1 15:30:08 2005
@@ -22,24 +22,21 @@
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.Timer;
-import java.util.Iterator;
 import java.util.TimerTask;
-
 import javax.transaction.RollbackException;
 import javax.transaction.Status;
 import javax.transaction.Synchronization;
 import javax.transaction.SystemException;
-import javax.transaction.Transaction;
 
 import EDU.oswego.cs.dl.util.concurrent.Executor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.transaction.context.TransactionContext;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
-import org.apache.geronimo.transaction.context.InheritableTransactionContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 /**
  *
@@ -244,22 +241,11 @@
 
     void registerSynchronization(Synchronization sync) throws RollbackException, SystemException {
         TransactionContext transactionContext = transactionContextManager.getContext();
-
-        //TODO move the registerSynchronization to the TransactionContext
-        Transaction transaction;
-        if (transactionContext instanceof InheritableTransactionContext) {
-            InheritableTransactionContext inheritableTransactionContext = ((InheritableTransactionContext) transactionContext);
-            transaction = inheritableTransactionContext.getTransaction();
-            assert transaction == null || inheritableTransactionContext.isActive(): "Trying to register a sync on an inactive transaction context";
+        if (transactionContext != null && transactionContext.isInheritable() && transactionContext.isActive()) {
+            transactionContext.registerSynchronization(sync);
         } else {
-            transaction = null;
-        }
-
-        if (transaction == null) {
             sync.beforeCompletion();
             sync.afterCompletion(Status.STATUS_COMMITTED);
-        } else {
-            transaction.registerSynchronization(sync);
         }
     }
 

Modified: geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/TransactionalExecutorTask.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/TransactionalExecutorTask.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/TransactionalExecutorTask.java (original)
+++ geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/TransactionalExecutorTask.java Tue Mar  1 15:30:08 2005
@@ -19,8 +19,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.transaction.context.ContainerTransactionContext;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
+import org.apache.geronimo.transaction.context.TransactionContext;
 
 /**
  * @version $Rev$ $Date$
@@ -44,7 +44,7 @@
     }
     
     public void run() {
-        ContainerTransactionContext transactionContext = null;
+        TransactionContext transactionContext = null;
         for (int tries = 0; tries < repeatCount; tries++) {
             try {
                 transactionContext = transactionContextManager.newContainerTransactionContext();

Modified: geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCStoreThreadPooledNonTransactionalTimer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCStoreThreadPooledNonTransactionalTimer.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCStoreThreadPooledNonTransactionalTimer.java (original)
+++ geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/jdbc/JDBCStoreThreadPooledNonTransactionalTimer.java Tue Mar  1 15:30:08 2005
@@ -42,7 +42,7 @@
                                                       Executor threadPool,
                                                       Serializable derbySystem,
                                                       Kernel kernel) throws SQLException {
-        super(new NontransactionalExecutorTaskFactory(),
+        super(new NontransactionalExecutorTaskFactory(transactionContextManager),
                 new JDBCWorkerPersistence(kernel.getKernelName(), (DataSource)managedConnectionFactoryWrapper.$getResource(), false), threadPool, transactionContextManager);
     }
 

Modified: geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/vm/VMStoreThreadPooledNonTransactionalTimer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/vm/VMStoreThreadPooledNonTransactionalTimer.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/vm/VMStoreThreadPooledNonTransactionalTimer.java (original)
+++ geronimo/trunk/modules/timer/src/java/org/apache/geronimo/timer/vm/VMStoreThreadPooledNonTransactionalTimer.java Tue Mar  1 15:30:08 2005
@@ -34,7 +34,7 @@
 public class VMStoreThreadPooledNonTransactionalTimer extends ThreadPooledTimer {
 
     public VMStoreThreadPooledNonTransactionalTimer(TransactionContextManager transactionContextManager, Executor threadPool) {
-        super(new NontransactionalExecutorTaskFactory(),
+        super(new NontransactionalExecutorTaskFactory(transactionContextManager),
                 new VMWorkerPersistence(), threadPool, transactionContextManager);
     }
 

Modified: geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/AbstractThreadPooledTimerTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/AbstractThreadPooledTimerTest.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/AbstractThreadPooledTimerTest.java (original)
+++ geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/AbstractThreadPooledTimerTest.java Tue Mar  1 15:30:08 2005
@@ -56,7 +56,7 @@
         timer.doStart();
 
         counter.set(0);
-        TransactionContext.setContext(null);
+        transactionContextManager.setContext(null);
     }
 
     protected void tearDown() throws Exception {

Modified: geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/NontransactionalThreadPooledTimerTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/NontransactionalThreadPooledTimerTest.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/NontransactionalThreadPooledTimerTest.java (original)
+++ geronimo/trunk/modules/timer/src/test/org/apache/geronimo/timer/NontransactionalThreadPooledTimerTest.java Tue Mar  1 15:30:08 2005
@@ -31,7 +31,7 @@
     protected void setUp() throws Exception {
         TransactionManagerImpl transactionManager = new TransactionManagerImpl(10 * 1000, null, null);
         transactionContextManager = new TransactionContextManager(transactionManager, transactionManager);
-        executableWorkFactory = new NontransactionalExecutorTaskFactory();
+        executableWorkFactory = new NontransactionalExecutorTaskFactory(transactionContextManager);
         super.setUp();
     }
 }

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java (original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java Tue Mar  1 15:30:08 2005
@@ -43,8 +43,8 @@
 import org.apache.geronimo.tomcat.valve.ComponentContextValve;
 import org.apache.geronimo.tomcat.valve.TransactionContextValve;
 import org.apache.geronimo.tomcat.valve.PolicyContextValve;
-import org.apache.geronimo.transaction.OnlineUserTransaction;
 import org.apache.geronimo.transaction.TrackedConnectionAssociator;
+import org.apache.geronimo.transaction.context.OnlineUserTransaction;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
 
 import javax.naming.NamingException;

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java (original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java Tue Mar  1 15:30:08 2005
@@ -57,7 +57,7 @@
 import org.apache.geronimo.xbeans.geronimo.jetty.JettyWebAppType;
 import org.apache.geronimo.xbeans.j2ee.WebAppDocument;
 import org.apache.geronimo.xbeans.j2ee.WebAppType;
-import org.apache.geronimo.transaction.OnlineUserTransaction;
+import org.apache.geronimo.transaction.context.OnlineUserTransaction;
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
 
 

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/valve/TransactionContextValve.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/valve/TransactionContextValve.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/valve/TransactionContextValve.java (original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/valve/TransactionContextValve.java Tue Mar  1 15:30:08 2005
@@ -16,19 +16,18 @@
  */
 package org.apache.geronimo.tomcat.valve;
 
-import org.apache.catalina.valves.ValveBase;
-import org.apache.catalina.connector.Request;
-import org.apache.catalina.connector.Response;
-import org.apache.geronimo.transaction.context.TransactionContextManager;
-import org.apache.geronimo.transaction.context.TransactionContext;
-import org.apache.geronimo.transaction.context.InheritableTransactionContext;
-
+import java.io.IOException;
 import javax.servlet.ServletException;
-import javax.transaction.SystemException;
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
 import javax.transaction.RollbackException;
-import java.io.IOException;
+import javax.transaction.SystemException;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.catalina.valves.ValveBase;
+import org.apache.geronimo.transaction.context.TransactionContext;
+import org.apache.geronimo.transaction.context.TransactionContextManager;
 
 /**
  * @version $Rev: $ $Date: $
@@ -46,7 +45,7 @@
         TransactionContext oldTransactionContext = transactionContextManager.getContext();
         TransactionContext newTransactionContext = null;
 
-        if (oldTransactionContext == null || !(oldTransactionContext instanceof InheritableTransactionContext)) {
+        if (oldTransactionContext == null || !oldTransactionContext.isInheritable()) {
             newTransactionContext = transactionContextManager.newUnspecifiedTransactionContext();
         }
 

Modified: geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java (original)
+++ geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java Tue Mar  1 15:30:08 2005
@@ -43,8 +43,8 @@
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.apache.geronimo.tomcat.connector.HTTPConnector;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
+import org.apache.geronimo.transaction.context.OnlineUserTransaction;
 import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
-import org.apache.geronimo.transaction.OnlineUserTransaction;
 
 
 /**

Added: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/AbstractTransactionContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/AbstractTransactionContext.java?view=auto&rev=155839
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/AbstractTransactionContext.java (added)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/AbstractTransactionContext.java Tue Mar  1 15:30:08 2005
@@ -0,0 +1,141 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.geronimo.transaction.context;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.transaction.ConnectionReleaser;
+import org.apache.geronimo.transaction.DoubleKeyedHashMap;
+import org.apache.geronimo.transaction.InstanceContext;
+import org.tranql.cache.InTxCache;
+
+
+/**
+ * @version $Rev: 155376 $ $Date: 2005-02-25 15:10:24 -0800 (Fri, 25 Feb 2005) $
+ */
+abstract class AbstractTransactionContext implements TransactionContext {
+    protected static final Log log = LogFactory.getLog(AbstractTransactionContext.class);
+    protected Map managedConnections;
+
+    private InstanceContext currentContext;
+    private final DoubleKeyedHashMap associatedContexts = new DoubleKeyedHashMap();
+    private final DoubleKeyedHashMap dirtyContexts = new DoubleKeyedHashMap();
+    private InTxCache inTxCache;
+
+    public final void associate(InstanceContext context) throws Throwable {
+        if (associatedContexts.put(context.getContainerId(), context.getId(), context) == null) {
+            context.associate();
+        }
+    }
+
+    public final void unassociate(InstanceContext context) throws Throwable {
+        associatedContexts.remove(context.getContainerId(), context.getId());
+        context.unassociate();
+    }
+
+    public final void unassociate(Object containerId, Object id) throws Throwable {
+        InstanceContext context = (InstanceContext) associatedContexts.remove(containerId, id);
+        if (context != null) {
+            context.unassociate();
+        }
+    }
+
+    public final InstanceContext getContext(Object containerId, Object id) {
+        return (InstanceContext) associatedContexts.get(containerId, id);
+    }
+
+    protected final ArrayList getAssociatedContexts() {
+        return new ArrayList(associatedContexts.values());
+    }
+
+    protected final void unassociateAll() {
+        ArrayList toFlush = getAssociatedContexts();
+        for (Iterator i = toFlush.iterator(); i.hasNext();) {
+            InstanceContext context = (InstanceContext) i.next();
+            try {
+                context.unassociate();
+            } catch (Throwable throwable) {
+                log.warn("Error while unassociating instance from transaction context: " + context, throwable);
+            }
+        }
+    }
+
+    public final InstanceContext beginInvocation(InstanceContext context) throws Throwable {
+        if (context.getId() != null) {
+            associate(context);
+            dirtyContexts.put(context.getContainerId(), context.getId(), context);
+        }
+        context.enter();
+        InstanceContext caller = currentContext;
+        currentContext = context;
+        return caller;
+    }
+
+    public final void endInvocation(InstanceContext caller) {
+        if (currentContext != null) {
+            currentContext.exit();
+        }
+        currentContext = caller;
+    }
+
+    public final void flushState() throws Throwable {
+        while (dirtyContexts.isEmpty() == false) {
+            ArrayList toFlush = new ArrayList(dirtyContexts.values());
+            dirtyContexts.clear();
+            for (Iterator i = toFlush.iterator(); i.hasNext();) {
+                InstanceContext context = (InstanceContext) i.next();
+                if (!context.isDead()) {
+                    context.flush();
+                }
+            }
+        }
+        if (currentContext != null && currentContext.getId() != null) {
+            dirtyContexts.put(currentContext.getContainerId(), currentContext.getId(), currentContext);
+        }
+        if(inTxCache != null) {
+            inTxCache.flush();
+        }
+    }
+
+    public final void setInTxCache(InTxCache inTxCache) {
+        this.inTxCache = inTxCache;
+    }
+    
+    public final InTxCache getInTxCache() {
+        return inTxCache;
+    }
+
+    public void setManagedConnectionInfo(ConnectionReleaser key, Object info) {
+        if (managedConnections == null) {
+            managedConnections = new HashMap();
+        }
+        managedConnections.put(key, info);
+    }
+
+    public Object getManagedConnectionInfo(ConnectionReleaser key) {
+        if (managedConnections == null) {
+            return null;
+        }
+        return managedConnections.get(key);
+    }
+}

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/BeanTransactionContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/BeanTransactionContext.java?view=diff&r1=155838&r2=155839
==============================================================================
--- 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 Tue Mar  1 15:30:08 2005
@@ -22,19 +22,22 @@
 /**
  * @version $Rev$ $Date$
  */
-public class BeanTransactionContext extends InheritableTransactionContext {
+class BeanTransactionContext extends InheritableTransactionContext {
     private UnspecifiedTransactionContext oldContext;
 
-    public BeanTransactionContext(ExtendedTransactionManager txnManager, UnspecifiedTransactionContext oldContext) {
+    BeanTransactionContext(ExtendedTransactionManager txnManager, UnspecifiedTransactionContext oldContext) {
         super(txnManager);
         this.oldContext = oldContext;
     }
 
-    public UnspecifiedTransactionContext getOldContext() {
+    UnspecifiedTransactionContext getOldContext() {
         return oldContext;
     }
 
-    public void setOldContext(UnspecifiedTransactionContext oldContext) {
+    void setOldContext(UnspecifiedTransactionContext oldContext) {
+        if (oldContext != null && oldContext.isInheritable()) {
+            throw new IllegalArgumentException("Old context is inheritable");
+        }
         this.oldContext = oldContext;
     }
 }

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/ContainerTransactionContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/ContainerTransactionContext.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/ContainerTransactionContext.java (original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/ContainerTransactionContext.java Tue Mar  1 15:30:08 2005
@@ -26,13 +26,13 @@
 /**
  * @version $Rev$ $Date$
  */
-public class ContainerTransactionContext extends InheritableTransactionContext {
-    public ContainerTransactionContext(ExtendedTransactionManager txnManager) throws SystemException, NotSupportedException {
+class ContainerTransactionContext extends InheritableTransactionContext {
+    ContainerTransactionContext(ExtendedTransactionManager txnManager) throws SystemException, NotSupportedException {
         super(txnManager);
         begin(0);
     }
 
-    public ContainerTransactionContext(ExtendedTransactionManager txnManager, Transaction transaction) {
+    ContainerTransactionContext(ExtendedTransactionManager txnManager, Transaction transaction) {
         super(txnManager, transaction);
     }
 }

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/InheritableTransactionContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/InheritableTransactionContext.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/InheritableTransactionContext.java (original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/InheritableTransactionContext.java Tue Mar  1 15:30:08 2005
@@ -19,7 +19,6 @@
 
 import java.util.Iterator;
 import java.util.Map;
-import java.util.HashMap;
 import java.util.ArrayList;
 import javax.transaction.SystemException;
 import javax.transaction.Status;
@@ -29,6 +28,8 @@
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
 import javax.transaction.RollbackException;
+import javax.transaction.Synchronization;
+import javax.transaction.xa.XAResource;
 
 import org.apache.geronimo.transaction.ExtendedTransactionManager;
 import org.apache.geronimo.transaction.ConnectionReleaser;
@@ -37,11 +38,10 @@
 /**
  * @version $Rev$ $Date$
  */
-public abstract class InheritableTransactionContext extends TransactionContext {
+abstract class InheritableTransactionContext extends AbstractTransactionContext {
     private final ExtendedTransactionManager txnManager;
     private Transaction transaction;
     private boolean threadAssociated = false;
-    private Map managedConnections;
 
     protected InheritableTransactionContext(ExtendedTransactionManager txnManager) {
         this.txnManager = txnManager;
@@ -52,7 +52,15 @@
         this.transaction = transaction;
     }
 
-    public boolean isThreadAssociated() {
+    void begin(long transactionTimeoutMilliseconds) throws SystemException, NotSupportedException {
+        if (transaction != null) {
+            throw new SystemException("Context is already associated with a transaction");
+        }
+        transaction = txnManager.begin(transactionTimeoutMilliseconds);
+        threadAssociated = true;
+    }
+
+    boolean isThreadAssociated() {
         return threadAssociated;
     }
 
@@ -60,18 +68,8 @@
         return transaction;
     }
 
-    public void setManagedConnectionInfo(ConnectionReleaser key, Object info) {
-        if (managedConnections == null) {
-            managedConnections = new HashMap();
-        }
-        managedConnections.put(key, info);
-    }
-
-    public Object getManagedConnectionInfo(ConnectionReleaser key) {
-        if (managedConnections == null) {
-            return null;
-        }
-        return managedConnections.get(key);
+    public boolean isInheritable() {
+        return true;
     }
 
     public boolean isActive() {
@@ -86,6 +84,30 @@
         }
     }
 
+    public boolean enlistResource(XAResource xaResource) throws RollbackException, SystemException {
+        if (transaction == null) {
+            throw new IllegalStateException("There is no transaction in progress.");
+        }
+
+        return transaction.enlistResource(xaResource);
+    }
+
+    public boolean delistResource(XAResource xaResource, int flag) throws SystemException {
+        if (transaction == null) {
+            throw new IllegalStateException("There is no transaction in progress.");
+        }
+
+        return transaction.delistResource(xaResource, flag);
+    }
+
+    public void registerSynchronization(Synchronization synchronization) throws RollbackException, SystemException {
+        if (transaction == null) {
+            throw new IllegalStateException("There is no transaction in progress.");
+        }
+
+        transaction.registerSynchronization(synchronization);
+    }
+
     public boolean getRollbackOnly() throws SystemException {
         if (transaction == null) {
             throw new IllegalStateException("There is no transaction in progress.");
@@ -104,12 +126,6 @@
         transaction.setRollbackOnly();
     }
 
-    public void begin(long transactionTimeoutMilliseconds) throws SystemException, NotSupportedException {
-        assert transaction == null:  "Already associated with a transaction";
-        transaction = txnManager.begin(transactionTimeoutMilliseconds);
-        threadAssociated = true;
-    }
-
     public void suspend() throws SystemException {
         Transaction suspendedTransaction = txnManager.suspend();
         if (transaction != suspendedTransaction) {
@@ -179,6 +195,7 @@
         } catch (Throwable t) {
             rollbackAndThrow("Unable to commit container transaction", t);
         } finally {
+            transaction = null;
             try {
                 afterCommit(wasCommitted);
             } catch (Throwable e) {
@@ -186,7 +203,6 @@
             } finally {
                 unassociateAll();
                 connectorAfterCommit();
-                transaction = null;
                 threadAssociated = false;
             }
         }

Copied: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/OnlineUserTransaction.java (from r155688, geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/OnlineUserTransaction.java)
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/OnlineUserTransaction.java?view=diff&rev=155839&p1=geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/OnlineUserTransaction.java&r1=155688&p2=geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/OnlineUserTransaction.java&r2=155839
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/OnlineUserTransaction.java (original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/OnlineUserTransaction.java Tue Mar  1 15:30:08 2005
@@ -1,21 +1,17 @@
-package org.apache.geronimo.transaction;
+package org.apache.geronimo.transaction.context;
 
 import java.io.Serializable;
-import javax.transaction.UserTransaction;
-import javax.transaction.SystemException;
-import javax.transaction.NotSupportedException;
+import javax.resource.ResourceException;
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
 import javax.transaction.RollbackException;
-import javax.resource.ResourceException;
+import javax.transaction.SystemException;
+import javax.transaction.UserTransaction;
 
-import org.apache.geronimo.transaction.context.TransactionContextManager;
-import org.apache.geronimo.transaction.context.TransactionContext;
-import org.apache.geronimo.transaction.context.BeanTransactionContext;
-import org.apache.geronimo.transaction.context.UnspecifiedTransactionContext;
+import org.apache.geronimo.transaction.TrackedConnectionAssociator;
 
-/**
- */
 public final class OnlineUserTransaction implements UserTransaction, Serializable {
     private transient TransactionContextManager transactionContextManager;
     private transient TrackedConnectionAssociator trackedConnectionAssociator;
@@ -68,9 +64,13 @@
                 throw new RollbackException();
             }
         } finally {
-            UnspecifiedTransactionContext oldContext = beanContext.getOldContext();
+            TransactionContext oldContext = beanContext.getOldContext();
             transactionContextManager.setContext(oldContext);
-            oldContext.resume();
+            try {
+                oldContext.resume();
+            } catch (InvalidTransactionException e) {
+                throw (SystemException)new SystemException("Unable to resume perexisting transaction context").initCause(e);
+            }
         }
     }
 
@@ -83,9 +83,13 @@
         try {
             beanContext.rollback();
         } finally {
-            UnspecifiedTransactionContext oldContext = beanContext.getOldContext();
+            TransactionContext oldContext = beanContext.getOldContext();
             transactionContextManager.setContext(oldContext);
-            oldContext.resume();
+            try {
+                oldContext.resume();
+            } catch (InvalidTransactionException e) {
+                throw (SystemException)new SystemException("Unable to resume perexisting transaction context").initCause(e);
+            }
         }
     }
 }

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContext.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContext.java (original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContext.java Tue Mar  1 15:30:08 2005
@@ -17,17 +17,15 @@
 
 package org.apache.geronimo.transaction.context;
 
-import java.util.ArrayList;
-import java.util.Iterator;
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
 import javax.transaction.InvalidTransactionException;
 import javax.transaction.RollbackException;
+import javax.transaction.Synchronization;
 import javax.transaction.SystemException;
+import javax.transaction.xa.XAResource;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.transaction.DoubleKeyedHashMap;
+import org.apache.geronimo.transaction.ConnectionReleaser;
 import org.apache.geronimo.transaction.InstanceContext;
 import org.tranql.cache.InTxCache;
 
@@ -35,113 +33,48 @@
 /**
  * @version $Rev$ $Date$
  */
-public abstract class TransactionContext {
-    protected static final Log log = LogFactory.getLog(TransactionContext.class);
-    private static ThreadLocal CONTEXT = new ThreadLocal();
-
-    public static TransactionContext getContext() {
-        return (TransactionContext) CONTEXT.get();
-    }
-
-    public static void setContext(TransactionContext context) {
-        CONTEXT.set(context);
-    }
-
-    private InstanceContext currentContext;
-    private final DoubleKeyedHashMap associatedContexts = new DoubleKeyedHashMap();
-    private final DoubleKeyedHashMap dirtyContexts = new DoubleKeyedHashMap();
-    private InTxCache inTxCache;
-
-    public abstract boolean getRollbackOnly() throws SystemException;
-
-    public abstract void setRollbackOnly() throws SystemException;
-
-    public abstract void suspend() throws SystemException;
-
-    public abstract void resume() throws SystemException, InvalidTransactionException;
-
-    public abstract boolean commit() throws HeuristicMixedException, HeuristicRollbackException, RollbackException, SystemException;
-
-    public abstract void rollback() throws SystemException;
-
-    public final void associate(InstanceContext context) throws Throwable {
-        if (associatedContexts.put(context.getContainerId(), context.getId(), context) == null) {
-            context.associate();
-        }
-    }
-
-    public final void unassociate(InstanceContext context) throws Throwable {
-        associatedContexts.remove(context.getContainerId(), context.getId());
-        context.unassociate();
-    }
-
-    public final void unassociate(Object containerId, Object id) throws Throwable {
-        InstanceContext context = (InstanceContext) associatedContexts.remove(containerId, id);
-        if (context != null) {
-            context.unassociate();
-        }
-    }
-
-    public final InstanceContext getContext(Object containerId, Object id) {
-        return (InstanceContext) associatedContexts.get(containerId, id);
-    }
-
-    protected final ArrayList getAssociatedContexts() {
-        return new ArrayList(associatedContexts.values());
-    }
-
-    protected final void unassociateAll() {
-        ArrayList toFlush = getAssociatedContexts();
-        for (Iterator i = toFlush.iterator(); i.hasNext();) {
-            InstanceContext context = (InstanceContext) i.next();
-            try {
-                context.unassociate();
-            } catch (Throwable throwable) {
-                log.warn("Error while unassociating instance from transaction context: " + context, throwable);
-            }
-        }
-    }
-
-    public final InstanceContext beginInvocation(InstanceContext context) throws Throwable {
-        if (context.getId() != null) {
-            associate(context);
-            dirtyContexts.put(context.getContainerId(), context.getId(), context);
-        }
-        context.enter();
-        InstanceContext caller = currentContext;
-        currentContext = context;
-        return caller;
-    }
-
-    public final void endInvocation(InstanceContext caller) {
-        currentContext.exit();
-        currentContext = caller;
-    }
-
-    public final void flushState() throws Throwable {
-        while (dirtyContexts.isEmpty() == false) {
-            ArrayList toFlush = new ArrayList(dirtyContexts.values());
-            dirtyContexts.clear();
-            for (Iterator i = toFlush.iterator(); i.hasNext();) {
-                InstanceContext context = (InstanceContext) i.next();
-                if (!context.isDead()) {
-                    context.flush();
-                }
-            }
-        }
-        if (currentContext != null && currentContext.getId() != null) {
-            dirtyContexts.put(currentContext.getContainerId(), currentContext.getId(), currentContext);
-        }
-        if(inTxCache != null) {
-            inTxCache.flush();
-        }
-    }
-
-    public final void setInTxCache(InTxCache inTxCache) {
-        this.inTxCache = inTxCache;
-    }
-    
-    public final InTxCache getInTxCache() {
-        return inTxCache;
-    }
-}
+public interface TransactionContext {
+    boolean isInheritable();
+
+    boolean isActive();
+
+    boolean enlistResource(XAResource xaResource) throws RollbackException, SystemException;
+
+    boolean delistResource(XAResource xaResource, int flag) throws SystemException;
+
+    void registerSynchronization(Synchronization synchronization) throws RollbackException, SystemException;
+
+    boolean getRollbackOnly() throws SystemException;
+
+    void setRollbackOnly() throws SystemException;
+
+    void suspend() throws SystemException;
+
+    void resume() throws SystemException, InvalidTransactionException;
+
+    boolean commit() throws HeuristicMixedException, HeuristicRollbackException, RollbackException, SystemException;
+
+    void rollback() throws SystemException;
+
+    void associate(InstanceContext context) throws Throwable;
+
+    void unassociate(InstanceContext context) throws Throwable;
+
+    void unassociate(Object containerId, Object id) throws Throwable;
+
+    InstanceContext getContext(Object containerId, Object id);
+
+    InstanceContext beginInvocation(InstanceContext context) throws Throwable;
+
+    void endInvocation(InstanceContext caller);
+
+    void flushState() throws Throwable;
+
+    void setInTxCache(InTxCache inTxCache);
+
+    InTxCache getInTxCache();
+
+    void setManagedConnectionInfo(ConnectionReleaser key, Object info);
+
+    Object getManagedConnectionInfo(ConnectionReleaser key);
+}
\ No newline at end of file

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContextManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContextManager.java?view=diff&r1=155838&r2=155839
==============================================================================
--- 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 Tue Mar  1 15:30:08 2005
@@ -38,16 +38,18 @@
 import org.apache.geronimo.transaction.ImportedTransactionActiveException;
 import org.apache.geronimo.transaction.XAWork;
 import org.apache.geronimo.transaction.manager.XidImporter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * @version $Rev$ $Date$
  */
 public class TransactionContextManager implements XATerminator, XAWork {
-
+    private static final Log log = LogFactory.getLog(TransactionContextManager.class);
     private static final boolean NOT_IN_RECOVERY = false;
     private static final boolean IN_RECOVERY = true;
 
-
+    private ThreadLocal CONTEXT = new ThreadLocal();
     private final ExtendedTransactionManager transactionManager;
     private final XidImporter importer;
     private final Map importedTransactions = new HashMap();
@@ -73,21 +75,21 @@
     }
 
     public TransactionContext getContext() {
-        return TransactionContext.getContext();
+        return (TransactionContext) CONTEXT.get();
     }
 
     public void setContext(TransactionContext transactionContext) {
-        TransactionContext.setContext(transactionContext);
+        CONTEXT.set(transactionContext);
     }
 
-    public ContainerTransactionContext newContainerTransactionContext() throws NotSupportedException, SystemException {
+    public TransactionContext newContainerTransactionContext() throws NotSupportedException, SystemException {
         ContainerTransactionContext transactionContext = new ContainerTransactionContext(transactionManager);
-        TransactionContext.setContext(transactionContext);
+        setContext(transactionContext);
         return transactionContext;
     }
 
-    public BeanTransactionContext newBeanTransactionContext(long transactionTimeoutMilliseconds) throws NotSupportedException, SystemException {
-        TransactionContext ctx = TransactionContext.getContext();
+    public TransactionContext newBeanTransactionContext(long transactionTimeoutMilliseconds) throws NotSupportedException, SystemException {
+        TransactionContext ctx = getContext();
         if (ctx instanceof UnspecifiedTransactionContext == false) {
             throw new NotSupportedException("Previous Transaction has not been committed");
         }
@@ -103,16 +105,94 @@
             oldContext.resume();
             throw e;
         }
-        TransactionContext.setContext(transactionContext);
+        setContext(transactionContext);
         return transactionContext;
     }
 
-    public UnspecifiedTransactionContext newUnspecifiedTransactionContext() {
+    public TransactionContext newUnspecifiedTransactionContext() {
         UnspecifiedTransactionContext transactionContext = new UnspecifiedTransactionContext();
-        TransactionContext.setContext(transactionContext);
+        setContext(transactionContext);
         return transactionContext;
     }
 
+    public TransactionContext suspendBeanTransactionContext() throws SystemException {
+        // suspend the exisiting unspecified transaction context
+        TransactionContext callerContext = getContext();
+        if (!(callerContext instanceof BeanTransactionContext)) {
+            throw new SystemException("Caller context is not a bean managed  transaction context");
+        }
+        BeanTransactionContext beanContext = ((BeanTransactionContext) callerContext);
+
+        // update the old context in the bean context
+        UnspecifiedTransactionContext oldContext = beanContext.getOldContext();
+        beanContext.setOldContext(null);
+
+        // suspend the bean context
+        try {
+            beanContext.suspend();
+            return beanContext;
+        } catch (SystemException e) {
+            if (beanContext.isActive()) {
+                try {
+                    beanContext.rollback();
+                } catch (SystemException e1) {
+                    log.warn("Unable to rollback transaction", e);
+                }
+            }
+            throw e;
+        } finally {
+            // always resume the old transaction
+            setContext(oldContext);
+            oldContext.resume();
+            setContext(oldContext);
+        }
+    }
+
+    public void resumeBeanTransactionContext(TransactionContext context) throws SystemException, InvalidTransactionException {
+        if (!(context instanceof BeanTransactionContext)) {
+            throw new InvalidTransactionException("Context is not a bean managed transaction context");
+        }
+        if (!context.isActive()) {
+            throw new InvalidTransactionException("Context is not active");
+        }
+        BeanTransactionContext beanContext = ((BeanTransactionContext) context);
+
+        // suspend the exisiting unspecified transaction context
+        TransactionContext callerContext = getContext();
+        if (!(callerContext instanceof UnspecifiedTransactionContext)) {
+            throw new InvalidTransactionException("Caller context is not an unspecified transaction context");
+        }
+        callerContext.suspend();
+
+        try {
+            beanContext.setOldContext((UnspecifiedTransactionContext) callerContext);
+            context.resume();
+            setContext(context);
+        } catch (SystemException e) {
+            if (beanContext.isActive()) {
+                try {
+                    beanContext.rollback();
+                } catch (SystemException e1) {
+                    log.warn("Unable to rollback transaction", e);
+                }
+            }
+            beanContext.setOldContext(null);
+            callerContext.resume();
+            throw e;
+        } catch (InvalidTransactionException e) {
+            if (beanContext.isActive()) {
+                try {
+                    beanContext.rollback();
+                } catch (SystemException e1) {
+                    log.warn("Unable to rollback transaction", e);
+                }
+            }
+            beanContext.setOldContext(null);
+            callerContext.resume();
+            throw e;
+        }
+    }
+
     public int getStatus() throws SystemException {
         return transactionManager.getStatus();
     }
@@ -259,11 +339,11 @@
             }
             containerTransactionContext.resume();
         }
-        TransactionContext.setContext(containerTransactionContext);
+        setContext(containerTransactionContext);
     }
 
     public void end(Xid xid) throws XAException, SystemException {
-        TransactionContext.setContext(null);
+        setContext(null);
         synchronized (importedTransactions) {
             ContainerTransactionContext containerTransactionContext = (ContainerTransactionContext) importedTransactions.get(xid);
             if (containerTransactionContext == null) {
@@ -288,6 +368,8 @@
         infoFactory.addOperation("newContainerTransactionContext");
         infoFactory.addOperation("newBeanTransactionContext", new Class[] {long.class});
         infoFactory.addOperation("newUnspecifiedTransactionContext");
+        infoFactory.addOperation("resumeBeanTransactionContext",  new Class[] {TransactionContext.class});
+        infoFactory.addOperation("suspendBeanTransactionContext");
         infoFactory.addOperation("getStatus");
         infoFactory.addOperation("setRollbackOnly");
         infoFactory.addOperation("setTransactionTimeout", new Class[] {int.class});

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/UnspecifiedTransactionContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/UnspecifiedTransactionContext.java?view=diff&r1=155838&r2=155839
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/UnspecifiedTransactionContext.java (original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/UnspecifiedTransactionContext.java Tue Mar  1 15:30:08 2005
@@ -17,12 +17,39 @@
 
 package org.apache.geronimo.transaction.context;
 
+import javax.transaction.Synchronization;
+import javax.transaction.xa.XAResource;
+
 /**
  * @version $Rev$ $Date$
  */
-public class UnspecifiedTransactionContext extends TransactionContext {
+class UnspecifiedTransactionContext extends AbstractTransactionContext {
+    private boolean active = true;
     private boolean failed = false;
 
+    public UnspecifiedTransactionContext() {
+    }
+
+    public boolean isInheritable() {
+        return false;
+    }
+
+    public boolean isActive() {
+        return active;
+    }
+
+    public boolean enlistResource(XAResource xaResource){
+        throw new IllegalStateException("There is no transaction in progress.");
+    }
+
+    public boolean delistResource(XAResource xaResource, int flag) {
+        throw new IllegalStateException("There is no transaction in progress.");
+    }
+
+    public void registerSynchronization(Synchronization synchronization) {
+        throw new IllegalStateException("There is no transaction in progress.");
+    }
+
     public boolean getRollbackOnly() {
         return failed;
     }
@@ -59,6 +86,7 @@
         } catch (Throwable e) {
             log.error("Unable to flush state, continuing", e);
         } finally {
+            active = false;
             unassociateAll();
         }
     }

Copied: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/UserTransactionImpl.java (from r155688, geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/UserTransactionImpl.java)
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/UserTransactionImpl.java?view=diff&rev=155839&p1=geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/UserTransactionImpl.java&r1=155688&p2=geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/UserTransactionImpl.java&r2=155839
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/UserTransactionImpl.java (original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/UserTransactionImpl.java Tue Mar  1 15:30:08 2005
@@ -15,10 +15,9 @@
  *  limitations under the License.
  */
 
-package org.apache.geronimo.transaction;
+package org.apache.geronimo.transaction.context;
 
 import java.io.Serializable;
-
 import javax.transaction.HeuristicMixedException;
 import javax.transaction.HeuristicRollbackException;
 import javax.transaction.NotSupportedException;
@@ -26,7 +25,7 @@
 import javax.transaction.SystemException;
 import javax.transaction.UserTransaction;
 
-import org.apache.geronimo.transaction.context.TransactionContextManager;
+import org.apache.geronimo.transaction.TrackedConnectionAssociator;
 
 /**
  * Implementation of UserTransaction for use in an EJB.
@@ -95,27 +94,27 @@
 
     private static final UserTransaction OFFLINE = new OfflineUserTransaction();
     private static final class OfflineUserTransaction implements UserTransaction, Serializable {
-        public void begin() throws NotSupportedException, SystemException {
+        public void begin() {
             throw new IllegalStateException("Cannot use UserTransaction methods in this state");
         }
 
-        public void commit() throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, RollbackException, SecurityException, SystemException {
+        public void commit() {
             throw new IllegalStateException("Cannot use UserTransaction methods in this state");
         }
 
-        public int getStatus() throws SystemException {
+        public int getStatus() {
             throw new IllegalStateException("Cannot use UserTransaction methods in this state");
         }
 
-        public void rollback() throws IllegalStateException, SecurityException, SystemException {
+        public void rollback() {
             throw new IllegalStateException("Cannot use UserTransaction methods in this state");
         }
 
-        public void setRollbackOnly() throws IllegalStateException, SystemException {
+        public void setRollbackOnly() {
             throw new IllegalStateException("Cannot use UserTransaction methods in this state");
         }
 
-        public void setTransactionTimeout(int seconds) throws SystemException {
+        public void setTransactionTimeout(int seconds) {
             throw new IllegalStateException("Cannot use UserTransaction methods in this state");
         }
     };



Mime
View raw message