geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject cvs commit: incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction BeanTransactionContext.java ConnectionReleaser.java ContainerTransactionContext.java DoubleKeyedHashMap.java InheritableTransactionContext.java InstanceContext.java TransactionContext.java UnspecifiedTransactionContext.java
Date Sat, 31 Jan 2004 19:27:17 GMT
djencks     2004/01/31 11:27:17

  Modified:    modules/connector/src/java/org/apache/geronimo/connector/outbound
                        ConnectionTrackingInterceptor.java
                        ManagedConnectionInfo.java
                        TransactionCachingInterceptor.java
                        TransactionEnlistingInterceptor.java
               modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking
                        ConnectionTracker.java
                        ConnectionTrackingCoordinator.java
                        TrackedConnectionAssociator.java
               modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl
                        DefaultComponentContext.java
                        DefaultComponentInterceptor.java
                        DefaultInterceptor.java
                        DefaultTransactionContext.java
               modules/connector/src/test/org/apache/geronimo/connector/outbound
                        ConnectionManagerTest.java
                        ConnectionTrackingInterceptorTest.java
                        TransactionCachingInterceptorTest.java
               modules/connector/src/test/org/apache/geronimo/connector/outbound/connectiontracking
                        ConnectionTrackingCoordinatorTest.java
               modules/jetty project.xml
               modules/jetty/src/java/org/apache/geronimo/jetty
                        JettyWebApplicationContext.java
  Added:       modules/transaction/src/java/org/apache/geronimo/transaction
                        BeanTransactionContext.java ConnectionReleaser.java
                        ContainerTransactionContext.java
                        DoubleKeyedHashMap.java
                        InheritableTransactionContext.java
                        InstanceContext.java TransactionContext.java
                        UnspecifiedTransactionContext.java
  Removed:     modules/connector/src/java/org/apache/geronimo/connector/outbound
                        ConnectionReleaser.java
                        ConnectorComponentContext.java
                        ConnectorTransactionContext.java
  Log:
  Bring TransactionContext concept from Nova and start on the resulting simplifications
  
  Revision  Changes    Path
  1.3       +2 -2      incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java
  
  Index: ConnectionTrackingInterceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConnectionTrackingInterceptor.java	23 Jan 2004 06:47:05 -0000	1.2
  +++ ConnectionTrackingInterceptor.java	31 Jan 2004 19:27:16 -0000	1.3
  @@ -108,7 +108,7 @@
        */
       public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
           ManagedConnectionInfo managedConnectionInfo = connectionInfo.getManagedConnectionInfo();
  -        managedConnectionInfo.setTransactionContext(connectionTracker.getConnectorTransactionContext());
  +        managedConnectionInfo.setTransactionContext(connectionTracker.getTransactionContext());
           next.getConnection(connectionInfo);
           connectionTracker.handleObtained(this, connectionInfo);
       }
  
  
  
  1.2       +5 -3      incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionInfo.java
  
  Index: ManagedConnectionInfo.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ManagedConnectionInfo.java	23 Jan 2004 05:56:10 -0000	1.1
  +++ ManagedConnectionInfo.java	31 Jan 2004 19:27:16 -0000	1.2
  @@ -62,6 +62,8 @@
   import javax.security.auth.Subject;
   import javax.transaction.xa.XAResource;
   
  +import org.apache.geronimo.transaction.TransactionContext;
  +
   /**
    * ConnectionRequest.java
    *
  @@ -75,7 +77,7 @@
       private ManagedConnectionFactory managedConnectionFactory;
       private ConnectionRequestInfo connectionRequestInfo;
       private Subject subject;
  -    private ConnectorTransactionContext transactionContext;
  +    private TransactionContext transactionContext;
       private ManagedConnection managedConnection;
       private XAResource xares;
       private long lastUsed;
  @@ -114,11 +116,11 @@
           this.subject = subject;
       }
   
  -    public ConnectorTransactionContext getTransactionContext() {
  +    public TransactionContext getTransactionContext() {
           return transactionContext;
       }
   
  -    public void setTransactionContext(ConnectorTransactionContext transactionContext) {
  +    public void setTransactionContext(TransactionContext transactionContext) {
           this.transactionContext = transactionContext;
       }
   
  
  
  
  1.2       +9 -7      incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java
  
  Index: TransactionCachingInterceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TransactionCachingInterceptor.java	23 Jan 2004 05:56:10 -0000	1.1
  +++ TransactionCachingInterceptor.java	31 Jan 2004 19:27:16 -0000	1.2
  @@ -59,6 +59,8 @@
   import javax.resource.ResourceException;
   
   import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
  +import org.apache.geronimo.transaction.ConnectionReleaser;
  +import org.apache.geronimo.transaction.TransactionContext;
   
   /**
    * TransactionCachingInterceptor.java
  @@ -91,14 +93,14 @@
       }
   
       public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
  -        ConnectorTransactionContext connectorTransactionContext = connectionTracker.getConnectorTransactionContext();
  -        ManagedConnectionInfo managedConnectionInfo = connectorTransactionContext.getManagedConnectionInfo(this);
  +        TransactionContext transactionContext = connectionTracker.getTransactionContext();
  +        ManagedConnectionInfo managedConnectionInfo = (ManagedConnectionInfo)transactionContext.getManagedConnectionInfo(this);
           if (managedConnectionInfo != null) {
               connectionInfo.setManagedConnectionInfo(managedConnectionInfo);
               return;
           } else {
               next.getConnection(connectionInfo);
  -            connectorTransactionContext.setManagedConnectionInfo(this, connectionInfo.getManagedConnectionInfo());
  +            transactionContext.setManagedConnectionInfo(this, connectionInfo.getManagedConnectionInfo());
           }
       }
   
  @@ -108,8 +110,8 @@
               next.returnConnection(connectionInfo, connectionReturnAction);
           }
   
  -        ConnectorTransactionContext connectorTransactionContext = connectionTracker.getConnectorTransactionContext();
  -        if (connectorTransactionContext.isActive()) {
  +        TransactionContext transactionContext = connectionTracker.getTransactionContext();
  +        if (transactionContext.isActive()) {
               return;
           }
           if (connectionInfo.getManagedConnectionInfo().hasConnectionHandles()) {
  @@ -119,9 +121,9 @@
           next.returnConnection(connectionInfo, connectionReturnAction);
       }
   
  -    public void afterCompletion(ManagedConnectionInfo managedConnectionInfo) {
  +    public void afterCompletion(Object managedConnectionInfo) {
           ConnectionInfo connectionInfo = new ConnectionInfo();
  -        connectionInfo.setManagedConnectionInfo(managedConnectionInfo);
  +        connectionInfo.setManagedConnectionInfo((ManagedConnectionInfo)managedConnectionInfo);
           returnConnection(connectionInfo, ConnectionReturnAction.RETURN_HANDLE);
       }
   
  
  
  
  1.2       +4 -2      incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptor.java
  
  Index: TransactionEnlistingInterceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TransactionEnlistingInterceptor.java	23 Jan 2004 05:56:10 -0000	1.1
  +++ TransactionEnlistingInterceptor.java	31 Jan 2004 19:27:16 -0000	1.2
  @@ -61,6 +61,8 @@
   import javax.transaction.SystemException;
   import javax.transaction.xa.XAResource;
   
  +import org.apache.geronimo.transaction.TransactionContext;
  +
   /**
    * TransactionEnlistingInterceptor.java
    *
  @@ -83,7 +85,7 @@
           next.getConnection(connectionInfo);
           try {
               ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
  -            ConnectorTransactionContext transactionContext = mci.getTransactionContext();
  +            TransactionContext transactionContext = mci.getTransactionContext();
               if (transactionContext.isActive()) {
                   XAResource xares = mci.getXAResource();
                   transactionContext.getTransaction().enlistResource(xares);
  @@ -112,7 +114,7 @@
               ConnectionReturnAction connectionReturnAction) {
           try {
               ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
  -            ConnectorTransactionContext transactionContext = mci.getTransactionContext();
  +            TransactionContext transactionContext = mci.getTransactionContext();
               if (transactionContext.isActive()) {
                   XAResource xares = mci.getXAResource();
                   transactionContext.getTransaction().delistResource(xares, XAResource.TMSUSPEND);
  
  
  
  1.2       +3 -3      incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTracker.java
  
  Index: ConnectionTracker.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTracker.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectionTracker.java	23 Jan 2004 05:56:10 -0000	1.1
  +++ ConnectionTracker.java	31 Jan 2004 19:27:16 -0000	1.2
  @@ -2,7 +2,7 @@
   
   import org.apache.geronimo.connector.outbound.ConnectionInfo;
   import org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor;
  -import org.apache.geronimo.connector.outbound.ConnectorTransactionContext;
  +import org.apache.geronimo.transaction.TransactionContext;
   
   /**
    *
  @@ -19,5 +19,5 @@
               ConnectionTrackingInterceptor connectionTrackingInterceptor,
               ConnectionInfo connectionInfo);
   
  -    ConnectorTransactionContext getConnectorTransactionContext();
  +    TransactionContext getTransactionContext();
   }
  
  
  
  1.3       +32 -32    incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java
  
  Index: ConnectionTrackingCoordinator.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConnectionTrackingCoordinator.java	30 Jan 2004 05:29:41 -0000	1.2
  +++ ConnectionTrackingCoordinator.java	31 Jan 2004 19:27:16 -0000	1.3
  @@ -64,11 +64,11 @@
   
   import org.apache.geronimo.connector.outbound.ConnectionInfo;
   import org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor;
  -import org.apache.geronimo.connector.outbound.ConnectorComponentContext;
  -import org.apache.geronimo.connector.outbound.ConnectorTransactionContext;
   import org.apache.geronimo.gbean.GBeanInfo;
   import org.apache.geronimo.gbean.GBeanInfoFactory;
   import org.apache.geronimo.gbean.GOperationInfo;
  +import org.apache.geronimo.transaction.TransactionContext;
  +import org.apache.geronimo.transaction.InstanceContext;
   
   /**
    * ConnectionTrackingCoordinator tracks connections that are in use by
  @@ -90,22 +90,22 @@
   
       public final static GBeanInfo GBEAN_INFO;
   
  -    private final ThreadLocal currentConnectorComponentContexts = new ThreadLocal();
  +    private final ThreadLocal currentInstanceContexts = new ThreadLocal();
       private final ThreadLocal currentConnectorTransactionContexts = new ThreadLocal();
       private final ThreadLocal currentUnshareableResources = new ThreadLocal();
   
  -    public ConnectorComponentContext enter(ConnectorComponentContext newConnectorComponentContext)
  +    public InstanceContext enter(InstanceContext newInstanceContext)
               throws ResourceException {
  -        ConnectorComponentContext oldConnectorComponentContext = (ConnectorComponentContext) currentConnectorComponentContexts.get();
  -        currentConnectorComponentContexts.set(newConnectorComponentContext);
  -        return oldConnectorComponentContext;
  +        InstanceContext oldInstanceContext = (InstanceContext) currentInstanceContexts.get();
  +        currentInstanceContexts.set(newInstanceContext);
  +        return oldInstanceContext;
       }
   
  -    public void exit(ConnectorComponentContext reenteringConnectorComponentContext,
  +    public void exit(InstanceContext reenteringInstanceContext,
               Set unshareableResources)
               throws ResourceException {
  -        ConnectorComponentContext oldConnectorComponentContext = (ConnectorComponentContext) currentConnectorComponentContexts.get();
  -        Map resources = oldConnectorComponentContext.getConnectionManagerMap();
  +        InstanceContext oldInstanceContext = (InstanceContext) currentInstanceContexts.get();
  +        Map resources = oldInstanceContext.getConnectionManagerMap();
           for (Iterator i = resources.entrySet().iterator(); i.hasNext();) {
               Map.Entry entry = (Map.Entry) i.next();
               ConnectionTrackingInterceptor mcci =
  @@ -116,7 +116,7 @@
                   i.remove();
               }
           }
  -        currentConnectorComponentContexts.set(reenteringConnectorComponentContext);
  +        currentInstanceContexts.set(reenteringInstanceContext);
       }
   
       public Set setUnshareableResources(Set unshareableResources) {
  @@ -125,12 +125,12 @@
           return oldUnshareableResources;
       }
   
  -    public ConnectorTransactionContext setConnectorTransactionContext(ConnectorTransactionContext newConnectorTransactionContext) throws ResourceException {
  -        ConnectorTransactionContext oldConnectorTransactionContext = (ConnectorTransactionContext) currentConnectorTransactionContexts.get();
  -        currentConnectorTransactionContexts.set(newConnectorTransactionContext);
  -        ConnectorComponentContext connectorComponentContext = (ConnectorComponentContext) currentConnectorComponentContexts.get();
  +    public TransactionContext setTransactionContext(TransactionContext newTransactionContext) throws ResourceException {
  +        TransactionContext oldConnectorTransactionContext = (TransactionContext) currentConnectorTransactionContexts.get();
  +        currentConnectorTransactionContexts.set(newTransactionContext);
  +        InstanceContext instanceContext = (InstanceContext) currentInstanceContexts.get();
           Set unshareableResources = (Set) currentUnshareableResources.get();
  -        Map connectionManagerToManagedConnectionInfoMap = connectorComponentContext.getConnectionManagerMap();
  +        Map connectionManagerToManagedConnectionInfoMap = instanceContext.getConnectionManagerMap();
           for (Iterator i = connectionManagerToManagedConnectionInfoMap.entrySet().iterator(); i.hasNext();) {
               Map.Entry entry = (Map.Entry) i.next();
               ConnectionTrackingInterceptor mcci =
  @@ -141,18 +141,18 @@
           return oldConnectorTransactionContext;
       }
   
  -    public void resetConnectorTransactionContext(ConnectorTransactionContext connectorTransactionContext) {
  -        currentConnectorTransactionContexts.set(connectorTransactionContext);
  +    public void resetTransactionContext(TransactionContext transactionContext) {
  +        currentConnectorTransactionContexts.set(transactionContext);
       }
   
       public void handleObtained(
               ConnectionTrackingInterceptor connectionTrackingInterceptor,
               ConnectionInfo connectionInfo) {
  -        ConnectorComponentContext connectorComponentContext = (ConnectorComponentContext) currentConnectorComponentContexts.get();
  -        if (connectorComponentContext == null) {
  +        InstanceContext instanceContext = (InstanceContext) currentInstanceContexts.get();
  +        if (instanceContext == null) {
               return;
           }
  -        Map resources = connectorComponentContext.getConnectionManagerMap();
  +        Map resources = instanceContext.getConnectionManagerMap();
           Set infos = (Set) resources.get(connectionTrackingInterceptor);
           if (infos == null) {
               infos = new HashSet();
  @@ -164,30 +164,30 @@
       public void handleReleased(
               ConnectionTrackingInterceptor connectionTrackingInterceptor,
               ConnectionInfo connectionInfo) {
  -        ConnectorComponentContext connectorComponentContext = (ConnectorComponentContext) currentConnectorComponentContexts.get();
  -        if (connectorComponentContext == null) {
  +        InstanceContext instanceContext = (InstanceContext) currentInstanceContexts.get();
  +        if (instanceContext == null) {
               return;
           }
  -        Map resources = connectorComponentContext.getConnectionManagerMap();
  +        Map resources = instanceContext.getConnectionManagerMap();
           Set infos = (Set) resources.get(connectionTrackingInterceptor);
           //It's not at all clear that an equal ci will be supplied here
           infos.remove(connectionInfo);
       }
   
  -    public ConnectorTransactionContext getConnectorTransactionContext() {
  -        return (ConnectorTransactionContext) currentConnectorTransactionContexts.get();
  +    public TransactionContext getTransactionContext() {
  +        return (TransactionContext) currentConnectorTransactionContexts.get();
       }
   
       static {
           GBeanInfoFactory infoFactory = new GBeanInfoFactory(ConnectionTrackingCoordinator.class.getName());
  -        infoFactory.addOperation(new GOperationInfo("enter", new String[]{ConnectorComponentContext.class.getName()}));
  -        infoFactory.addOperation(new GOperationInfo("exit", new String[]{ConnectorComponentContext.class.getName(), Set.class.getName()}));
  -        infoFactory.addOperation(new GOperationInfo("setConnectorTransactionContext", new String[]{ConnectorTransactionContext.class.getName()}));
  +        infoFactory.addOperation(new GOperationInfo("enter", new String[]{InstanceContext.class.getName()}));
  +        infoFactory.addOperation(new GOperationInfo("exit", new String[]{InstanceContext.class.getName(), Set.class.getName()}));
  +        infoFactory.addOperation(new GOperationInfo("setTransactionContext", new String[]{TransactionContext.class.getName()}));
           infoFactory.addOperation(new GOperationInfo("setUnshareableResources", new String[]{Set.class.getName()}));
  -        infoFactory.addOperation(new GOperationInfo("resetConnectorTransactionContext", new String[]{ConnectorTransactionContext.class.getName()}));
  +        infoFactory.addOperation(new GOperationInfo("resetTransactionContext", new String[]{TransactionContext.class.getName()}));
           infoFactory.addOperation(new GOperationInfo("handleObtained", new String[]{ConnectionTrackingInterceptor.class.getName(), ConnectionInfo.class.getName()}));
           infoFactory.addOperation(new GOperationInfo("handleReleased", new String[]{ConnectionTrackingInterceptor.class.getName(), ConnectionInfo.class.getName()}));
  -        infoFactory.addOperation(new GOperationInfo("getConnectorTransactionContext"));
  +        infoFactory.addOperation(new GOperationInfo("getTransactionContext"));
           GBEAN_INFO = infoFactory.getBeanInfo();
       }
   
  
  
  
  1.2       +9 -7      incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/TrackedConnectionAssociator.java
  
  Index: TrackedConnectionAssociator.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/TrackedConnectionAssociator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TrackedConnectionAssociator.java	23 Jan 2004 05:56:10 -0000	1.1
  +++ TrackedConnectionAssociator.java	31 Jan 2004 19:27:16 -0000	1.2
  @@ -1,10 +1,11 @@
   package org.apache.geronimo.connector.outbound.connectiontracking;
   
   import java.util.Set;
  +
   import javax.resource.ResourceException;
   
  -import org.apache.geronimo.connector.outbound.ConnectorComponentContext;
  -import org.apache.geronimo.connector.outbound.ConnectorTransactionContext;
  +import org.apache.geronimo.transaction.InstanceContext;
  +import org.apache.geronimo.transaction.TransactionContext;
   
   /**
    *
  @@ -13,17 +14,18 @@
    *
    * */
   public interface TrackedConnectionAssociator {
  -    ConnectorComponentContext enter(ConnectorComponentContext newConnectorComponentContext
  +
  +    InstanceContext enter(InstanceContext newInstanceContext
               )
               throws ResourceException;
   
  -    void exit(ConnectorComponentContext reenteringConnectorComponentContext,
  +    void exit(InstanceContext reenteringInstanceContext,
               Set unshareableResources)
               throws ResourceException;
   
  -    ConnectorTransactionContext setConnectorTransactionContext(ConnectorTransactionContext newConnectorTransactionContext) throws ResourceException;
  +    TransactionContext setTransactionContext(TransactionContext newTransactionContext) throws ResourceException;
   
       Set setUnshareableResources(Set unshareableResources);
   
  -    void resetConnectorTransactionContext(ConnectorTransactionContext connectorTransactionContext);
  +    void resetTransactionContext(TransactionContext transactionContext);
   }
  
  
  
  1.2       +27 -3     incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl/DefaultComponentContext.java
  
  Index: DefaultComponentContext.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl/DefaultComponentContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultComponentContext.java	23 Jan 2004 05:56:10 -0000	1.1
  +++ DefaultComponentContext.java	31 Jan 2004 19:27:16 -0000	1.2
  @@ -59,7 +59,8 @@
   import java.util.HashMap;
   import java.util.Map;
   
  -import org.apache.geronimo.connector.outbound.ConnectorComponentContext;
  +import org.apache.geronimo.transaction.InstanceContext;
  +
   
   /**
    * Simple implementation of ComponentContext satisfying invariant.
  @@ -67,9 +68,32 @@
    * @version $Revision$ $Date$
    *
    * */
  -public class DefaultComponentContext implements ConnectorComponentContext {
  +public class DefaultComponentContext implements InstanceContext {
   
       private final Map connectionManagerMap = new HashMap();
  +
  +    public Object getId() {
  +        return null;
  +    }
  +
  +    public void setId(Object id) {
  +    }
  +
  +    public Object getContainer() {
  +        return null;
  +    }
  +
  +    public void associate() throws Exception {
  +    }
  +
  +    public void flush() throws Exception {
  +    }
  +
  +    public void beforeCommit() throws Exception {
  +    }
  +
  +    public void afterCommit(boolean status) throws Exception {
  +    }
   
       public Map getConnectionManagerMap() {
           return connectionManagerMap;
  
  
  
  1.2       +15 -15    incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl/DefaultComponentInterceptor.java
  
  Index: DefaultComponentInterceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl/DefaultComponentInterceptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultComponentInterceptor.java	23 Jan 2004 05:56:10 -0000	1.1
  +++ DefaultComponentInterceptor.java	31 Jan 2004 19:27:16 -0000	1.2
  @@ -63,9 +63,9 @@
   import javax.transaction.Transaction;
   import javax.transaction.TransactionManager;
   
  -import org.apache.geronimo.connector.outbound.ConnectorComponentContext;
  -import org.apache.geronimo.connector.outbound.ConnectorTransactionContext;
   import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
  +import org.apache.geronimo.transaction.TransactionContext;
  +import org.apache.geronimo.transaction.InstanceContext;
   
   /**
    *
  @@ -91,26 +91,26 @@
           this.transactionManager = transactionManager;
       }
   
  -    public Object invoke(ConnectorComponentContext newConnectorComponentContext) throws Throwable {
  +    public Object invoke(InstanceContext newInstanceContext) throws Throwable {
           Transaction transaction = transactionManager.getTransaction();
  -        ConnectorTransactionContext newConnectorTransactionContext;
  +        TransactionContext newTransactionContext;
           if (transaction == null || transaction.getStatus() == Status.STATUS_COMMITTED || transaction.getStatus() == Status.STATUS_ROLLEDBACK) {
  -            newConnectorTransactionContext = new DefaultTransactionContext(null);
  +            newTransactionContext = new DefaultTransactionContext(null);
           } else {
  -            newConnectorTransactionContext = (ConnectorTransactionContext) transactionToTransactionContextMap.get(transaction);
  -            if (newConnectorTransactionContext == null) {
  -                newConnectorTransactionContext = new DefaultTransactionContext(transaction);
  -                transactionToTransactionContextMap.put(transaction, newConnectorTransactionContext);
  +            newTransactionContext = (TransactionContext) transactionToTransactionContextMap.get(transaction);
  +            if (newTransactionContext == null) {
  +                newTransactionContext = new DefaultTransactionContext(transaction);
  +                transactionToTransactionContextMap.put(transaction, newTransactionContext);
               }
           }
           Set oldUnshareableResources = cachedConnectionAssociator.setUnshareableResources(unshareableResources);
  -        ConnectorComponentContext oldConnectorComponentContext = cachedConnectionAssociator.enter(newConnectorComponentContext);
  -        ConnectorTransactionContext oldConnectorTransactionContext = cachedConnectionAssociator.setConnectorTransactionContext(newConnectorTransactionContext);
  +        InstanceContext oldInstanceContext = cachedConnectionAssociator.enter(newInstanceContext);
  +        TransactionContext oldTransactionContext = cachedConnectionAssociator.setTransactionContext(newTransactionContext);
           try {
  -            return next.invoke(newConnectorComponentContext);
  +            return next.invoke(newInstanceContext);
           } finally {
  -            cachedConnectionAssociator.exit(oldConnectorComponentContext, unshareableResources);
  -            cachedConnectionAssociator.resetConnectorTransactionContext(oldConnectorTransactionContext);
  +            cachedConnectionAssociator.exit(oldInstanceContext, unshareableResources);
  +            cachedConnectionAssociator.resetTransactionContext(oldTransactionContext);
               cachedConnectionAssociator.setUnshareableResources(oldUnshareableResources);
           }
       }
  
  
  
  1.2       +4 -3      incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl/DefaultInterceptor.java
  
  Index: DefaultInterceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl/DefaultInterceptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultInterceptor.java	23 Jan 2004 05:56:10 -0000	1.1
  +++ DefaultInterceptor.java	31 Jan 2004 19:27:16 -0000	1.2
  @@ -56,7 +56,8 @@
   
   package org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl;
   
  -import org.apache.geronimo.connector.outbound.ConnectorComponentContext;
  +import org.apache.geronimo.transaction.InstanceContext;
  +
   
   /**
    *
  @@ -66,5 +67,5 @@
    * */
   public interface DefaultInterceptor {
   
  -    Object invoke(ConnectorComponentContext newConnectorComponentContext) throws Throwable;
  +    Object invoke(InstanceContext newInstanceContext) throws Throwable;
   }
  
  
  
  1.2       +26 -7     incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl/DefaultTransactionContext.java
  
  Index: DefaultTransactionContext.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl/DefaultTransactionContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultTransactionContext.java	23 Jan 2004 05:56:10 -0000	1.1
  +++ DefaultTransactionContext.java	31 Jan 2004 19:27:16 -0000	1.2
  @@ -64,9 +64,13 @@
   import javax.transaction.Synchronization;
   import javax.transaction.SystemException;
   import javax.transaction.Transaction;
  +import javax.transaction.NotSupportedException;
  +import javax.transaction.InvalidTransactionException;
  +import javax.transaction.HeuristicMixedException;
  +import javax.transaction.HeuristicRollbackException;
   
  -import org.apache.geronimo.connector.outbound.ConnectionReleaser;
  -import org.apache.geronimo.connector.outbound.ConnectorTransactionContext;
  +import org.apache.geronimo.transaction.ConnectionReleaser;
  +import org.apache.geronimo.transaction.TransactionContext;
   import org.apache.geronimo.connector.outbound.ManagedConnectionInfo;
   
   /**
  @@ -75,7 +79,7 @@
    * @version $Revision$ $Date$
    *
    * */
  -public class DefaultTransactionContext implements ConnectorTransactionContext, Synchronization {
  +public class DefaultTransactionContext extends TransactionContext implements Synchronization {
   
       private Map managedConnections;
   
  @@ -89,13 +93,28 @@
           }
       }
   
  +    public void begin() throws SystemException, NotSupportedException {
  +    }
  +
  +    public void suspend() throws SystemException {
  +    }
  +
  +    public void resume() throws SystemException, InvalidTransactionException {
  +    }
  +
  +    public void commit() throws HeuristicMixedException, HeuristicRollbackException, RollbackException, SystemException {
  +    }
  +
  +    public void rollback() throws SystemException {
  +    }
  +
       /**
        * Don't try to cache connections if there is no transaction, since there is no
        * event that tells us to release the connection.
        * @param key
        * @param info
        */
  -    public void setManagedConnectionInfo(ConnectionReleaser key, ManagedConnectionInfo info) {
  +    public void setManagedConnectionInfo(ConnectionReleaser key, Object info) {
           if (isActive()) {
               if (managedConnections == null) {
                   managedConnections = new HashMap();
  @@ -104,7 +123,7 @@
           }
       }
   
  -    public ManagedConnectionInfo getManagedConnectionInfo(ConnectionReleaser key) {
  +    public Object getManagedConnectionInfo(ConnectionReleaser key) {
           if (managedConnections == null) {
               return null;
           }
  @@ -135,7 +154,7 @@
               for (Iterator entries = managedConnections.entrySet().iterator(); entries.hasNext();) {
                   Map.Entry entry = (Map.Entry) entries.next();
                   ConnectionReleaser key = (ConnectionReleaser) entry.getKey();
  -                key.afterCompletion((ManagedConnectionInfo) entry.getValue());
  +                key.afterCompletion(entry.getValue());
               }
               //should we clear managedConnections?  might be less work for garbage collector.  any other reason?
           }
  
  
  
  1.2       +3 -2      incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTest.java
  
  Index: ConnectionManagerTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectionManagerTest.java	23 Jan 2004 05:56:11 -0000	1.1
  +++ ConnectionManagerTest.java	31 Jan 2004 19:27:16 -0000	1.2
  @@ -73,6 +73,7 @@
   import org.apache.geronimo.kernel.Kernel;
   import org.apache.geronimo.security.bridge.RealmBridge;
   import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
  +import org.apache.geronimo.transaction.InstanceContext;
   
   import junit.framework.TestCase;
   
  @@ -174,7 +175,7 @@
           assertTrue("Should be committed", mockXAResource.getCommitted() != null);
       }
   
  -    public Object invoke(ConnectorComponentContext newConnectorComponentContext) throws Throwable {
  +    public Object invoke(InstanceContext newInstanceContext) throws Throwable {
           MockConnection mockConnection = (MockConnection) connectionFactory.getConnection();
           mockManagedConnection = mockConnection.getManagedConnection();
           mockConnection.close();
  
  
  
  1.2       +3 -2      incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptorTest.java
  
  Index: ConnectionTrackingInterceptorTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectionTrackingInterceptorTest.java	23 Jan 2004 05:56:11 -0000	1.1
  +++ ConnectionTrackingInterceptorTest.java	31 Jan 2004 19:27:16 -0000	1.2
  @@ -62,6 +62,7 @@
   import javax.resource.ResourceException;
   
   import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
  +import org.apache.geronimo.transaction.TransactionContext;
   
   /**
    * TODO test unshareable resources.
  @@ -185,7 +186,7 @@
           releasedTrackedConnectionInfo = connectionInfo;
       }
   
  -    public ConnectorTransactionContext getConnectorTransactionContext() {
  +    public TransactionContext getTransactionContext() {
           return null;
       }
   
  
  
  
  1.2       +3 -2      incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/TransactionCachingInterceptorTest.java
  
  Index: TransactionCachingInterceptorTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/TransactionCachingInterceptorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TransactionCachingInterceptorTest.java	23 Jan 2004 05:56:11 -0000	1.1
  +++ TransactionCachingInterceptorTest.java	31 Jan 2004 19:27:16 -0000	1.2
  @@ -63,6 +63,7 @@
   import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
   import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultTransactionContext;
   import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
  +import org.apache.geronimo.transaction.TransactionContext;
   
   /**
    *
  @@ -202,7 +203,7 @@
               ConnectionInfo connectionInfo) {
       }
   
  -    public ConnectorTransactionContext getConnectorTransactionContext() {
  +    public TransactionContext getTransactionContext() {
           return defaultTransactionContext;
       }
   
  
  
  
  1.2       +11 -11    incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorTest.java
  
  Index: ConnectionTrackingCoordinatorTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectionTrackingCoordinatorTest.java	23 Jan 2004 05:56:11 -0000	1.1
  +++ ConnectionTrackingCoordinatorTest.java	31 Jan 2004 19:27:17 -0000	1.2
  @@ -65,13 +65,13 @@
   
   import org.apache.geronimo.connector.outbound.ConnectionInfo;
   import org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor;
  -import org.apache.geronimo.connector.outbound.ConnectorComponentContext;
  -import org.apache.geronimo.connector.outbound.ConnectorTransactionContext;
   import org.apache.geronimo.connector.outbound.ManagedConnectionInfo;
   import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultComponentContext;
   import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultTransactionContext;
   import org.apache.geronimo.security.bridge.RealmBridge;
   import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
  +import org.apache.geronimo.transaction.InstanceContext;
  +import org.apache.geronimo.transaction.TransactionContext;
   
   import junit.framework.TestCase;
   
  @@ -112,7 +112,7 @@
   
       public void testSimpleComponentContextLifecyle() throws Exception {
           DefaultComponentContext componentContext = new DefaultComponentContext();
  -        ConnectorComponentContext oldComponentContext = connectionTrackingCoordinator.enter(componentContext);
  +        InstanceContext oldComponentContext = connectionTrackingCoordinator.enter(componentContext);
           assertNull("Expected old component context to be null", oldComponentContext);
           //give the context a ConnectionInfo
           ManagedConnectionInfo managedConnectionInfo = new ManagedConnectionInfo(null, null);
  @@ -136,7 +136,7 @@
   
       public void testNestedComponentContextLifecyle() throws Exception {
           DefaultComponentContext componentContext1 = new DefaultComponentContext();
  -        ConnectorComponentContext oldComponentContext1 = connectionTrackingCoordinator.enter(componentContext1);
  +        InstanceContext oldComponentContext1 = connectionTrackingCoordinator.enter(componentContext1);
           assertNull("Expected old component context to be null", oldComponentContext1);
           //give the context a ConnectionInfo
           ManagedConnectionInfo managedConnectionInfo1 = new ManagedConnectionInfo(null, null);
  @@ -145,7 +145,7 @@
   
           //Simulate calling another component
           DefaultComponentContext componentContext2 = new DefaultComponentContext();
  -        ConnectorComponentContext oldComponentContext2 = connectionTrackingCoordinator.enter(componentContext2);
  +        InstanceContext oldComponentContext2 = connectionTrackingCoordinator.enter(componentContext2);
           assertTrue("Expected returned component context to be componentContext1", oldComponentContext2 == componentContext1);
           //give the context a ConnectionInfo
           ManagedConnectionInfo managedConnectionInfo2 = new ManagedConnectionInfo(null, null);
  @@ -179,18 +179,18 @@
   
       public void testSimpleTransactionContextLifecycle() throws Exception {
           DefaultComponentContext componentContext = new DefaultComponentContext();
  -        ConnectorComponentContext oldComponentContext = connectionTrackingCoordinator.enter(componentContext);
  +        InstanceContext oldComponentContext = connectionTrackingCoordinator.enter(componentContext);
           transactionManager.begin();
           Transaction transaction = transactionManager.getTransaction();
           DefaultTransactionContext transactionContext = new DefaultTransactionContext(transaction);
  -        ConnectorTransactionContext oldTransactionContext = connectionTrackingCoordinator.setConnectorTransactionContext(transactionContext);
  +        TransactionContext oldTransactionContext = connectionTrackingCoordinator.setTransactionContext(transactionContext);
           assertNull("Expected no old transactionContext", oldTransactionContext);
  -        ConnectorTransactionContext availableTransactionContext = connectionTrackingCoordinator.getConnectorTransactionContext();
  +        TransactionContext availableTransactionContext = connectionTrackingCoordinator.getTransactionContext();
           assertTrue("Expected the same transactionContext as we sent in", transactionContext == availableTransactionContext);
   
  -        ConnectorTransactionContext exitingTransactionContext = connectionTrackingCoordinator.setConnectorTransactionContext(null);
  +        TransactionContext exitingTransactionContext = connectionTrackingCoordinator.setTransactionContext(null);
           assertTrue("Expected the same transactionContext as we sent in", transactionContext == exitingTransactionContext);
  -        ConnectorTransactionContext availableTransactionContext2 = connectionTrackingCoordinator.getConnectorTransactionContext();
  +        TransactionContext availableTransactionContext2 = connectionTrackingCoordinator.getTransactionContext();
           assertNull("Expected no transactionContext", availableTransactionContext2);
       }
   
  
  
  
  1.10      +9 -1      incubator-geronimo/modules/jetty/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jetty/project.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- project.xml	28 Jan 2004 23:02:07 -0000	1.9
  +++ project.xml	31 Jan 2004 19:27:17 -0000	1.10
  @@ -59,6 +59,14 @@
   
           <dependency>
               <groupId>geronimo</groupId>
  +            <artifactId>geronimo-transaction</artifactId>
  +            <version>DEV</version>
  +            <properties>
  +            </properties>
  +        </dependency>
  +
  +        <dependency>
  +            <groupId>geronimo</groupId>
               <artifactId>geronimo-connector</artifactId>
               <version>DEV</version>
               <properties>
  
  
  
  1.7       +11 -11    incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebApplicationContext.java
  
  Index: JettyWebApplicationContext.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/JettyWebApplicationContext.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JettyWebApplicationContext.java	26 Jan 2004 05:55:26 -0000	1.6
  +++ JettyWebApplicationContext.java	31 Jan 2004 19:27:17 -0000	1.7
  @@ -70,8 +70,6 @@
   import javax.transaction.Transaction;
   import javax.transaction.TransactionManager;
   
  -import org.apache.geronimo.connector.outbound.ConnectorComponentContext;
  -import org.apache.geronimo.connector.outbound.ConnectorTransactionContext;
   import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
   import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultComponentContext;
   import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultTransactionContext;
  @@ -86,6 +84,8 @@
   import org.apache.geronimo.kernel.config.ConfigurationParent;
   import org.apache.geronimo.naming.java.ReadOnlyContext;
   import org.apache.geronimo.naming.java.RootContext;
  +import org.apache.geronimo.transaction.TransactionContext;
  +import org.apache.geronimo.transaction.InstanceContext;
   import org.mortbay.http.HttpException;
   import org.mortbay.http.HttpRequest;
   import org.mortbay.http.HttpResponse;
  @@ -141,8 +141,8 @@
           ReadOnlyContext oldComponentContext = RootContext.getComponentContext();
           String oldPolicyContextID = PolicyContext.getContextID();
           Set oldUnshareableResources = null;
  -        ConnectorComponentContext oldConnectorComponentContext = null;
  -        ConnectorTransactionContext oldConnectorTransactionContext = null;
  +        InstanceContext oldInstanceContext = null;
  +        TransactionContext oldTransactionContext = null;
   
           try {
               // set up java:comp JNDI Context
  @@ -153,7 +153,7 @@
   
               // set up Transaction Context
               if (txManager != null) {
  -                ConnectorTransactionContext newTxContext;
  +                TransactionContext newTxContext;
   
                   // @todo this will not clean up properly if an exception occurs - we need to fix this API
                   try {
  @@ -161,15 +161,15 @@
                       if (tx == null) {
                           newTxContext = new DefaultTransactionContext(null);
                       } else {
  -                        newTxContext = (ConnectorTransactionContext) transactionContextMap.get(tx);
  +                        newTxContext = (TransactionContext) transactionContextMap.get(tx);
                           if (newTxContext == null) {
                               newTxContext = new DefaultTransactionContext(tx);
                               transactionContextMap.put(tx, newTxContext);
                           }
                       }
                       oldUnshareableResources = associator.setUnshareableResources(unshareableResources);
  -                    oldConnectorComponentContext = associator.enter(new DefaultComponentContext());
  -                    oldConnectorTransactionContext = associator.setConnectorTransactionContext(newTxContext);
  +                    oldInstanceContext = associator.enter(new DefaultComponentContext());
  +                    oldTransactionContext = associator.setTransactionContext(newTxContext);
                   } catch (SystemException e) {
                       throw new RuntimeException(e);
                   } catch (RollbackException e) {
  @@ -183,8 +183,8 @@
           } finally {
               try {
                   if (txManager != null) {
  -                    associator.exit(oldConnectorComponentContext, unshareableResources);
  -                    associator.resetConnectorTransactionContext(oldConnectorTransactionContext);
  +                    associator.exit(oldInstanceContext, unshareableResources);
  +                    associator.resetTransactionContext(oldTransactionContext);
                       associator.setUnshareableResources(oldUnshareableResources);
                   }
               } catch (ResourceException e) {
  
  
  
  1.1                  incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/BeanTransactionContext.java
  
  Index: BeanTransactionContext.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.transaction;
  
  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 org.apache.geronimo.transaction.UnspecifiedTransactionContext;
  import org.apache.geronimo.transaction.InheritableTransactionContext;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/31 19:27:17 $
   */
  public class BeanTransactionContext extends InheritableTransactionContext {
      private final TransactionManager txnManager;
      private final UnspecifiedTransactionContext oldContext;
      private Transaction transaction;
  
  
      public BeanTransactionContext(TransactionManager txnManager, UnspecifiedTransactionContext oldContext) {
          this.txnManager = txnManager;
          this.oldContext = oldContext;
      }
  
      public UnspecifiedTransactionContext getOldContext() {
          return oldContext;
      }
  
      public void begin() throws SystemException, NotSupportedException {
          txnManager.begin();
          transaction = txnManager.getTransaction();
      }
  
      public void suspend() throws SystemException {
          Transaction suspendedTransaction = txnManager.suspend();
          assert (transaction == suspendedTransaction) : "suspend did not return our transaction";
      }
  
      public void resume() throws SystemException, InvalidTransactionException {
          txnManager.resume(transaction);
      }
  
      public void commit() throws HeuristicMixedException, HeuristicRollbackException, RollbackException, SystemException {
          try {
              try {
                  flushState();
              } catch (Throwable t) {
                  try {
                      txnManager.rollback();
                  } catch (Throwable t1) {
                      log.error("Unable to roll back transaction", t1);
                  }
                  throw (RollbackException) new RollbackException("Could not flush state before commit").initCause(t);
              }
              txnManager.commit();
          } finally {
              connectorAfterCommit();
              transaction = null;
          }
      }
  
      public void rollback() throws SystemException {
          try {
              txnManager.rollback();
          } finally {
              connectorAfterCommit();
              transaction = null;
          }
      }
  
      //Geronimo connector framework support
  
      public boolean isActive() {
          try {
              return txnManager.getStatus() == Status.STATUS_ACTIVE;
          } catch (SystemException e) {
              return false;
          }
      }
  
      public Transaction getTransaction() {
          return transaction;
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/ConnectionReleaser.java
  
  Index: ConnectionReleaser.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.transaction;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/31 19:27:17 $
   *
   * */
  public interface ConnectionReleaser {
      void afterCompletion(Object managedConnectionInfo);
  }
  
  
  
  1.1                  incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/ContainerTransactionContext.java
  
  Index: ContainerTransactionContext.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.transaction;
  
  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 org.apache.geronimo.transaction.InheritableTransactionContext;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/31 19:27:17 $
   */
  public class ContainerTransactionContext extends InheritableTransactionContext {
      private final TransactionManager txnManager;
      private Transaction transaction;
  
      public ContainerTransactionContext(TransactionManager txnManager) {
          this.txnManager = txnManager;
      }
  
      public void begin() throws SystemException, NotSupportedException {
          txnManager.begin();
          transaction = txnManager.getTransaction();
      }
  
      public void suspend() throws SystemException {
          Transaction suspendedTransaction = txnManager.suspend();
          assert (transaction == suspendedTransaction) : "suspend did not return our transaction";
      }
  
      public void resume() throws SystemException, InvalidTransactionException {
          txnManager.resume(transaction);
      }
  
      /**
       * TODO the exceptions thrown here are not all correct.  Don't throw a RollbackException after
       * a successful commit...??
       *
       * @throws javax.transaction.HeuristicMixedException
       * @throws javax.transaction.HeuristicRollbackException
       * @throws javax.transaction.RollbackException
       * @throws javax.transaction.SystemException
       */
      public void commit() throws HeuristicMixedException, HeuristicRollbackException, RollbackException, SystemException {
          try {
              try {
                  flushState();
              } catch (Throwable t) {
                  try {
                      txnManager.rollback();
                  } catch (Throwable t1) {
                      log.error("Unable to roll back transaction", t1);
                  }
                  throw (RollbackException) new RollbackException("Could not flush state before commit").initCause(t);
              }
              try {
                  beforeCommit();
              } catch (Exception e) {
                  try {
                      txnManager.rollback();
                  } catch (Throwable t1) {
                      log.error("Unable to roll back transaction", t1);
                  }
                  throw (RollbackException) new RollbackException("Could not flush state before commit").initCause(e);
              }
              txnManager.commit();
              try {
                  afterCommit(true);
              } catch (Exception e) {
                  try {
                      txnManager.rollback();
                  } catch (Throwable t1) {
                      log.error("Unable to roll back transaction", t1);
                  }
                  throw (RollbackException) new RollbackException("Could not flush state before commit").initCause(e);
              }
          } finally {
              connectorAfterCommit();
              transaction = null;
          }
      }
  
      public void rollback() throws SystemException {
          try {
              txnManager.rollback();
          } finally {
              connectorAfterCommit();
              transaction = null;
          }
      }
  
      //Geronimo connector framework support
      public boolean isActive() {
          try {
              return txnManager.getStatus() == Status.STATUS_ACTIVE;
          } catch (SystemException e) {
              return false;
          }
      }
  
      public Transaction getTransaction() {
          return transaction;
      }
  
      public void setRollbackOnly() throws IllegalStateException, SystemException {
          if (transaction == null) {
              throw new IllegalStateException("There is no transaction in progress.");
          }
          transaction.setRollbackOnly();
      }
  
      public boolean getRollbackOnly() throws SystemException {
          if (transaction == null) {
              throw new IllegalStateException("There is no transaction in progress.");
          }
  
          int status = transaction.getStatus();
          return (status == Status.STATUS_MARKED_ROLLBACK ||
                  status == Status.STATUS_ROLLEDBACK ||
                  status == Status.STATUS_ROLLING_BACK );
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/DoubleKeyedHashMap.java
  
  Index: DoubleKeyedHashMap.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.transaction;
  
  import java.util.Map;
  import java.util.HashMap;
  import java.util.Collection;
  
  /**
   * <b>Really</b> stupid implementation of a double keyed map.
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/31 19:27:17 $
   */
  public final class DoubleKeyedHashMap {
      private final Map map = new HashMap();
  
      public Object put(Object key1, Object key2, Object value) {
          return map.put(new Key(key1, key2), value);
      }
  
      public Object get(Object key1, Object key2) {
          return map.get(new Key(key1, key2));
      }
  
      public Object remove(Object key1, Object key2) {
          return map.remove(new Key(key1, key2));
      }
  
      public Collection values() {
          return map.values();
      }
  
      public void clear() {
          map.clear();
      }
  
      public boolean isEmpty() {
          return map.isEmpty();
      }
  
      private final static class Key {
          private final Object part1;
          private final Object part2;
  
          public Key(Object part1, Object part2) {
              this.part1 = part1;
              this.part2 = part2;
          }
  
          public int hashCode() {
              return part1.hashCode() ^ part2.hashCode();
          }
  
          public boolean equals(Object obj) {
              if (obj instanceof Key) {
                  Key other = (Key) obj;
                  return this.part1.equals(other.part1) && this.part2.equals(other.part2);
              } else {
                  return false;
              }
          }
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/InheritableTransactionContext.java
  
  Index: InheritableTransactionContext.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.transaction;
  
  import org.apache.geronimo.transaction.TransactionContext;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/31 19:27:17 $
   */
  public abstract class InheritableTransactionContext extends TransactionContext {
  }
  
  
  
  1.1                  incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/InstanceContext.java
  
  Index: InstanceContext.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.transaction;
  
  import java.util.Map;
  
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/31 19:27:17 $
   *
   * */
  public interface InstanceContext {
      Object getId();
  
      void setId(Object id);
  
      Object getContainer();
  
      void associate() throws Exception;
  
      void flush() throws Exception;
  
      void beforeCommit() throws Exception;
  
      void afterCommit(boolean status) throws Exception;
  
      /**
       * IMPORTANT INVARIANT: this should always return a map, never null.
       * @return map of ConnectionManager to (list of ) managed connection info objects.
       */
      public Map getConnectionManagerMap();
  
  }
  
  
  
  1.1                  incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/TransactionContext.java
  
  Index: TransactionContext.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.transaction;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Iterator;
  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.SystemException;
  import javax.transaction.Transaction;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/31 19:27:17 $
   */
  public abstract class TransactionContext {
      protected static final Log log = LogFactory.getLog(TransactionContext.class);
      private static ThreadLocal CONTEXT = new ThreadLocal();
      private Map managedConnections;
  
      public static TransactionContext getContext() {
          return (TransactionContext) CONTEXT.get();
      }
  
      public static void setContext(TransactionContext context) {
          CONTEXT.set(context);
      }
  
      private InstanceContext currentContext;
      private final org.apache.geronimo.transaction.DoubleKeyedHashMap associatedContexts = new org.apache.geronimo.transaction.DoubleKeyedHashMap();
      private final org.apache.geronimo.transaction.DoubleKeyedHashMap dirtyContexts = new org.apache.geronimo.transaction.DoubleKeyedHashMap();
      private final org.apache.geronimo.transaction.DoubleKeyedHashMap instanceDataCache = new org.apache.geronimo.transaction.DoubleKeyedHashMap();
  
      public abstract void begin() throws SystemException, NotSupportedException;
  
      public abstract void suspend() throws SystemException;
  
      public abstract void resume() throws SystemException, InvalidTransactionException;
  
      public abstract void commit() throws HeuristicMixedException, HeuristicRollbackException, RollbackException, SystemException;
  
      public abstract void rollback() throws SystemException;
  
      public final void associate(InstanceContext context) throws Exception {
          if (associatedContexts.put(context.getContainer(), context.getId(), context) == null) {
              context.associate();
          }
      }
  
      public final InstanceContext beginInvocation(InstanceContext context) {
          if (context.getId() != null) {
              dirtyContexts.put(context.getContainer(), context.getId(), context);
          }
          InstanceContext caller = currentContext;
          currentContext = context;
          return caller;
      }
  
      public final void endInvocation(InstanceContext caller) {
          currentContext = caller;
      }
  
      public final void flushState() throws Exception {
          while (dirtyContexts.isEmpty() == false) {
              ArrayList toFlush = new ArrayList(dirtyContexts.values());
              dirtyContexts.clear();
              for (Iterator i = toFlush.iterator(); i.hasNext();) {
                  InstanceContext context = (InstanceContext) i.next();
                  context.flush();
              }
          }
          if (currentContext != null && currentContext.getId() != null) {
              dirtyContexts.put(currentContext.getContainer(), currentContext.getId(), currentContext);
          }
      }
  
      protected void beforeCommit() throws Exception {
          // @todo allow for enrollment during pre-commit
          ArrayList toFlush = new ArrayList(associatedContexts.values());
          for (Iterator i = toFlush.iterator(); i.hasNext();) {
              InstanceContext context = (InstanceContext) i.next();
              context.beforeCommit();
          }
      }
  
      protected void afterCommit(boolean status) throws Exception {
          // @todo allow for enrollment during pre-commit
          ArrayList toFlush = new ArrayList(associatedContexts.values());
          for (Iterator i = toFlush.iterator(); i.hasNext();) {
              InstanceContext context = (InstanceContext) i.next();
              context.afterCommit(status);
          }
      }
  
      public final InstanceContext getContext(Object container, Object id) {
          return (InstanceContext) associatedContexts.get(container, id);
      }
  
      public final void putInstanceData(Object container, Object id, Object data) {
          instanceDataCache.put(container, id, data);
      }
  
      public final Object getInstancedata(Object container, Object id) {
          return instanceDataCache.get(container, id);
      }
  
      //Geronimo connector framework support
      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 abstract boolean isActive();
  
      public abstract Transaction getTransaction();
  
      protected void connectorAfterCommit() {
          if (managedConnections != null) {
              for (Iterator entries = managedConnections.entrySet().iterator(); entries.hasNext();) {
                  Map.Entry entry = (Map.Entry) entries.next();
                  ConnectionReleaser key = (ConnectionReleaser) entry.getKey();
                  key.afterCompletion(entry.getValue());
              }
              //If BeanTransactionContext never reuses the same instance for sequential BMT, this
              //clearing is unnecessary.
              managedConnections.clear();
          }
      }
  
  }
  
  
  
  1.1                  incubator-geronimo/modules/transaction/src/java/org/apache/geronimo/transaction/UnspecifiedTransactionContext.java
  
  Index: UnspecifiedTransactionContext.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.transaction;
  
  import javax.transaction.Transaction;
  
  import org.apache.geronimo.transaction.ConnectionReleaser;
  import org.apache.geronimo.transaction.TransactionContext;
  
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/31 19:27:17 $
   */
  public class UnspecifiedTransactionContext extends TransactionContext {
      public void begin() {
      }
  
      public void suspend() {
      }
  
      public void resume() {
      }
  
      public void commit() {
          try {
              flushState();
          } catch (Exception e) {
              log.error("Unable to flush state, continuing", e);
          }
      }
  
      public void rollback() {
      }
  
      //Geronimo connector framework support
      public void setManagedConnectionInfo(ConnectionReleaser key, Object info) {
      }
  
      public Object getManagedConnectionInfo(ConnectionReleaser key) {
          return null;
      }
  
      public boolean isActive() {
          return false;
      }
  
      public Transaction getTransaction() {
          return null;
      }
  }
  
  
  

Mime
View raw message