geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r427273 [5/6] - in /geronimo/branches/dain/notcm: applications/magicGball/magicGball-ear/src/plan/ applications/magicGball/src/plan/ configs/client-corba/src/plan/ configs/client-deployer/src/plan/ configs/client/src/plan/ configs/j2ee-corb...
Date Mon, 31 Jul 2006 21:08:24 GMT
Modified: geronimo/branches/dain/notcm/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java (original)
+++ geronimo/branches/dain/notcm/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java Mon Jul 31 14:08:15 2006
@@ -88,8 +88,7 @@
 import org.apache.geronimo.tomcat.HostGBean;
 import org.apache.geronimo.tomcat.RealmGBean;
 import org.apache.geronimo.tomcat.TomcatContainer;
-import org.apache.geronimo.transaction.context.TransactionContextManagerGBean;
-import org.apache.geronimo.transaction.manager.TransactionManagerImplGBean;
+import org.apache.geronimo.transaction.manager.GeronimoTransactionManagerGBean;
 
 /**
  * @version $Rev:385232 $ $Date$
@@ -100,8 +99,8 @@
     private final AbstractName serverName = naming.createRootName(baseId, "Server", "J2EEServer");
 
     protected Kernel kernel;
+    private AbstractName tmName;
     private AbstractName ctcName;
-    private AbstractName tcmName;
     private ClassLoader cl;
     private TomcatModuleBuilder builder;
     private File basedir = new File(System.getProperty("basedir", "."));
@@ -198,8 +197,7 @@
                 repositories,
                 new AbstractNameQuery(serverName),
                 moduleName,
-                null,
-                new AbstractNameQuery(tcmName),
+                new AbstractNameQuery(tmName),
                 new AbstractNameQuery(ctcName),
                 null,
                 null,
@@ -361,13 +359,13 @@
         connector.setAttribute("port", new Integer(8181));
         connector.setReferencePattern("TomcatContainer", containerName);
 
-        GBeanData tm = bootstrap.addGBean("TransactionManager", TransactionManagerImplGBean.GBEAN_INFO);
+        GBeanData tm = bootstrap.addGBean("TransactionManager", GeronimoTransactionManagerGBean.GBEAN_INFO);
+        tmName = tm.getAbstractName();
         tm.setAttribute("defaultTransactionTimeoutSeconds", new Integer(10));
 
-        GBeanData tcm = bootstrap.addGBean("TransactionContextManager", TransactionContextManagerGBean.GBEAN_INFO);
-        tcm.setReferencePattern("TransactionManager", tm.getAbstractName());
-        tcmName = tcm.getAbstractName();
-        ctcName = bootstrap.addGBean("ConnectionTrackingCoordinator", ConnectionTrackingCoordinatorGBean.GBEAN_INFO).getAbstractName();
+        GBeanData ctc = bootstrap.addGBean("ConnectionTrackingCoordinator", ConnectionTrackingCoordinatorGBean.GBEAN_INFO);
+        ctcName = ctc.getAbstractName();
+        ctc.setReferencePattern("TransactionManager", tmName);
 
         ConfigurationUtil.loadBootstrapConfiguration(kernel, bootstrap, getClass().getClassLoader());
 

Modified: geronimo/branches/dain/notcm/modules/tomcat/project.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/tomcat/project.xml?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/tomcat/project.xml (original)
+++ geronimo/branches/dain/notcm/modules/tomcat/project.xml Mon Jul 31 14:08:15 2006
@@ -41,7 +41,13 @@
     <!-- ============ -->
 
     <dependencies>
-
+        <dependency>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>${backport_util_concurrent_version}</version>
+            <type>test</type>
+        </dependency>
+        
         <dependency>
             <groupId>geronimo</groupId>
             <artifactId>geronimo-dependency-plugin</artifactId>

Modified: geronimo/branches/dain/notcm/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java (original)
+++ geronimo/branches/dain/notcm/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java Mon Jul 31 14:08:15 2006
@@ -21,7 +21,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-
 import javax.naming.NamingException;
 import javax.security.auth.Subject;
 import javax.security.jacc.PolicyContext;
@@ -43,8 +42,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
-import org.apache.geronimo.naming.reference.ClassLoaderAwareReference;
-import org.apache.geronimo.naming.reference.KernelAwareReference;
 import org.apache.geronimo.security.ContextManager;
 import org.apache.geronimo.security.IdentificationPrincipal;
 import org.apache.geronimo.security.SubjectId;
@@ -54,11 +51,9 @@
 import org.apache.geronimo.tomcat.interceptor.ComponentContextBeforeAfter;
 import org.apache.geronimo.tomcat.interceptor.InstanceContextBeforeAfter;
 import org.apache.geronimo.tomcat.interceptor.PolicyContextBeforeAfter;
-import org.apache.geronimo.tomcat.interceptor.TransactionContextBeforeAfter;
 import org.apache.geronimo.tomcat.util.SecurityHolder;
 import org.apache.geronimo.tomcat.valve.DefaultSubjectValve;
 import org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve;
-import org.apache.geronimo.transaction.context.TransactionContextManager;
 import org.apache.geronimo.webservices.POJOWebServiceServlet;
 import org.apache.geronimo.webservices.WebServiceContainer;
 import org.apache.geronimo.webservices.WebServiceContainerInvoker;
@@ -91,16 +86,7 @@
         Map componentContext = ctx.getComponentContext();
         try {
             if (componentContext != null) {
-                for (Iterator iterator = componentContext.values().iterator(); iterator.hasNext();) {
-                    Object value = iterator.next();
-                    if (value instanceof KernelAwareReference) {
-                        ((KernelAwareReference) value).setKernel(ctx.getKernel());
-                    }
-                    if (value instanceof ClassLoaderAwareReference) {
-                        ((ClassLoaderAwareReference) value).setClassLoader(ctx.getClassLoader());
-                    }
-                }
-                enc = EnterpriseNamingContext.createEnterpriseNamingContext(componentContext);
+                enc = EnterpriseNamingContext.createEnterpriseNamingContext(componentContext, ctx.getUserTransaction(), ctx.getKernel(), ctx.getClassLoader());
             }
         } catch (NamingException ne) {
             log.error(ne);
@@ -115,12 +101,6 @@
         // Set ComponentContext BeforeAfter
         if (enc != null) {
             interceptor = new ComponentContextBeforeAfter(interceptor, index++, enc);
-        }
-
-        // Set TransactionContext BeforeAfter
-        TransactionContextManager transactionContextManager = ctx.getTransactionContextManager();
-        if (transactionContextManager != null) {
-            interceptor = new TransactionContextBeforeAfter(interceptor, index++, transactionContextManager);
         }
 
         //Set a PolicyContext BeforeAfter

Modified: geronimo/branches/dain/notcm/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContext.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContext.java?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContext.java (original)
+++ geronimo/branches/dain/notcm/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContext.java Mon Jul 31 14:08:15 2006
@@ -20,14 +20,15 @@
 import java.util.Map;
 import java.util.Set;
 
+import javax.transaction.UserTransaction;
+
 import org.apache.catalina.Context;
 import org.apache.catalina.Manager;
 import org.apache.catalina.Realm;
 import org.apache.catalina.cluster.CatalinaCluster;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.tomcat.util.SecurityHolder;
-import org.apache.geronimo.transaction.TrackedConnectionAssociator;
-import org.apache.geronimo.transaction.context.TransactionContextManager;
+import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
 
 /**
  * @version $Rev$ $Date$
@@ -41,36 +42,36 @@
     public Context getContext();
 
     public String getDocBase();
-    
+
     public SecurityHolder getSecurityHolder();
-    
+
     public String getVirtualServer();
-    
+
     public ClassLoader getClassLoader();
-    
+
+    public UserTransaction getUserTransaction();
+
     public Map getComponentContext();
 
     public Kernel getKernel();
-    
-    public TransactionContextManager getTransactionContextManager();
-    
+
     public Set getApplicationManagedSecurityResources();
 
     public TrackedConnectionAssociator getTrackedConnectionAssociator();
 
     public Set getUnshareableResources();
-    
+
     public Realm getRealm();
-    
-    public List getValveChain();    
-    
+
+    public List getValveChain();
+
     public CatalinaCluster getCluster();
-    
+
     public Manager getManager();
-    
+
     public boolean isCrossContext();
 
     public boolean isDisableCookies();
-    
+
     public Map getWebServices();
 }

Modified: geronimo/branches/dain/notcm/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java (original)
+++ geronimo/branches/dain/notcm/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java Mon Jul 31 14:08:15 2006
@@ -40,14 +40,15 @@
 import org.apache.geronimo.security.jacc.RoleDesignateSource;
 import org.apache.geronimo.tomcat.cluster.CatalinaClusterGBean;
 import org.apache.geronimo.tomcat.util.SecurityHolder;
-import org.apache.geronimo.transaction.TrackedConnectionAssociator;
-import org.apache.geronimo.transaction.context.OnlineUserTransaction;
-import org.apache.geronimo.transaction.context.TransactionContextManager;
+import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
+import org.apache.geronimo.transaction.GeronimoUserTransaction;
 import org.apache.naming.resources.DirContextURLStreamHandler;
 
 import javax.management.ObjectName;
 import javax.management.MalformedObjectNameException;
 import javax.naming.directory.DirContext;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
 
 import java.net.URI;
 import java.net.URL;
@@ -92,6 +93,8 @@
 
     private final boolean disableCookies;
 
+    private final UserTransaction userTransaction;
+
     private final Map componentContext;
 
     private final Kernel kernel;
@@ -102,8 +105,6 @@
 
     private final TrackedConnectionAssociator trackedConnectionAssociator;
 
-    private final TransactionContextManager transactionContextManager;
-
     private final RoleDesignateSource roleDesignateSource;
 
     private final SecurityHolder securityHolder;
@@ -130,8 +131,7 @@
             Map componentContext,
             Set unshareableResources,
             Set applicationManagedSecurityResources,
-            OnlineUserTransaction userTransaction,
-            TransactionContextManager transactionContextManager,
+            TransactionManager transactionManager,
             TrackedConnectionAssociator trackedConnectionAssociator,
             TomcatContainer container,
             RoleDesignateSource roleDesignateSource,
@@ -149,7 +149,7 @@
 
         assert classLoader != null;
         assert configurationBaseUrl != null;
-        assert transactionContextManager != null;
+        assert transactionManager != null;
         assert trackedConnectionAssociator != null;
         assert componentContext != null;
         assert container != null;
@@ -170,8 +170,8 @@
         this.virtualServer = virtualServer;
         this.securityHolder = securityHolder;
 
+        this.userTransaction = new GeronimoUserTransaction(transactionManager);
         this.componentContext = componentContext;
-        this.transactionContextManager = transactionContextManager;
         this.unshareableResources = unshareableResources;
         this.applicationManagedSecurityResources = applicationManagedSecurityResources;
         this.trackedConnectionAssociator = trackedConnectionAssociator;
@@ -205,16 +205,18 @@
         }
 
         //Add the cluster
-        if (cluster != null)
-           catalinaCluster = (CatalinaCluster)cluster.getInternalObject();
-        else
+        if (cluster != null) {
+            catalinaCluster = (CatalinaCluster) cluster.getInternalObject();
+        } else {
             catalinaCluster = null;
+        }
 
         //Add the manager
-        if (manager != null)
-           this.manager = (Manager)manager.getInternalObject();
-        else
+        if (manager != null) {
+            this.manager = (Manager) manager.getInternalObject();
+        } else {
             this.manager = null;
+        }
 
         this.crossContext = crossContext;
 
@@ -235,9 +237,6 @@
                 throw new IllegalArgumentException("RoleDesignateSource must be supplied for a secure web app");
             }
         }
-        userTransaction.setUp(transactionContextManager,
-                trackedConnectionAssociator);
-
     }
 
     public String getObjectName() {
@@ -285,6 +284,10 @@
         this.docBase = docBase;
     }
 
+    public UserTransaction getUserTransaction() {
+        return userTransaction;
+    }
+
     public Map getComponentContext() {
         return componentContext;
     }
@@ -305,10 +308,6 @@
         return disableCookies;
     }
 
-    public TransactionContextManager getTransactionContextManager() {
-        return transactionContextManager;
-    }
-
     public Context getContext() {
         return context;
     }
@@ -392,8 +391,9 @@
 
     public String[] getServlets(){
         String[] result = null;
-        if ((context != null) && (context instanceof StandardContext))
-            result = ((StandardContext)context).getServlets();
+        if ((context != null) && (context instanceof StandardContext)) {
+            result = ((StandardContext) context).getServlets();
+        }
 
         return result;
     }
@@ -491,8 +491,7 @@
         infoBuilder.addAttribute("componentContext", Map.class, true);
         infoBuilder.addAttribute("unshareableResources", Set.class, true);
         infoBuilder.addAttribute("applicationManagedSecurityResources", Set.class, true);
-        infoBuilder.addAttribute("userTransaction", OnlineUserTransaction.class, true);
-        infoBuilder.addReference("TransactionContextManager", TransactionContextManager.class, NameFactory.TRANSACTION_CONTEXT_MANAGER);
+        infoBuilder.addReference("TransactionManager", TransactionManager.class, NameFactory.TRANSACTION_MANAGER);
         infoBuilder.addReference("TrackedConnectionAssociator", TrackedConnectionAssociator.class, NameFactory.JCA_CONNECTION_TRACKER);
 
         infoBuilder.addReference("Container", TomcatContainer.class, NameFactory.GERONIMO_SERVICE);
@@ -520,8 +519,7 @@
                 "componentContext",
                 "unshareableResources",
                 "applicationManagedSecurityResources",
-                "userTransaction",
-                "TransactionContextManager",
+                "TransactionManager",
                 "TrackedConnectionAssociator",
                 "Container",
                 "RoleDesignateSource",

Modified: geronimo/branches/dain/notcm/modules/tomcat/src/java/org/apache/geronimo/tomcat/interceptor/InstanceContextBeforeAfter.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/tomcat/src/java/org/apache/geronimo/tomcat/interceptor/InstanceContextBeforeAfter.java?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/tomcat/src/java/org/apache/geronimo/tomcat/interceptor/InstanceContextBeforeAfter.java (original)
+++ geronimo/branches/dain/notcm/modules/tomcat/src/java/org/apache/geronimo/tomcat/interceptor/InstanceContextBeforeAfter.java Mon Jul 31 14:08:15 2006
@@ -22,12 +22,12 @@
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 
-import org.apache.geronimo.transaction.DefaultInstanceContext;
-import org.apache.geronimo.transaction.InstanceContext;
-import org.apache.geronimo.transaction.TrackedConnectionAssociator;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContextImpl;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContext;
+import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
 
 public class InstanceContextBeforeAfter implements BeforeAfter{
-    
+
     private final BeforeAfter next;
     private final int index;
     private final Set unshareableResources;
@@ -44,7 +44,7 @@
 
     public void before(Object[] context, ServletRequest httpRequest, ServletResponse httpResponse) {
         try {
-            context[index] = trackedConnectionAssociator.enter(new DefaultInstanceContext(unshareableResources, applicationManagedSecurityResources));
+            context[index] = trackedConnectionAssociator.enter(new ConnectorInstanceContextImpl(unshareableResources, applicationManagedSecurityResources));
         } catch (ResourceException e) {
             throw new RuntimeException(e);
         }
@@ -58,7 +58,7 @@
             next.after(context, httpRequest, httpResponse);
         }
         try {
-            trackedConnectionAssociator.exit((InstanceContext) context[index]);
+            trackedConnectionAssociator.exit((ConnectorInstanceContext) context[index]);
         } catch (ResourceException e) {
             throw new RuntimeException(e);
         }

Modified: geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java (original)
+++ geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java Mon Jul 31 14:08:15 2006
@@ -24,8 +24,11 @@
 import java.util.Map;
 import java.util.Properties;
 
+import javax.transaction.TransactionManager;
+
 import junit.framework.TestCase;
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator;
+import org.apache.geronimo.connector.outbound.connectiontracking.GeronimoTransactionListener;
 import org.apache.geronimo.security.SecurityServiceImpl;
 import org.apache.geronimo.security.deploy.PrincipalInfo;
 import org.apache.geronimo.security.jaas.GeronimoLoginConfiguration;
@@ -41,8 +44,6 @@
 import org.apache.geronimo.system.serverinfo.BasicServerInfo;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.apache.geronimo.tomcat.util.SecurityHolder;
-import org.apache.geronimo.transaction.context.OnlineUserTransaction;
-import org.apache.geronimo.transaction.context.TransactionContextManager;
 import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
 
 
@@ -55,7 +56,7 @@
     protected final static String securityRealmName = "demo-properties-realm";
     private ConnectorGBean connector;
     protected TomcatContainer container;
-    private TransactionContextManager transactionContextManager;
+    private TransactionManager transactionManager;
     private ConnectionTrackingCoordinator connectionTrackingCoordinator;
 
     protected static final String POLICY_CONTEXT_ID = "securetest";
@@ -72,8 +73,7 @@
                 Collections.EMPTY_MAP,
                 null,
                 null,
-                new OnlineUserTransaction(),
-                transactionContextManager,
+                transactionManager,
                 connectionTrackingCoordinator,
                 container,
                 roleDesignateSource,
@@ -183,9 +183,10 @@
         connector = new ConnectorGBean("HTTP", null, "localhost", 8181, container);
         connector.doStart();
 
-        TransactionManagerImpl tm = new TransactionManagerImpl(10, null, null, Collections.EMPTY_LIST);
-        transactionContextManager = new TransactionContextManager(tm, tm);
+        TransactionManagerImpl transactionManager = new TransactionManagerImpl();
+        this.transactionManager = transactionManager;
         connectionTrackingCoordinator = new ConnectionTrackingCoordinator();
+        transactionManager.addTransactionAssociationListener(new GeronimoTransactionListener(connectionTrackingCoordinator));
     }
 
     protected void tearDown() throws Exception {

Modified: geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/ApplicationTest.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/ApplicationTest.java?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/ApplicationTest.java (original)
+++ geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/ApplicationTest.java Mon Jul 31 14:08:15 2006
@@ -24,7 +24,7 @@
 
 
 /**
- * @version $Rev: 387050 $ $Date$
+ * @version $Rev$ $Date$
  */
 public class ApplicationTest extends AbstractWebModuleTest {
 

Modified: geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/ContainerTest.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/ContainerTest.java?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/ContainerTest.java (original)
+++ geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/ContainerTest.java Mon Jul 31 14:08:15 2006
@@ -27,7 +27,7 @@
 
 
 /**
- * @version $Rev: 387050 $ $Date$
+ * @version $Rev$ $Date$
  */
 public class ContainerTest extends AbstractWebModuleTest {
 

Modified: geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/JAASSecurityTest.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/JAASSecurityTest.java?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/JAASSecurityTest.java (original)
+++ geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/JAASSecurityTest.java Mon Jul 31 14:08:15 2006
@@ -33,7 +33,7 @@
 /**
  * Tests the JAAS security for Tomcat
  *
- * @version $Revision: 387050 $ $Date$
+ * @version $Revision$ $Date$
  */
 public class JAASSecurityTest extends AbstractWebModuleTest {
 

Modified: geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/JACCSecurityTest.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/JACCSecurityTest.java?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/JACCSecurityTest.java (original)
+++ geronimo/branches/dain/notcm/modules/tomcat/src/test/org/apache/geronimo/tomcat/JACCSecurityTest.java Mon Jul 31 14:08:15 2006
@@ -45,7 +45,7 @@
 /**
  * Tests the JACC security for Tomcat
  *
- * @version $Revision: 387050 $ $Date$
+ * @version $Revision$ $Date$
  */
 public class JACCSecurityTest extends AbstractWebModuleTest {
 

Modified: geronimo/branches/dain/notcm/modules/transaction/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/transaction/pom.xml?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/transaction/pom.xml (original)
+++ geronimo/branches/dain/notcm/modules/transaction/pom.xml Mon Jul 31 14:08:15 2006
@@ -33,33 +33,38 @@
     <description>Geronimo Transaction</description>
 
     <dependencies>
-        <!-- temp, for ServerInfo. Remove when it is moved to Kernel-->
         <dependency>
             <groupId>org.apache.geronimo.modules</groupId>
-            <artifactId>geronimo-system</artifactId>
+            <artifactId>geronimo-j2ee</artifactId>
             <version>${pom.version}</version>
         </dependency>
 
-        <!-- thread pool, for timer -->
+        <!-- Only for *GBean classes -->
         <dependency>
             <groupId>org.apache.geronimo.modules</groupId>
-            <artifactId>geronimo-core</artifactId>
+            <artifactId>geronimo-kernel</artifactId>
+            <optional>true</optional>
             <version>${pom.version}</version>
         </dependency>
 
+        <!-- Only for *GBean classes -->
         <dependency>
             <groupId>org.apache.geronimo.modules</groupId>
-            <artifactId>geronimo-j2ee</artifactId>
+            <artifactId>geronimo-system</artifactId>
+            <optional>true</optional>
             <version>${pom.version}</version>
         </dependency>
 
         <dependency>
+<<<<<<< .mine
+=======
             <groupId>org.apache.geronimo.modules</groupId>
             <artifactId>geronimo-kernel</artifactId>
             <version>${pom.version}</version>
         </dependency>
 
         <dependency>
+>>>>>>> .r427184
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-jta_1.0.1B_spec</artifactId>
         </dependency>
@@ -75,8 +80,8 @@
         </dependency>
 
         <dependency>
-            <groupId>concurrent</groupId>
-            <artifactId>concurrent</artifactId>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
         </dependency>
 
         <dependency>
@@ -84,14 +89,17 @@
             <artifactId>commons-logging</artifactId>
         </dependency>
 
+        <!-- only for howl log -->
         <dependency>
             <groupId>org.objectweb.howl</groupId>
             <artifactId>howl</artifactId>
+            <optional>true</optional>
         </dependency>
 
         <dependency>
             <groupId>mx4j</groupId>
             <artifactId>mx4j</artifactId>
+            <scope>test</scope>
         </dependency>
     </dependencies>
 </project>

Modified: geronimo/branches/dain/notcm/modules/transaction/project.xml
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/transaction/project.xml?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/transaction/project.xml (original)
+++ geronimo/branches/dain/notcm/modules/transaction/project.xml Mon Jul 31 14:08:15 2006
@@ -42,32 +42,11 @@
 
     <dependencies>
         <!-- Module Dependencies -->
-        <!-- temp, for ServerInfo. Remove when it is moved to Kernel-->
-        <dependency>
-            <groupId>geronimo</groupId>
-            <artifactId>geronimo-system</artifactId>
-            <version>${pom.currentVersion}</version>
-        </dependency>
 
-        <!-- thread pool, for timer -->
-        <dependency>
-            <groupId>geronimo</groupId>
-            <artifactId>geronimo-core</artifactId>
-            <version>${pom.currentVersion}</version>
-        </dependency>
-
-
-        <!-- actual tx dependencies -->
         <dependency>
              <groupId>geronimo</groupId>
              <artifactId>geronimo-j2ee</artifactId>
              <version>${pom.currentVersion}</version>
-         </dependency>
-
-        <dependency>
-            <groupId>geronimo</groupId>
-            <artifactId>geronimo-kernel</artifactId>
-            <version>${pom.currentVersion}</version>
         </dependency>
 
         <dependency>
@@ -91,9 +70,9 @@
         <!-- Thirdparty -->
 
         <dependency>
-            <groupId>concurrent</groupId>
-            <artifactId>concurrent</artifactId>
-            <version>${concurrent_version}</version>
+            <groupId>backport-util-concurrent</groupId>
+            <artifactId>backport-util-concurrent</artifactId>
+            <version>${backport_util_concurrent_version}</version>
         </dependency>
 
         <dependency>
@@ -103,18 +82,39 @@
             <url>http://jakarta.apache.org/commons/logging/</url>
         </dependency>
 
-        <!--compiled by David Jencks, but tagged version-->
+        <!-- Optional -->
+
+        <!-- Only for *GBean classes -->
+        <dependency>
+            <groupId>geronimo</groupId>
+            <artifactId>geronimo-system</artifactId>
+            <version>${pom.currentVersion}</version>
+            <!--<optional>true</optional>-->
+        </dependency>
+
+        <!-- Only for *GBean classes -->
+        <dependency>
+            <groupId>geronimo</groupId>
+            <artifactId>geronimo-kernel</artifactId>
+            <version>${pom.currentVersion}</version>
+            <!--<optional>true</optional>-->
+        </dependency>
+
         <dependency>
             <groupId>org.objectweb.howl</groupId>
             <artifactId>howl</artifactId>
             <version>${howl_version}</version>
             <url>http://forge.objectweb.org/projects/howl</url>
+            <!--<optional>true</optional>-->
         </dependency>
 
+        <!-- Test -->
+
         <dependency>
             <groupId>mx4j</groupId>
             <artifactId>mx4j</artifactId>
             <version>${mx4j_version}</version>
+            <type>test</type>
         </dependency>
     </dependencies>
 </project>

Copied: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/GeronimoUserTransaction.java (from r417848, geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/OnlineUserTransaction.java)
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/GeronimoUserTransaction.java?p2=geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/GeronimoUserTransaction.java&p1=geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/OnlineUserTransaction.java&r1=417848&r2=427273&rev=427273&view=diff
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/OnlineUserTransaction.java (original)
+++ geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/GeronimoUserTransaction.java Mon Jul 31 14:08:15 2006
@@ -15,98 +15,62 @@
  *  limitations under the License.
  */
 
-package org.apache.geronimo.transaction.context;
+package org.apache.geronimo.transaction;
 
 import java.io.Serializable;
-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.transaction.SystemException;
+import javax.transaction.TransactionManager;
 import javax.transaction.UserTransaction;
 
-import org.apache.geronimo.transaction.TrackedConnectionAssociator;
+public final class GeronimoUserTransaction implements UserTransaction, Serializable {
+    private static final long serialVersionUID = -7524804683512228998L;
+    private transient TransactionManager transactionManager;
 
-public final class OnlineUserTransaction implements UserTransaction, Serializable {
-    private transient TransactionContextManager transactionContextManager;
-    private transient TrackedConnectionAssociator trackedConnectionAssociator;
+    public GeronimoUserTransaction(TransactionManager transactionManager) {
+        this.transactionManager = transactionManager;
+    }
 
     boolean isActive() {
-        return transactionContextManager != null;
+        return transactionManager != null;
     }
 
-    public void setUp(TransactionContextManager transactionContextManager, TrackedConnectionAssociator trackedConnectionAssociator) {
-        this.transactionContextManager = transactionContextManager;
-        this.trackedConnectionAssociator = trackedConnectionAssociator;
+    public void setTransactionManager(TransactionManager transactionManager) {
+        if (this.transactionManager == null) {
+            this.transactionManager = transactionManager;
+        } else if (this.transactionManager != transactionManager) {
+            throw new IllegalStateException("This user transaction is already associated with another transaction manager");
+        }
     }
 
 
     public int getStatus() throws SystemException {
-        return transactionContextManager.getStatus();
+        return transactionManager.getStatus();
     }
 
     public void setRollbackOnly() throws IllegalStateException, SystemException {
-        transactionContextManager.setRollbackOnly();
+        transactionManager.setRollbackOnly();
     }
 
     public void setTransactionTimeout(int seconds) throws SystemException {
         if (seconds < 0) {
             throw new SystemException("transaction timeout must be positive or 0, not " + seconds);
         }
-        transactionContextManager.setTransactionTimeout(seconds);
+        transactionManager.setTransactionTimeout(seconds);
     }
 
     public void begin() throws NotSupportedException, SystemException {
-        transactionContextManager.newBeanTransactionContext(0L);
-
-        if(trackedConnectionAssociator != null) {
-            try {
-                trackedConnectionAssociator.newTransaction();
-            } catch (ResourceException e) {
-                throw (SystemException)new SystemException().initCause(e);
-            }
-        }
+        transactionManager.begin();
     }
 
     public void commit() throws HeuristicMixedException, HeuristicRollbackException, IllegalStateException, RollbackException, SecurityException, SystemException {
-        TransactionContext ctx = transactionContextManager.getContext();
-        if (ctx instanceof BeanTransactionContext == false) {
-            throw new IllegalStateException("Transaction has not been started");
-        }
-        BeanTransactionContext beanContext = (BeanTransactionContext) ctx;
-        try {
-            if (!beanContext.commit()) {
-                throw new RollbackException();
-            }
-        } finally {
-            TransactionContext oldContext = beanContext.getOldContext();
-            transactionContextManager.setContext(oldContext);
-            try {
-                oldContext.resume();
-            } catch (InvalidTransactionException e) {
-                throw (SystemException)new SystemException("Unable to resume perexisting transaction context").initCause(e);
-            }
-        }
+        transactionManager.commit();
     }
 
     public void rollback() throws IllegalStateException, SecurityException, SystemException {
-        TransactionContext ctx = transactionContextManager.getContext();
-        if (ctx instanceof BeanTransactionContext == false) {
-            throw new IllegalStateException("Transaction has not been started");
-        }
-        BeanTransactionContext beanContext = (BeanTransactionContext) ctx;
-        try {
-            beanContext.rollback();
-        } finally {
-            TransactionContext oldContext = beanContext.getOldContext();
-            transactionContextManager.setContext(oldContext);
-            try {
-                oldContext.resume();
-            } catch (InvalidTransactionException e) {
-                throw (SystemException)new SystemException("Unable to resume perexisting transaction context").initCause(e);
-            }
-        }
+        transactionManager.rollback();
     }
 }

Propchange: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/GeronimoUserTransaction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/GeronimoUserTransaction.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/GeronimoUserTransaction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/log/HOWLLog.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/log/HOWLLog.java?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/log/HOWLLog.java (original)
+++ geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/log/HOWLLog.java Mon Jul 31 14:08:15 2006
@@ -18,6 +18,7 @@
 package org.apache.geronimo.transaction.log;
 
 import java.io.IOException;
+import java.io.File;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -27,17 +28,12 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.apache.geronimo.transaction.manager.LogException;
 import org.apache.geronimo.transaction.manager.Recovery;
 import org.apache.geronimo.transaction.manager.TransactionBranchInfo;
 import org.apache.geronimo.transaction.manager.TransactionBranchInfoImpl;
 import org.apache.geronimo.transaction.manager.TransactionLog;
 import org.apache.geronimo.transaction.manager.XidFactory;
-import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.objectweb.howl.log.Configuration;
 import org.objectweb.howl.log.LogClosedException;
 import org.objectweb.howl.log.LogConfigurationException;
@@ -53,7 +49,7 @@
 /**
  * @version $Rev$ $Date$
  */
-public class HOWLLog implements TransactionLog, GBeanLifecycle {
+public class HOWLLog implements TransactionLog {
 //    static final byte PREPARE = 1;
     //these are used as debugging aids only
     private static final byte COMMIT = 2;
@@ -63,7 +59,7 @@
 
     private static final Log log = LogFactory.getLog(HOWLLog.class);
 
-    private final ServerInfo serverInfo;
+    private File serverBaseDir;
     private String logFileDir;
 
     private final XidFactory xidFactory;
@@ -86,8 +82,8 @@
                    int minBuffers,
                    int threadsWaitingForceThreshold,
                    XidFactory xidFactory,
-                   ServerInfo serverInfo) throws IOException, LogConfigurationException {
-        this.serverInfo = serverInfo;
+                   File serverBaseDir) throws IOException, LogConfigurationException {
+        this.serverBaseDir = serverBaseDir;
         setBufferClassName(bufferClassName);
         setBufferSizeKBytes(bufferSize);
         setChecksumEnabled(checksumEnabled);
@@ -109,10 +105,15 @@
         return logFileDir;
     }
 
-    public void setLogFileDir(String logDir) {
-        this.logFileDir = logDir;
+    public void setLogFileDir(String logDirName) {
+        File logDir = new File(logDirName);
+        if (!logDir.isAbsolute()) {
+            logDir = new File(serverBaseDir, logDirName);
+        }
+
+        this.logFileDir = logDirName;
         if (started) {
-            configuration.setLogFileDir(serverInfo.resolveServerPath(logDir));
+            configuration.setLogFileDir(logDir.getAbsolutePath());
         }
     }
 
@@ -204,10 +205,6 @@
         configuration.setMaxLogFiles(maxLogFiles);
     }
 
-    public ServerInfo getServerInfo() {
-        return serverInfo;
-    }
-
     public void doStart() throws Exception {
         started = true;
         setLogFileDir(logFileDir);
@@ -395,49 +392,4 @@
         }
 
     }
-
-    public static final GBeanInfo GBEAN_INFO;
-
-    static {
-        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(HOWLLog.class, NameFactory.TRANSACTION_LOG);
-        infoFactory.addAttribute("bufferClassName", String.class, true);
-        infoFactory.addAttribute("bufferSizeKBytes", Integer.TYPE, true);
-        infoFactory.addAttribute("checksumEnabled", Boolean.TYPE, true);
-        infoFactory.addAttribute("flushSleepTimeMilliseconds", Integer.TYPE, true);
-        infoFactory.addAttribute("logFileDir", String.class, true);
-        infoFactory.addAttribute("logFileExt", String.class, true);
-        infoFactory.addAttribute("logFileName", String.class, true);
-        infoFactory.addAttribute("maxBlocksPerFile", Integer.TYPE, true);
-        infoFactory.addAttribute("maxBuffers", Integer.TYPE, true);
-        infoFactory.addAttribute("maxLogFiles", Integer.TYPE, true);
-        infoFactory.addAttribute("minBuffers", Integer.TYPE, true);
-        infoFactory.addAttribute("threadsWaitingForceThreshold", Integer.TYPE, true);
-
-        infoFactory.addReference("XidFactory", XidFactory.class, NameFactory.XID_FACTORY);
-        infoFactory.addReference("ServerInfo", ServerInfo.class, NameFactory.GERONIMO_SERVICE);
-
-        infoFactory.addInterface(TransactionLog.class);
-
-        infoFactory.setConstructor(new String[]{
-            "bufferClassName",
-            "bufferSizeKBytes",
-            "checksumEnabled",
-            "flushSleepTimeMilliseconds",
-            "logFileDir",
-            "logFileExt",
-            "logFileName",
-            "maxBlocksPerFile",
-            "maxBuffers",
-            "maxLogFiles",
-            "minBuffers",
-            "threadsWaitingForceThreshold",
-            "XidFactory",
-            "ServerInfo"});
-        GBEAN_INFO = infoFactory.getBeanInfo();
-    }
-
-    public static GBeanInfo getGBeanInfo() {
-        return GBEAN_INFO;
-    }
-
 }

Added: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/log/HOWLLogGBean.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/log/HOWLLogGBean.java?rev=427273&view=auto
==============================================================================
--- geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/log/HOWLLogGBean.java (added)
+++ geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/log/HOWLLogGBean.java Mon Jul 31 14:08:15 2006
@@ -0,0 +1,82 @@
+/**
+ *
+ * Copyright 2006 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.log;
+
+import java.io.IOException;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.apache.geronimo.transaction.manager.TransactionLog;
+import org.apache.geronimo.transaction.manager.XidFactory;
+import org.objectweb.howl.log.LogConfigurationException;
+
+/**
+ * @version $Rev: 406493 $ $Date: 2006-05-14 18:14:11 -0700 (Sun, 14 May 2006) $
+ */
+public class HOWLLogGBean extends HOWLLog implements GBeanLifecycle {
+    public HOWLLogGBean(String bufferClassName, int bufferSize, boolean checksumEnabled, int flushSleepTimeMilliseconds, String logFileDir, String logFileExt, String logFileName, int maxBlocksPerFile, int maxBuffers, int maxLogFiles, int minBuffers, int threadsWaitingForceThreshold, XidFactory xidFactory, ServerInfo serverInfo) throws IOException, LogConfigurationException {
+        super(bufferClassName, bufferSize, checksumEnabled, flushSleepTimeMilliseconds, logFileDir, logFileExt, logFileName, maxBlocksPerFile, maxBuffers, maxLogFiles, minBuffers, threadsWaitingForceThreshold, xidFactory, serverInfo.resolveServer("."));
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(HOWLLogGBean.class, NameFactory.TRANSACTION_LOG);
+        infoFactory.addAttribute("bufferClassName", String.class, true);
+        infoFactory.addAttribute("bufferSizeKBytes", Integer.TYPE, true);
+        infoFactory.addAttribute("checksumEnabled", Boolean.TYPE, true);
+        infoFactory.addAttribute("flushSleepTimeMilliseconds", Integer.TYPE, true);
+        infoFactory.addAttribute("logFileDir", String.class, true);
+        infoFactory.addAttribute("logFileExt", String.class, true);
+        infoFactory.addAttribute("logFileName", String.class, true);
+        infoFactory.addAttribute("maxBlocksPerFile", Integer.TYPE, true);
+        infoFactory.addAttribute("maxBuffers", Integer.TYPE, true);
+        infoFactory.addAttribute("maxLogFiles", Integer.TYPE, true);
+        infoFactory.addAttribute("minBuffers", Integer.TYPE, true);
+        infoFactory.addAttribute("threadsWaitingForceThreshold", Integer.TYPE, true);
+
+        infoFactory.addReference("XidFactory", XidFactory.class, NameFactory.XID_FACTORY);
+        infoFactory.addReference("ServerInfo", ServerInfo.class, NameFactory.GERONIMO_SERVICE);
+
+        infoFactory.addInterface(TransactionLog.class);
+
+        infoFactory.setConstructor(new String[]{
+            "bufferClassName",
+            "bufferSizeKBytes",
+            "checksumEnabled",
+            "flushSleepTimeMilliseconds",
+            "logFileDir",
+            "logFileExt",
+            "logFileName",
+            "maxBlocksPerFile",
+            "maxBuffers",
+            "maxLogFiles",
+            "minBuffers",
+            "threadsWaitingForceThreshold",
+            "XidFactory",
+            "ServerInfo"});
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return HOWLLogGBean.GBEAN_INFO;
+    }
+
+}

Added: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java?rev=427273&view=auto
==============================================================================
--- geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java (added)
+++ geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManager.java Mon Jul 31 14:08:15 2006
@@ -0,0 +1,203 @@
+/**
+ *
+ * Copyright 2006 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.manager;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import javax.resource.spi.XATerminator;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoTransactionManager extends TransactionManagerImpl implements XATerminator, XAWork {
+    private final Map importedTransactions = new HashMap();
+    private boolean isInRecovery = false;
+
+    public GeronimoTransactionManager() throws XAException {
+    }
+
+    public GeronimoTransactionManager(int defaultTransactionTimeoutSeconds) throws XAException {
+        super(defaultTransactionTimeoutSeconds);
+    }
+
+    public GeronimoTransactionManager(int defaultTransactionTimeoutSeconds, TransactionLog transactionLog) throws XAException {
+        super(defaultTransactionTimeoutSeconds, transactionLog);
+    }
+
+    public GeronimoTransactionManager(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog, Collection resourceManagers) throws XAException {
+        super(defaultTransactionTimeoutSeconds, xidFactory, transactionLog, resourceManagers);
+    }
+
+    /**
+     * @see javax.resource.spi.XATerminator#commit(javax.transaction.xa.Xid, boolean)
+     */
+    public void commit(Xid xid, boolean onePhase) throws XAException {
+        Transaction importedTransaction;
+        synchronized (importedTransactions) {
+            importedTransaction = (Transaction) importedTransactions.remove(xid);
+        }
+        if (importedTransaction == null) {
+            throw new XAException("No imported transaction for xid: " + xid);
+        }
+
+        try {
+            int status = importedTransaction.getStatus();
+            assert status == Status.STATUS_ACTIVE || status == Status.STATUS_PREPARED: "invalid status: " + status;
+        } catch (SystemException e) {
+            throw new XAException();
+        }
+        commit(importedTransaction, onePhase);
+    }
+
+    /**
+     * @see javax.resource.spi.XATerminator#forget(javax.transaction.xa.Xid)
+     */
+    public void forget(Xid xid) throws XAException {
+        Transaction importedTransaction;
+        synchronized (importedTransactions) {
+            importedTransaction = (Transaction) importedTransactions.remove(xid);
+        }
+        if (importedTransaction == null) {
+            throw new XAException("No imported transaction for xid: " + xid);
+        }
+        //todo is there a correct status test here?
+//        try {
+//            int status = tx.getStatus();
+//            assert status == Status.STATUS_ACTIVE || status == Status.STATUS_PREPARED;
+//        } catch (SystemException e) {
+//            throw new XAException();
+//        }
+        forget(importedTransaction);
+    }
+
+    /**
+     * @see javax.resource.spi.XATerminator#prepare(javax.transaction.xa.Xid)
+     */
+    public int prepare(Xid xid) throws XAException {
+        Transaction importedTransaction;
+        synchronized (importedTransactions) {
+            importedTransaction = (Transaction) importedTransactions.get(xid);
+        }
+        if (importedTransaction == null) {
+            throw new XAException("No imported transaction for xid: " + xid);
+        }
+        try {
+            int status = importedTransaction.getStatus();
+            assert status == Status.STATUS_ACTIVE;
+        } catch (SystemException e) {
+            throw new XAException();
+        }
+        return prepare(importedTransaction);
+    }
+
+    /**
+     * @see javax.resource.spi.XATerminator#recover(int)
+     */
+    public Xid[] recover(int flag) throws XAException {
+        if (!isInRecovery) {
+            if ((flag & XAResource.TMSTARTRSCAN) == 0) {
+                throw new XAException(XAException.XAER_PROTO);
+            }
+            isInRecovery = true;
+        }
+        if ((flag & XAResource.TMENDRSCAN) != 0) {
+            isInRecovery = false;
+        }
+        //we always return all xids in first call.
+        //calling "startrscan" repeatedly starts at beginning of list again.
+        if ((flag & XAResource.TMSTARTRSCAN) != 0) {
+            Map recoveredXidMap = getExternalXids();
+            Xid[] recoveredXids = new Xid[recoveredXidMap.size()];
+            int i = 0;
+            synchronized (importedTransactions) {
+                for (Iterator iterator = recoveredXidMap.entrySet().iterator(); iterator.hasNext();) {
+                    Map.Entry entry = (Map.Entry) iterator.next();
+                    Xid xid = (Xid) entry.getKey();
+                    recoveredXids[i++] = xid;
+                    Transaction transaction = (Transaction) entry.getValue();
+                    importedTransactions.put(xid, transaction);
+                }
+            }
+            return recoveredXids;
+        } else {
+            return new Xid[0];
+        }
+    }
+
+    /**
+     * @see javax.resource.spi.XATerminator#rollback(javax.transaction.xa.Xid)
+     */
+    public void rollback(Xid xid) throws XAException {
+        Transaction importedTransaction;
+        synchronized (importedTransactions) {
+            importedTransaction = (Transaction) importedTransactions.remove(xid);
+        }
+        if (importedTransaction == null) {
+            throw new XAException("No imported transaction for xid: " + xid);
+        }
+        try {
+            int status = importedTransaction.getStatus();
+            assert status == Status.STATUS_ACTIVE || status == Status.STATUS_PREPARED;
+        } catch (SystemException e) {
+            throw new XAException();
+        }
+        rollback(importedTransaction);
+    }
+
+
+    //XAWork implementation
+    public void begin(Xid xid, long txTimeoutMillis) throws XAException, InvalidTransactionException, SystemException, ImportedTransactionActiveException {
+        Transaction importedTransaction;
+        synchronized (importedTransactions) {
+            importedTransaction = (Transaction) importedTransactions.get(xid);
+            if (importedTransaction == null) {
+                // this does not associate tx with current thread.
+                importedTransaction = importXid(xid, txTimeoutMillis);
+                importedTransactions.put(xid, importedTransaction);
+            }
+            // associate the the imported transaction with the current thread
+            try {
+                resume(importedTransaction);
+            } catch (InvalidTransactionException e) {
+                // this occures if our transaciton is associated with another thread
+                throw new ImportedTransactionActiveException(xid);
+            }
+        }
+    }
+
+    public void end(Xid xid) throws XAException, SystemException {
+        synchronized (importedTransactions) {
+            Transaction importedTransaction = (Transaction) importedTransactions.get(xid);
+            if (importedTransaction == null) {
+                throw new XAException("No imported transaction for xid: " + xid);
+            }
+            if (importedTransaction != getTransaction()) {
+                throw new XAException("Imported transaction is not associated with the curren thread xid: " + xid);
+            }
+            suspend();
+        }
+    }
+}

Copied: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManagerGBean.java (from r417848, geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContextManagerGBean.java)
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManagerGBean.java?p2=geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManagerGBean.java&p1=geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContextManagerGBean.java&r1=417848&r2=427273&rev=427273&view=diff
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/context/TransactionContextManagerGBean.java (original)
+++ geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManagerGBean.java Mon Jul 31 14:08:15 2006
@@ -15,49 +15,72 @@
  *  limitations under the License.
  */
 
-package org.apache.geronimo.transaction.context;
+package org.apache.geronimo.transaction.manager;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import javax.transaction.xa.XAException;
 
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.ReferenceCollection;
+import org.apache.geronimo.gbean.ReferenceCollectionEvent;
+import org.apache.geronimo.gbean.ReferenceCollectionListener;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.apache.geronimo.transaction.ExtendedTransactionManager;
-import org.apache.geronimo.transaction.XAWork;
-import org.apache.geronimo.transaction.manager.XidImporter;
-
-import javax.resource.spi.XATerminator;
 
 /**
- * Used to provide the GBean metadata for the TransactionContextManager class
+ * Used to provide the GBean metadata for the GeronimoTransactionManager class
  *
  * @version $Rev$ $Date$
  */
-public class TransactionContextManagerGBean {
+public class GeronimoTransactionManagerGBean extends GeronimoTransactionManager {
+
+    /**
+     * TODO NOTE!!! this should be called in an unspecified transaction context, but we cannot enforce this restriction!
+     */
+    public GeronimoTransactionManagerGBean(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog, Collection resourceManagers) throws XAException {
+        super(defaultTransactionTimeoutSeconds == 0 ? DEFAULT_TIMEOUT : defaultTransactionTimeoutSeconds, 
+                xidFactory,
+                transactionLog,
+                resourceManagers);
+    }
+
+
+    /**
+     * We can track as resources are added into the geronimo kernel.
+     *
+     * @param resourceManagers
+     * @return the original list of resources.
+     */
+    protected List watchResourceManagers(Collection resourceManagers) {
+        if( resourceManagers instanceof ReferenceCollection ) {
+            List copy;
+            synchronized (resourceManagers) {
+                copy = new ArrayList(resourceManagers);
+                    ((ReferenceCollection)resourceManagers).addReferenceCollectionListener(new ReferenceCollectionListener() {
+                    public void memberAdded(ReferenceCollectionEvent event) {
+                        ResourceManager resourceManager = (ResourceManager) event.getMember();
+                        recoverResourceManager(resourceManager);
+                    }
+
+                    public void memberRemoved(ReferenceCollectionEvent event) {
+                    }
+
+                });
+            }
+            return copy;
+        } else {
+            return super.watchResourceManagers(resourceManagers);
+        }
+    }
 
     public static final GBeanInfo GBEAN_INFO;
 
     static {
-        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(TransactionContextManagerGBean.class, TransactionContextManager.class, NameFactory.TRANSACTION_CONTEXT_MANAGER);
-
-        infoFactory.addOperation("getTransactionManager");
-        infoFactory.addOperation("getContext");
-        infoFactory.addOperation("setContext", new Class[]{TransactionContext.class});
-        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});
-
-        infoFactory.addReference("TransactionManager", ExtendedTransactionManager.class, NameFactory.TRANSACTION_MANAGER);
-        infoFactory.addReference("XidImporter", XidImporter.class, NameFactory.TRANSACTION_MANAGER);
-
-        infoFactory.addInterface(XATerminator.class);
-        infoFactory.addInterface(XAWork.class);
-        infoFactory.addInterface(TransactionContextManager.class);
-
-        infoFactory.setConstructor(new String[]{"TransactionManager", "XidImporter"});
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(GeronimoTransactionManagerGBean.class,
+                TransactionManagerImplGBean.GBEAN_INFO,
+                NameFactory.TRANSACTION_MANAGER);
         GBEAN_INFO = infoFactory.getBeanInfo();
     }
 

Propchange: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManagerGBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManagerGBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/GeronimoTransactionManagerGBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/ImportedTransactionActiveException.java (from r417848, geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/ImportedTransactionActiveException.java)
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/ImportedTransactionActiveException.java?p2=geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/ImportedTransactionActiveException.java&p1=geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/ImportedTransactionActiveException.java&r1=417848&r2=427273&rev=427273&view=diff
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/ImportedTransactionActiveException.java (original)
+++ geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/ImportedTransactionActiveException.java Mon Jul 31 14:08:15 2006
@@ -15,7 +15,7 @@
  *  limitations under the License.
  */
 
-package org.apache.geronimo.transaction;
+package org.apache.geronimo.transaction.manager;
 
 import javax.transaction.xa.Xid;
 

Propchange: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/ImportedTransactionActiveException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/ImportedTransactionActiveException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/ImportedTransactionActiveException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/MonitorableTransactionManager.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/MonitorableTransactionManager.java?rev=427273&view=auto
==============================================================================
--- geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/MonitorableTransactionManager.java (added)
+++ geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/MonitorableTransactionManager.java Mon Jul 31 14:08:15 2006
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2006 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.manager;
+
+import java.util.EventListener;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface MonitorableTransactionManager extends EventListener {
+    // todo add notifications for begin, syspend, resume, commit, rollback and exceptions
+    void addTransactionAssociationListener(TransactionManagerMonitor listener);
+    void removeTransactionAssociationListener(TransactionManagerMonitor listener);
+}

Modified: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java (original)
+++ geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java Mon Jul 31 14:08:15 2006
@@ -237,7 +237,7 @@
                               }
                               else
                               {
-                                  throw new RollbackException("Unable to commit");
+                                  throw new RollbackException("Unable to commit: transaction marked for rollback");
                               }
             }
             synchronized (this) {

Modified: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java (original)
+++ geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerImpl.java Mon Jul 31 14:08:15 2006
@@ -17,43 +17,93 @@
 
 package org.apache.geronimo.transaction.manager;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.Xid;
+
+import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
+import edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.transaction.ExtendedTransactionManager;
 import org.apache.geronimo.transaction.log.UnrecoverableLog;
 
-import javax.transaction.*;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.Xid;
-import java.util.*;
-
 /**
  * Simple implementation of a transaction manager.
  *
  * @version $Rev$ $Date$
  */
-public class TransactionManagerImpl implements ExtendedTransactionManager, XidImporter {
+public class TransactionManagerImpl implements TransactionManager, UserTransaction, XidImporter, MonitorableTransactionManager {
+    private static final Log log = LogFactory.getLog(TransactionManagerImpl.class);
+    protected static final int DEFAULT_TIMEOUT = 600;
+    protected static final byte[] DEFAULT_TM_ID = new byte[] {71,84,77,73,68};
+
     final TransactionLog transactionLog;
     final XidFactory xidFactory;
     private final int defaultTransactionTimeoutMilliseconds;
     private final ThreadLocal transactionTimeoutMilliseconds = new ThreadLocal();
     private final ThreadLocal threadTx = new ThreadLocal();
+    private final ConcurrentHashMap associatedTransactions = new ConcurrentHashMap();
     private static final Log recoveryLog = LogFactory.getLog("RecoveryController");
     final Recovery recovery;
     final Collection resourceManagers;
+    private final CopyOnWriteArrayList transactionAssociationListeners = new CopyOnWriteArrayList();
     private List recoveryErrors = new ArrayList();
 
-    /**
-     * TODO NOTE!!! this should be called in an unspecified transaction context, but we cannot enforce this restriction!
-     */
+    public TransactionManagerImpl() throws XAException {
+        this(DEFAULT_TIMEOUT,
+                null,
+                null,
+                null);
+    }
+
+    public TransactionManagerImpl(int defaultTransactionTimeoutSeconds) throws XAException {
+        this(defaultTransactionTimeoutSeconds,
+                null,
+                null,
+                null);
+    }
+
+    public TransactionManagerImpl(int defaultTransactionTimeoutSeconds, TransactionLog transactionLog) throws XAException {
+        this(defaultTransactionTimeoutSeconds,
+                null,
+                transactionLog,
+                null);
+    }
+
     public TransactionManagerImpl(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog, Collection resourceManagers) throws XAException {
         if (defaultTransactionTimeoutSeconds <= 0) {
             throw new IllegalArgumentException("defaultTransactionTimeoutSeconds must be positive: attempted value: " + defaultTransactionTimeoutSeconds);
         }
 
         this.defaultTransactionTimeoutMilliseconds = defaultTransactionTimeoutSeconds * 1000;
-        this.transactionLog = transactionLog == null ? new UnrecoverableLog() : transactionLog;
-        this.xidFactory = xidFactory;
+
+        if (transactionLog == null) {
+            this.transactionLog = new UnrecoverableLog();
+        } else {
+            this.transactionLog = transactionLog;
+        }
+
+        if (xidFactory != null) {
+            this.xidFactory = xidFactory;
+        } else {
+            this.xidFactory = new XidFactoryImpl(DEFAULT_TM_ID);
+        }
+
         this.resourceManagers = resourceManagers;
         recovery = new RecoveryImpl(this.transactionLog, this.xidFactory);
 
@@ -71,11 +121,30 @@
         return new ArrayList(resourceManagers);
     }
 
-
     public Transaction getTransaction() throws SystemException {
         return (Transaction) threadTx.get();
     }
 
+    private void associate(TransactionImpl tx) throws InvalidTransactionException {
+        if (tx == null) throw new NullPointerException("tx is null");
+
+        Object existingAssociation = associatedTransactions.putIfAbsent(tx, Thread.currentThread());
+        if (existingAssociation != null) {
+            throw new InvalidTransactionException("Specified transaction is already associated with another thread");
+        }
+        threadTx.set(tx);
+        fireThreadAssociated(tx);
+    }
+
+    private void unassociate() throws SystemException {
+        Transaction tx = getTransaction();
+        if (tx != null) {
+            associatedTransactions.remove(tx);
+            threadTx.set(null);
+            fireThreadAssociated(tx);
+        }
+    }
+
     public void setTransactionTimeout(int seconds) throws SystemException {
         if (seconds < 0) {
             throw new SystemException("transaction timeout must be positive or 0 to reset to default");
@@ -102,8 +171,13 @@
         }
         TransactionImpl tx = new TransactionImpl(xidFactory, transactionLog, getTransactionTimeoutMilliseconds(transactionTimeoutMilliseconds));
 //        timeoutTimer.schedule(tx, getTransactionTimeoutMilliseconds(transactionTimeoutMilliseconds));
-        threadTx.set(tx);
-                // Todo: Verify if this is correct thing to do. Use default timeout for next transaction.
+        try {
+            associate(tx);
+        } catch (InvalidTransactionException e) {
+            // should not be possible since we just created that transaction and no one has a reference yet
+            throw new SystemException("Internal error: associate threw an InvalidTransactionException for a newly created transaction");
+        }
+        // Todo: Verify if this is correct thing to do. Use default timeout for next transaction.
         this.transactionTimeoutMilliseconds.set(null);
         return tx;
     }
@@ -111,19 +185,19 @@
     public Transaction suspend() throws SystemException {
         Transaction tx = getTransaction();
         if (tx != null) {
+            unassociate();
         }
-        threadTx.set(null);
         return tx;
     }
 
     public void resume(Transaction tx) throws IllegalStateException, InvalidTransactionException, SystemException {
-        if (threadTx.get() != null) {
-            throw new IllegalStateException("Transaction already associated with current thread");
+        if (getTransaction() != null) {
+            throw new IllegalStateException("Thread already associated with another transaction");
         }
-        if (tx instanceof TransactionImpl == false) {
+        if (!(tx instanceof TransactionImpl)) {
             throw new InvalidTransactionException("Cannot resume foreign transaction: " + tx);
         }
-        threadTx.set(tx);
+        associate((TransactionImpl) tx);
     }
 
     public void setRollbackOnly() throws IllegalStateException, SystemException {
@@ -142,7 +216,7 @@
         try {
             tx.commit();
         } finally {
-            threadTx.set(null);
+            unassociate();
         }
     }
 
@@ -154,7 +228,7 @@
         try {
             tx.rollback();
         } finally {
-            threadTx.set(null);
+            unassociate();
         }
     }
 
@@ -252,4 +326,33 @@
         return new HashMap(recovery.getExternalXids());
     }
 
+    public void addTransactionAssociationListener(TransactionManagerMonitor listener) {
+        transactionAssociationListeners.addIfAbsent(listener);
+    }
+
+    public void removeTransactionAssociationListener(TransactionManagerMonitor listener) {
+        transactionAssociationListeners.remove(listener);
+    }
+
+    protected void fireThreadAssociated(Transaction tx) {
+        for (Iterator iterator = transactionAssociationListeners.iterator(); iterator.hasNext();) {
+            TransactionManagerMonitor listener = (TransactionManagerMonitor) iterator.next();
+            try {
+                listener.threadAssociated(tx);
+            } catch (Exception e) {
+                log.warn("Error calling transaction association listener", e);
+            }
+        }
+    }
+
+    protected void fireThreadUnassociated(Transaction tx) {
+        for (Iterator iterator = transactionAssociationListeners.iterator(); iterator.hasNext();) {
+            TransactionManagerMonitor listener = (TransactionManagerMonitor) iterator.next();
+            try {
+                listener.threadUnassociated(tx);
+            } catch (Exception e) {
+                log.warn("Error calling transaction association listener", e);
+            }
+        }
+    }
 }

Modified: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerImplGBean.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerImplGBean.java?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerImplGBean.java (original)
+++ geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerImplGBean.java Mon Jul 31 14:08:15 2006
@@ -17,14 +17,17 @@
 
 package org.apache.geronimo.transaction.manager;
 
-import org.apache.geronimo.gbean.*;
-import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
-import org.apache.geronimo.transaction.ExtendedTransactionManager;
-
-import javax.transaction.xa.XAException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import javax.transaction.xa.XAException;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.ReferenceCollection;
+import org.apache.geronimo.gbean.ReferenceCollectionEvent;
+import org.apache.geronimo.gbean.ReferenceCollectionListener;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 
 /**
  * Simple implementation of a transaction manager.
@@ -40,7 +43,7 @@
         super(defaultTransactionTimeoutSeconds, xidFactory, transactionLog, resourceManagers);
     }
 
-    
+
     /**
      * We can track as resources are added into the geronimo kernel.
      *
@@ -78,9 +81,6 @@
         infoBuilder.addReference("XidFactory", XidFactory.class, NameFactory.XID_FACTORY);
         infoBuilder.addReference("TransactionLog", TransactionLog.class, NameFactory.TRANSACTION_LOG);
         infoBuilder.addReference("ResourceManagers", ResourceManager.class);//two kinds of things, so specify the type in each pattern.
-
-        infoBuilder.addInterface(ExtendedTransactionManager.class);
-        infoBuilder.addInterface(XidImporter.class);
 
         infoBuilder.setConstructor(new String[]{
                 "defaultTransactionTimeoutSeconds",

Added: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerMonitor.java?rev=427273&view=auto
==============================================================================
--- geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerMonitor.java (added)
+++ geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionManagerMonitor.java Mon Jul 31 14:08:15 2006
@@ -0,0 +1,28 @@
+/**
+ *
+ * Copyright 2006 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.manager;
+
+import java.util.EventListener;
+import javax.transaction.Transaction;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface TransactionManagerMonitor extends EventListener {
+    void threadAssociated(Transaction transaction);
+    void threadUnassociated(Transaction transaction);
+}

Copied: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XAWork.java (from r417848, geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/XAWork.java)
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XAWork.java?p2=geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XAWork.java&p1=geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/XAWork.java&r1=417848&r2=427273&rev=427273&view=diff
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/XAWork.java (original)
+++ geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XAWork.java Mon Jul 31 14:08:15 2006
@@ -15,12 +15,14 @@
  *  limitations under the License.
  */
 
-package org.apache.geronimo.transaction;
+package org.apache.geronimo.transaction.manager;
 
 import javax.transaction.xa.Xid;
 import javax.transaction.xa.XAException;
 import javax.transaction.SystemException;
 import javax.transaction.InvalidTransactionException;
+
+import org.apache.geronimo.transaction.manager.ImportedTransactionActiveException;
 
 /**
  * primarily an interface between the WorkManager/ExecutionContext and the tm.

Propchange: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XAWork.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XAWork.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XAWork.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XidImporter.java
URL: http://svn.apache.org/viewvc/geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XidImporter.java?rev=427273&r1=427272&r2=427273&view=diff
==============================================================================
--- geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XidImporter.java (original)
+++ geronimo/branches/dain/notcm/modules/transaction/src/java/org/apache/geronimo/transaction/manager/XidImporter.java Mon Jul 31 14:08:15 2006
@@ -38,4 +38,6 @@
     void forget(Transaction tx) throws XAException;
     int prepare(Transaction tx) throws XAException;
     void rollback(Transaction tx) throws XAException;
+
+    Map getExternalXids();
 }



Mime
View raw message