You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2003/12/14 00:33:54 UTC

cvs commit: incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound ConnectionManagerTestUtils.java ConnectionTrackingInterceptorTest.java TransactionEnlistingInterceptorTest.java

djencks     2003/12/13 15:33:54

  Modified:    modules/core/src/java/org/apache/geronimo/connector/outbound
                        ConnectionHandleInterceptor.java
                        ConnectionManagerDeployment.java
                        ConnectionTrackingInterceptor.java
                        ConnectorTransactionContext.java
                        GeronimoConnectionEventListener.java
                        ManagedConnectionInfo.java
                        ProxyConnectionManager.java
                        TransactionEnlistingInterceptor.java
               modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl
                        DefaultTransactionContext.java
               modules/core/src/test/org/apache/geronimo/connector/outbound
                        ConnectionManagerTestUtils.java
                        ConnectionTrackingInterceptorTest.java
                        TransactionEnlistingInterceptorTest.java
  Removed:     modules/core/src/java/org/apache/geronimo/connector/outbound
                        ConnectionManagerDeployment.xml
  Log:
  Convert completely to using TransactionContext rather than TransactionManager, and clean up a bit
  
  Revision  Changes    Path
  1.4       +17 -7     incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ConnectionHandleInterceptor.java
  
  Index: ConnectionHandleInterceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ConnectionHandleInterceptor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ConnectionHandleInterceptor.java	9 Dec 2003 04:16:25 -0000	1.3
  +++ ConnectionHandleInterceptor.java	13 Dec 2003 23:33:53 -0000	1.4
  @@ -72,6 +72,12 @@
           this.next = next;
       }
   
  +    /**
  +     * in: connectionInfo not null, managedConnectionInfo not null. ManagedConnection may or may not be null.  ConnectionHandle may or may not be null
  +     * out: managedConnection not null. connection handle not null. managedConnectionInfo has connection handle registered.  Connection handle is associated with ManagedConnection.
  +     * @param connectionInfo
  +     * @throws ResourceException
  +     */
       public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
           next.getConnection(connectionInfo);
           ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
  @@ -81,19 +87,23 @@
                               mci.getSubject(),
                               mci.getConnectionRequestInfo()));
   
  -        } else {
  +        } else if (!mci.hasConnectionInfo(connectionInfo)) {
               mci.getManagedConnection().associateConnection(
                       connectionInfo.getConnectionHandle());
           }
  -        mci.addConnectionHandle(connectionInfo.getConnectionHandle());
  +        mci.addConnectionHandle(connectionInfo);
       }
   
  -    public void returnConnection(
  -            ConnectionInfo connectionInfo,
  -            ConnectionReturnAction connectionReturnAction) {
  +    /**
  +     *  in: connectionInfo not null, managedConnectionInfo not null, managedConnection not null.  Handle can be null if mc is being destroyed from pool.
  +     * out: managedCOnnectionInfo null, handle not in mci.handles.
  +     * @param connectionInfo
  +     * @param connectionReturnAction
  +     */
  +    public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) {
           if (connectionInfo.getConnectionHandle() != null) {
               connectionInfo.getManagedConnectionInfo().removeConnectionHandle(
  -                    connectionInfo.getConnectionHandle());
  +                    connectionInfo);
           }
           next.returnConnection(connectionInfo, connectionReturnAction);
       }
  
  
  
  1.5       +68 -123   incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ConnectionManagerDeployment.java
  
  Index: ConnectionManagerDeployment.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ConnectionManagerDeployment.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ConnectionManagerDeployment.java	10 Dec 2003 07:48:12 -0000	1.4
  +++ ConnectionManagerDeployment.java	13 Dec 2003 23:33:53 -0000	1.5
  @@ -57,14 +57,20 @@
   package org.apache.geronimo.connector.outbound;
   
   import javax.management.ObjectName;
  +import javax.management.MBeanOperationInfo;
   import javax.resource.ResourceException;
   import javax.resource.spi.ManagedConnectionFactory;
  -import javax.transaction.TransactionManager;
   
   import org.apache.geronimo.connector.deployment.ConnectionManagerFactory;
   import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
   import org.apache.geronimo.kernel.jmx.JMXUtil;
  +import org.apache.geronimo.kernel.service.GeronimoAttributeInfo;
  +import org.apache.geronimo.kernel.service.GeronimoOperationInfo;
  +import org.apache.geronimo.kernel.service.GeronimoParameterInfo;
  +
   import org.apache.geronimo.kernel.service.GeronimoMBeanContext;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanEndpoint;
  +import org.apache.geronimo.kernel.service.GeronimoMBeanInfo;
   import org.apache.geronimo.kernel.service.GeronimoMBeanTarget;
   
   /**
  @@ -105,11 +111,6 @@
       private SecurityDomain securityDomain;
   
       /**
  -     * The actual TransactionManager we get
  -     */
  -    private TransactionManager transactionManager;
  -
  -    /**
        * Identifying string used by unshareable resource detection
        */
       private String jndiName;
  @@ -130,12 +131,20 @@
           return true;
       }
   
  -    /* (non-Javadoc)
  -         * @see org.apache.geronimo.core.service.AbstractStateManageable#doStart()
  -         */
  +    /**
  +     * Order of constructed interceptors:
  +     *
  +     * ConnectionTrackingInterceptor (connectionTracker != null)
  +     * ConnectionHandleInterceptor
  +     * TransactionCachingInterceptor (useTransactions & useTransactionCaching)
  +     * TransactionEnlistingInterceptor (useTransactions)
  +     * SubjectInterceptor (securityDomain != null)
  +     * SinglePoolConnectionInterceptor or MultiPoolConnectionInterceptor
  +     * LocalXAResourceInsertionInterceptor or XAResourceInsertionInterceptor (useTransactions (&localTransactions))
  +     * MCFConnectionInterceptor
  +     */
       public void doStart() {
           //check for consistency between attributes
  -        useTransactions = (transactionManager != null);
           if (securityDomain == null) {
               assert useSubject == false: "To use Subject in pooling, you need a SecurityDomain";
           }
  @@ -151,24 +160,24 @@
           }
           if (useSubject || useConnectionRequestInfo) {
               stack = new MultiPoolConnectionInterceptor(
  -                            stack,
  -                            maxSize,
  -                            blockingTimeout,
  -                            useSubject,
  -                            useConnectionRequestInfo);
  +                    stack,
  +                    maxSize,
  +                    blockingTimeout,
  +                    useSubject,
  +                    useConnectionRequestInfo);
           } else {
               stack = new SinglePoolConnectionInterceptor(
  -                            stack,
  -                            null,
  -                            null,
  -                            maxSize,
  -                            blockingTimeout);
  +                    stack,
  +                    null,
  +                    null,
  +                    maxSize,
  +                    blockingTimeout);
           }
           if (securityDomain != null) {
               stack = new SubjectInterceptor(stack, securityDomain);
           }
           if (useTransactions) {
  -            stack = new TransactionEnlistingInterceptor(stack, transactionManager);
  +            stack = new TransactionEnlistingInterceptor(stack);
               if (useTransactionCaching) {
                   stack = new TransactionCachingInterceptor(stack, connectionTracker);
               }
  @@ -176,10 +185,10 @@
           stack = new ConnectionHandleInterceptor(stack);
           if (connectionTracker != null) {
               stack = new ConnectionTrackingInterceptor(
  -                            stack,
  -                            jndiName,
  -                            connectionTracker,
  -                            securityDomain);
  +                    stack,
  +                    jndiName,
  +                    connectionTracker,
  +                    securityDomain);
           }
   
           ObjectName name = JMXUtil.getObjectName(MBEAN_SERVER_DELEGATE);
  @@ -202,7 +211,6 @@
       public void doStop() {
           cm = null;
           securityDomain = null;
  -        transactionManager = null;
           connectionTracker = null;
   
       }
  @@ -210,182 +218,119 @@
       public void doFail() {
       }
   
  -    /**
  -     * @return
  -     * @jmx.managed-attribute
  -     */
       public ConnectionInterceptor getStack() {
           return cm.getStack();
       }
   
   
  -    /**
  -     * @return
  -     * @jmx.managed-operation
  -     */
       public Object createConnectionFactory(ManagedConnectionFactory mcf) throws ResourceException {
           return mcf.createConnectionFactory(cm);
       }
   
  -    /**
  -     * @return
  -     * @jmx.managed-attribute
  -     */
       public int getBlockingTimeout() {
           return blockingTimeout;
       }
   
  -    /**
  -     * @param blockingTimeout
  -     * @jmx.managed-attribute
  -     */
       public void setBlockingTimeout(int blockingTimeout) {
           this.blockingTimeout = blockingTimeout;
       }
   
  -    /**
  -     * @return
  -     * @jmx.managed-attribute
  -     */
       public ConnectionTracker getConnectionTracker() {
           return connectionTracker;
       }
   
  -    /**
  -     * @param connectionTracker
  -     * @jmx.managed-attribute
  -     */
       public void setConnectionTracker(ConnectionTracker connectionTracker) {
           this.connectionTracker = connectionTracker;
       }
   
  -    /**
  -     * @return
  -     * @jmx.managed-attribute
  -     */
       public String getJndiName() {
           return jndiName;
       }
   
  -    /**
  -     * @param jndiName
  -     * @jmx.managed-attribute
  -     */
       public void setJndiName(String jndiName) {
           this.jndiName = jndiName;
       }
   
  -    /**
  -     * @return
  -     * @jmx.managed-attribute
  -     */
       public int getMaxSize() {
           return maxSize;
       }
   
  -    /**
  -     * @param maxSize
  -     * @jmx.managed-attribute
  -     */
       public void setMaxSize(int maxSize) {
           this.maxSize = maxSize;
       }
   
  -    /**
  -     * @return
  -     * @jmx.managed-attribute
  -     */
       public SecurityDomain getSecurityDomain() {
           return securityDomain;
       }
   
  -    /**
  -     * @param securityDomain
  -     * @jmx.managed-attribute
  -     */
       public void setSecurityDomain(SecurityDomain securityDomain) {
           this.securityDomain = securityDomain;
       }
   
  -    /**
  -     * @return
  -     * @jmx.managed-attribute
  -     */
  -    public TransactionManager getTransactionManager() {
  -        return transactionManager;
  -    }
  -
  -    /**
  -     * @param transactionManager
  -     * @jmx.managed-attribute
  -     */
  -    public void setTransactionManager(TransactionManager transactionManager) {
  -        this.transactionManager = transactionManager;
  -    }
  -
  -    /**
  -     * @return
  -     * @jmx.managed-attribute
  -     */
       public boolean isUseConnectionRequestInfo() {
           return useConnectionRequestInfo;
       }
   
  -    /**
  -     * @param useConnectionRequestInfo
  -     * @jmx.managed-attribute
  -     */
       public void setUseConnectionRequestInfo(boolean useConnectionRequestInfo) {
           this.useConnectionRequestInfo = useConnectionRequestInfo;
       }
   
  -    /**
  -     * @return
  -     * @jmx.managed-attribute
  -     */
  +    //TODO determine this from [geronimo-]ra.xml transaction attribute.
  +    public boolean isUseTransactions() {
  +        return useTransactions;
  +    }
  +
  +    public void setUseTransactions(boolean useTransactions) {
  +        this.useTransactions = useTransactions;
  +    }
  +
       public boolean isUseLocalTransactions() {
           return useLocalTransactions;
       }
   
  -    /**
  -     * @param useLocalTransactions
  -     * @jmx.managed-attribute
  -     */
       public void setUseLocalTransactions(boolean useLocalTransactions) {
           this.useLocalTransactions = useLocalTransactions;
       }
   
  -    /**
  -     * @return
  -     * @jmx.managed-attribute
  -     */
       public boolean isUseSubject() {
           return useSubject;
       }
   
  -    /**
  -     * @param useSubject
  -     * @jmx.managed-attribute
  -     */
       public void setUseSubject(boolean useSubject) {
           this.useSubject = useSubject;
       }
   
  -    /**
  -     * @return
  -     * @jmx.managed-attribute
  -     */
       public boolean isUseTransactionCaching() {
           return useTransactionCaching;
       }
   
  -    /**
  -     * @param useTransactionCaching
  -     * @jmx.managed-attribute
  -     */
       public void setUseTransactionCaching(boolean useTransactionCaching) {
           this.useTransactionCaching = useTransactionCaching;
       }
   
  +    public static GeronimoMBeanInfo getGeronimoMBeanInfo() throws Exception {
  +        GeronimoMBeanInfo mBeanInfo = new GeronimoMBeanInfo();
  +
  +        mBeanInfo.setTargetClass(ConnectionManagerDeployment.class);
  +        mBeanInfo.addEndpoint(new GeronimoMBeanEndpoint("ConnectionTracker", ConnectionTracker.class, ObjectName.getInstance("geronimo.connector:role=ConnectionTrackingCoordinator"), true));
  +        mBeanInfo.addEndpoint(new GeronimoMBeanEndpoint("SecurityDomain", SecurityDomain.class, ObjectName.getInstance("geronimo.connector:role=SecurityDomain"), false));
  +
  +        mBeanInfo.addAttributeInfo(new GeronimoAttributeInfo("BlockingTimeout", true, true, "Milliseconds to wait for a connection to be returned"));
  +        mBeanInfo.addAttributeInfo(new GeronimoAttributeInfo("JndiName", true, true, "Name to use to identify this guy (needs refactoring of naming conventions)"));
  +        mBeanInfo.addAttributeInfo(new GeronimoAttributeInfo("MaxSize", true, true, "Maximum number of ManagedConnections to create in each pool"));
  +        mBeanInfo.addAttributeInfo(new GeronimoAttributeInfo("UseConnectionRequestInfo", true, true, "Select pool using app-supplied ConnectionRequestInfo"));
  +        mBeanInfo.addAttributeInfo(new GeronimoAttributeInfo("UseTransactions", true, true, "Use local or xa transactions vs. no transactions"));
  +        mBeanInfo.addAttributeInfo(new GeronimoAttributeInfo("UseLocalTransactions", true, true, "Use local rather than xa transactions"));
  +        mBeanInfo.addAttributeInfo(new GeronimoAttributeInfo("UseTransactionCaching", true, true, "Always use the same connection in a transaction"));
  +        mBeanInfo.addAttributeInfo(new GeronimoAttributeInfo("UseSubject", true, true, "Select pool using SecurityDomain supplied subject"));
  +
  +        mBeanInfo.addOperationInfo(new GeronimoOperationInfo("getStack"));
  +
  +        mBeanInfo.addOperationInfo(new GeronimoOperationInfo("createConnectionFactory",
  +                new GeronimoParameterInfo[] {new GeronimoParameterInfo("ManagedConnectionFactory", ManagedConnectionFactory.class, "ManagedConnectionFactory that will create the ConnectionFactory")},
  +                MBeanOperationInfo.ACTION,
  +                "PRIVATE OPERATION. Have the supplied ManagedConnectionFactory create a connection factory"));
  +        return mBeanInfo;
  +    }
   
   }
  
  
  
  1.3       +23 -27    incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java
  
  Index: ConnectionTrackingInterceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/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	10 Dec 2003 07:48:12 -0000	1.2
  +++ ConnectionTrackingInterceptor.java	13 Dec 2003 23:33:53 -0000	1.3
  @@ -68,7 +68,7 @@
   import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
   
   /**
  - * MetaCallConnectionInterceptor.java handles communication with the
  + * ConnectionTrackingInterceptor.java handles communication with the
    * CachedConnectionManager.  On method call entry, cached handles are
    * checked for the correct Subject.  On method call exit, cached
    * handles are disassociated if possible. On getting or releasing
  @@ -95,11 +95,30 @@
           this.securityDomain = securityDomain;
       }
   
  +    /**
  +     * called by: ProxyConnectionManager.allocateConnection, ProxyConnectionManager.associateConnection, and enter.
  +     * in: connectionInfo is non-null, and has non-null ManagedConnectionInfo with non-null managedConnectionfactory.
  +     * connection handle may or may not be null.
  +     * out: connectionInfo has non-null connection handle, non null ManagedConnectionInfo with non-null ManagedConnection and GeronimoConnectionEventListener.
  +     * connection tracker has been notified of handle-managed connection association.
  +     * @param connectionInfo
  +     * @throws ResourceException
  +     */
       public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
  +        ManagedConnectionInfo managedConnectionInfo = connectionInfo.getManagedConnectionInfo();
  +        managedConnectionInfo.setTransactionContext(connectionTracker.getConnectorTransactionContext());
           next.getConnection(connectionInfo);
           connectionTracker.handleObtained(this, connectionInfo);
       }
   
  +    /**
  +     * called by: GeronimoConnectionEventListener.connectionClosed, GeronimoConnectionEventListener.connectionErrorOccurred, exit
  +     * in: handle has already been dissociated from ManagedConnection. connectionInfo not null, has non-null ManagedConnectionInfo, ManagedConnectionInfo has non-null ManagedConnection
  +     * handle can be null if called from error in ManagedConnection in pool.
  +     * out: connectionTracker has been notified, ManagedConnectionInfo null.
  +     * @param connectionInfo
  +     * @param connectionReturnAction
  +     */
       public void returnConnection(
               ConnectionInfo connectionInfo,
               ConnectionReturnAction connectionReturnAction) {
  @@ -132,30 +151,6 @@
           for (Iterator i = connectionInfos.iterator(); i.hasNext();) {
               ConnectionInfo connectionInfo = (ConnectionInfo) i.next();
               getConnection(connectionInfo);
  -            /*
  -            ManagedConnectionInfo originalManagedConnectionInfo = connectionInfo.getManagedConnectionInfo();
  -            //Is this check correct?  perhaps more credentials got
  -            //added without changing the relevant credential we use.
  -            if (!currentSubject.equals(originalManagedConnectionInfo.getSubject())) {
  -                //make a ConnectionInfo to process removing the handle from the old mc
  -                ConnectionInfo returningConnectionInfo = new ConnectionInfo();
  -                returningConnectionInfo.setManagedConnectionInfo(originalManagedConnectionInfo);
  -                //This should decrement handle count, but not close the handle, when returnConnection is called
  -                //I'm not sure how to test/assure this.
  -                returningConnectionInfo.setConnectionHandle(connectionInfo.getConnectionHandle());
  -
  -                //make a new originalManagedConnectionInfo for the mc we will ask for
  -                ManagedConnectionInfo newManagedConnectionInfo =
  -                        new ManagedConnectionInfo(
  -                                originalManagedConnectionInfo.getManagedConnectionFactory(),
  -                                originalManagedConnectionInfo.getConnectionRequestInfo());
  -                newManagedConnectionInfo.setSubject(currentSubject);
  -                connectionInfo.setManagedConnectionInfo(newManagedConnectionInfo);
  -                next.getConnection(connectionInfo);
  -                //process the removal of the handle from the previous mc
  -                returnConnection(returningConnectionInfo, ConnectionReturnAction.RETURN_HANDLE);
  -            }
  -            */
           }
   
       }
  @@ -169,7 +164,8 @@
               ConnectionInfo connectionInfo = (ConnectionInfo) i.next();
               ManagedConnectionInfo managedConnectionInfo = connectionInfo.getManagedConnectionInfo();
               ManagedConnection managedConnection = managedConnectionInfo.getManagedConnection();
  -            if (managedConnection instanceof DissociatableManagedConnection) {
  +            if (managedConnection instanceof DissociatableManagedConnection
  +            && managedConnectionInfo.isFirstConnectionInfo(connectionInfo)) {
                   i.remove();
                   ((DissociatableManagedConnection) managedConnection).dissociateConnections();
                   managedConnectionInfo.clearConnectionHandles();
  
  
  
  1.2       +4 -1      incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ConnectorTransactionContext.java
  
  Index: ConnectorTransactionContext.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ConnectorTransactionContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectorTransactionContext.java	9 Dec 2003 04:15:20 -0000	1.1
  +++ ConnectorTransactionContext.java	13 Dec 2003 23:33:53 -0000	1.2
  @@ -1,5 +1,6 @@
   package org.apache.geronimo.connector.outbound;
   
  +import javax.transaction.Transaction;
   
   
   /**
  @@ -22,5 +23,7 @@
       ManagedConnectionInfo getManagedConnectionInfo(ConnectionReleaser key);
   
       boolean isActive();
  +
  +    Transaction getTransaction();
   
   }
  
  
  
  1.5       +30 -21    incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/GeronimoConnectionEventListener.java
  
  Index: GeronimoConnectionEventListener.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/GeronimoConnectionEventListener.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- GeronimoConnectionEventListener.java	9 Dec 2003 04:16:25 -0000	1.4
  +++ GeronimoConnectionEventListener.java	13 Dec 2003 23:33:53 -0000	1.5
  @@ -56,12 +56,11 @@
   
   package org.apache.geronimo.connector.outbound;
   
  -import java.util.HashSet;
  -import java.util.Set;
  +import java.util.ArrayList;
  +import java.util.List;
   
   import javax.resource.spi.ConnectionEvent;
   import javax.resource.spi.ConnectionEventListener;
  -import javax.transaction.Synchronization;
   
   import org.apache.commons.logging.LogFactory;
   import org.apache.commons.logging.Log;
  @@ -79,43 +78,43 @@
   
       private static Log log = LogFactory.getLog(GeronimoConnectionEventListener.class.getName());
   
  -    private final ManagedConnectionInfo mci;
  +    private final ManagedConnectionInfo managedConnectionInfo;
       private final ConnectionInterceptor stack;
  -    private final Set connectionHandles = new HashSet();
  +    private final List connectionInfos = new ArrayList();
   
       public GeronimoConnectionEventListener(
               final ConnectionInterceptor stack,
  -            final ManagedConnectionInfo mci) {
  +            final ManagedConnectionInfo managedConnectionInfo) {
           this.stack = stack;
  -        this.mci = mci;
  +        this.managedConnectionInfo = managedConnectionInfo;
       }
   
       public void connectionClosed(ConnectionEvent connectionEvent) {
  -        if (connectionEvent.getSource() != mci.getManagedConnection()) {
  +        if (connectionEvent.getSource() != managedConnectionInfo.getManagedConnection()) {
               throw new IllegalArgumentException(
                       "ConnectionClosed event received from wrong ManagedConnection. Expected "
  -                    + mci.getManagedConnection()
  +                    + managedConnectionInfo.getManagedConnection()
                       + ", actual "
                       + connectionEvent.getSource());
           }
           if (log.isTraceEnabled()) {
               log.trace("connectionClosed called with " + connectionEvent.getConnectionHandle());
           }
  -        ConnectionInfo ci = new ConnectionInfo(mci);
  +        ConnectionInfo ci = new ConnectionInfo(managedConnectionInfo);
           ci.setConnectionHandle(connectionEvent.getConnectionHandle());
           stack.returnConnection(ci, ConnectionReturnAction.RETURN_HANDLE);
       }
   
       public void connectionErrorOccurred(ConnectionEvent connectionEvent) {
  -        if (connectionEvent.getSource() != mci.getManagedConnection()) {
  +        if (connectionEvent.getSource() != managedConnectionInfo.getManagedConnection()) {
               throw new IllegalArgumentException(
                       "ConnectionError event received from wrong ManagedConnection. Expected "
  -                    + mci.getManagedConnection()
  +                    + managedConnectionInfo.getManagedConnection()
                       + ", actual "
                       + connectionEvent.getSource());
           }
           log.info("connectionErrorOccurred called with " + connectionEvent.getConnectionHandle(),connectionEvent.getException());
  -        ConnectionInfo ci = new ConnectionInfo(mci);
  +        ConnectionInfo ci = new ConnectionInfo(managedConnectionInfo);
           ci.setConnectionHandle(connectionEvent.getConnectionHandle());
           stack.returnConnection(ci, ConnectionReturnAction.DESTROY);
       }
  @@ -142,20 +141,30 @@
       public void localTransactionRolledback(ConnectionEvent event) {
       }
   
  -    public void addConnectionHandle(Object handle) {
  -        connectionHandles.add(handle);
  +    public void addConnectionInfo(ConnectionInfo connectionInfo) {
  +        assert connectionInfo.getConnectionHandle() != null;
  +        connectionInfos.add(connectionInfo);
       }
   
  -    public void removeConnectionHandle(Object handle) {
  -        connectionHandles.remove(handle);
  +    public void removeConnectionInfo(ConnectionInfo connectionInfo) {
  +        assert connectionInfo.getConnectionHandle() != null;
  +        connectionInfos.remove(connectionInfo);
       }
   
  -    public boolean hasConnectionHandles() {
  -        return !connectionHandles.isEmpty();
  +    public boolean hasConnectionInfos() {
  +        return !connectionInfos.isEmpty();
       }
   
  -    public void clearConnectionHandles() {
  -        connectionHandles.clear();
  +    public void clearConnectionInfos() {
  +        connectionInfos.clear();
  +    }
  +
  +    public boolean hasConnectionInfo(ConnectionInfo connectionInfo) {
  +        return connectionInfos.contains(connectionInfo);
  +    }
  +
  +    public boolean isFirstConnectionInfo(ConnectionInfo connectionInfo) {
  +        return !connectionInfos.isEmpty() && connectionInfos.get(0) == connectionInfo;
       }
   
   }
  
  
  
  1.4       +42 -83    incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionInfo.java
  
  Index: ManagedConnectionInfo.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionInfo.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ManagedConnectionInfo.java	9 Dec 2003 04:16:25 -0000	1.3
  +++ ManagedConnectionInfo.java	13 Dec 2003 23:33:53 -0000	1.4
  @@ -60,7 +60,6 @@
   import javax.resource.spi.ManagedConnection;
   import javax.resource.spi.ManagedConnectionFactory;
   import javax.security.auth.Subject;
  -import javax.transaction.Transaction;
   import javax.transaction.xa.XAResource;
   
   /**
  @@ -73,11 +72,11 @@
    */
   public class ManagedConnectionInfo {
   
  -    private ManagedConnectionFactory mcf;
  -    private ConnectionRequestInfo cri;
  +    private ManagedConnectionFactory managedConnectionFactory;
  +    private ConnectionRequestInfo connectionRequestInfo;
       private Subject subject;
  -    private Transaction tx;
  -    private ManagedConnection mc;
  +    private ConnectorTransactionContext transactionContext;
  +    private ManagedConnection managedConnection;
       private XAResource xares;
       private long lastUsed;
       private ConnectionInterceptor poolInterceptor;
  @@ -85,104 +84,56 @@
       private GeronimoConnectionEventListener listener;
   
       public ManagedConnectionInfo(
  -            ManagedConnectionFactory mcf,
  -            ConnectionRequestInfo cri) {
  -        this.mcf = mcf;
  -        this.cri = cri;
  -    } // ManagedConnectionInfo constructor
  -
  -    /**
  -     * Get the Mcf value.
  -     * @return the Mcf value.
  -     */
  +            ManagedConnectionFactory managedConnectionFactory,
  +            ConnectionRequestInfo connectionRequestInfo) {
  +        this.managedConnectionFactory = managedConnectionFactory;
  +        this.connectionRequestInfo = connectionRequestInfo;
  +    }
  +
       public ManagedConnectionFactory getManagedConnectionFactory() {
  -        return mcf;
  +        return managedConnectionFactory;
       }
   
  -    /**
  -     * Set the Mcf value.
  -     * @param newMcf The new Mcf value.
  -     */
  -    public void setManagedConnectionFactory(ManagedConnectionFactory mcf) {
  -        this.mcf = mcf;
  +    public void setManagedConnectionFactory(ManagedConnectionFactory managedConnectionFactory) {
  +        this.managedConnectionFactory = managedConnectionFactory;
       }
   
  -    /**
  -     * Get the Cri value.
  -     * @return the Cri value.
  -     */
       public ConnectionRequestInfo getConnectionRequestInfo() {
  -        return cri;
  +        return connectionRequestInfo;
       }
   
  -    /**
  -     * Set the Cri value.
  -     * @param newCri The new Cri value.
  -     */
       public void setConnectionRequestInfo(ConnectionRequestInfo cri) {
  -        this.cri = cri;
  +        this.connectionRequestInfo = cri;
       }
   
  -    /**
  -     * Get the Subject value.
  -     * @return the Subject value.
  -     */
       public Subject getSubject() {
           return subject;
       }
   
  -    /**
  -     * Set the Subject value.
  -     * @param newSubject The new Subject value.
  -     */
       public void setSubject(Subject subject) {
           this.subject = subject;
       }
   
  -    /**
  -     * Get the Tx value.
  -     * @return the Tx value.
  -     */
  -    public Transaction getTransaction() {
  -        return tx;
  -    }
  -
  -    /**
  -     * Set the Tx value.
  -     * @param newTx The new Tx value.
  -     */
  -    public void setTransaction(Transaction tx) {
  -        this.tx = tx;
  -    }
  -
  -    /**
  -     * Get the Mc value.
  -     * @return the Mc value.
  -     */
  +    public ConnectorTransactionContext getTransactionContext() {
  +        return transactionContext;
  +    }
  +
  +    public void setTransactionContext(ConnectorTransactionContext transactionContext) {
  +        this.transactionContext = transactionContext;
  +    }
  +
       public ManagedConnection getManagedConnection() {
  -        return mc;
  +        return managedConnection;
       }
   
  -    /**
  -     * Set the Mc value.
  -     * @param newMc The new Mc value.
  -     */
  -    public void setManagedConnection(ManagedConnection mc) {
  -        this.mc = mc;
  +    public void setManagedConnection(ManagedConnection managedConnection) {
  +        this.managedConnection = managedConnection;
       }
   
  -    /**
  -     * Get the Xares value.
  -     * @return the Xares value.
  -     */
       public XAResource getXAResource() {
           return xares;
       }
   
  -    /**
  -     * Set the Xares value.
  -     * @param newXares The new Xares value.
  -     */
       public void setXAResource(XAResource xares) {
           this.xares = xares;
       }
  @@ -207,20 +158,20 @@
           this.listener = listener;
       }
   
  -    public void addConnectionHandle(Object handle) {
  -        listener.addConnectionHandle(handle);
  +    public void addConnectionHandle(ConnectionInfo connectionInfo) {
  +        listener.addConnectionInfo(connectionInfo);
       }
   
  -    public void removeConnectionHandle(Object handle) {
  -        listener.removeConnectionHandle(handle);
  +    public void removeConnectionHandle(ConnectionInfo connectionInfo) {
  +        listener.removeConnectionInfo(connectionInfo);
       }
   
       public boolean hasConnectionHandles() {
  -        return listener.hasConnectionHandles();
  +        return listener.hasConnectionInfos();
       }
   
       public void clearConnectionHandles() {
  -        listener.clearConnectionHandles();
  +        listener.clearConnectionInfos();
       }
   
       public boolean securityMatches(ManagedConnectionInfo other) {
  @@ -228,9 +179,17 @@
                   subject == null
                   ? other.getSubject() == null
                   : subject.equals(other.getSubject()))
  -                && (cri == null
  +                && (connectionRequestInfo == null
                   ? other.getConnectionRequestInfo() == null
  -                : cri.equals(other.getConnectionRequestInfo()));
  +                : connectionRequestInfo.equals(other.getConnectionRequestInfo()));
  +    }
  +
  +    public boolean hasConnectionInfo(ConnectionInfo connectionInfo) {
  +        return listener.hasConnectionInfo(connectionInfo);
  +    }
  +
  +    public boolean isFirstConnectionInfo(ConnectionInfo connectionInfo) {
  +        return listener.isFirstConnectionInfo(connectionInfo);
       }
   
   }
  
  
  
  1.3       +30 -21    incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ProxyConnectionManager.java
  
  Index: ProxyConnectionManager.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ProxyConnectionManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ProxyConnectionManager.java	14 Nov 2003 16:00:23 -0000	1.2
  +++ ProxyConnectionManager.java	13 Dec 2003 23:33:53 -0000	1.3
  @@ -58,7 +58,6 @@
   
   import java.io.Serializable;
   
  -import javax.management.AttributeNotFoundException;
   import javax.management.InstanceNotFoundException;
   import javax.management.MBeanException;
   import javax.management.MBeanServer;
  @@ -90,7 +89,7 @@
       private final String agentID;
   
       /**
  -     * The field <code>CMName</code> holds the object name of
  +     * The field <code>ConnectionManagerName</code> holds the object name of
        * the ConnectionManagerDeployment that sets us up.
        *
        */
  @@ -100,31 +99,48 @@
   
       public ProxyConnectionManager(
               String agentID,
  -            ObjectName CMName,
  +            ObjectName ConnectionManagerName,
               ConnectionInterceptor stack) {
           this.agentID = agentID;
  -        this.CMName = CMName;
  +        this.CMName = ConnectionManagerName;
           this.stack = stack;
  -    } // ProxyConnectionManager constructor
  +    }
   
  +    /**
  +     * in: mcf != null, is a deployed mcf
  +     * out: useable connection object.
  +     * @param managedConnectionFactory
  +     * @param connectionRequestInfo
  +     * @return
  +     * @throws ResourceException
  +     */
       public Object allocateConnection(
  -            ManagedConnectionFactory mcf,
  -            ConnectionRequestInfo cri)
  +            ManagedConnectionFactory managedConnectionFactory,
  +            ConnectionRequestInfo connectionRequestInfo)
               throws ResourceException {
           internalGetStack();
  -        ManagedConnectionInfo mci = new ManagedConnectionInfo(mcf, cri);
  +        ManagedConnectionInfo mci = new ManagedConnectionInfo(managedConnectionFactory, connectionRequestInfo);
           ConnectionInfo ci = new ConnectionInfo(mci);
           stack.getConnection(ci);
           return ci.getConnectionHandle();
       }
   
  +    /**
  +     * in: non-null connection object, from non-null mcf.
  +     * connection object is not associated with a managed connection
  +     * out: supplied connection object is assiciated with a non-null ManagedConnection from mcf.
  +     * @param connection
  +     * @param managedConnectionFactory
  +     * @param connectionRequestInfo
  +     * @throws ResourceException
  +     */
       public void associateConnection(
               Object connection,
  -            ManagedConnectionFactory mcf,
  -            ConnectionRequestInfo cri)
  +            ManagedConnectionFactory managedConnectionFactory,
  +            ConnectionRequestInfo connectionRequestInfo)
               throws ResourceException {
           internalGetStack();
  -        ManagedConnectionInfo mci = new ManagedConnectionInfo(mcf, cri);
  +        ManagedConnectionInfo mci = new ManagedConnectionInfo(managedConnectionFactory, connectionRequestInfo);
           ConnectionInfo ci = new ConnectionInfo(mci);
           ci.setConnectionHandle(connection);
           stack.getConnection(ci);
  @@ -137,20 +153,15 @@
                               0);
               try {
                   this.stack =
  -                        (ConnectionInterceptor) server.getAttribute(
  -                                this.CMName,
  -                                "Stack");
  +                        (ConnectionInterceptor) server.invoke(CMName, "getStack", null, null);
               } catch (InstanceNotFoundException e) {
                   throw new ResourceException("Could not get stack from jmx", e);
               } catch (MBeanException e) {
                   throw new ResourceException("Could not get stack from jmx", e);
               } catch (ReflectionException e) {
                   throw new ResourceException("Could not get stack from jmx", e);
  -            } catch (AttributeNotFoundException e) {
  -                throw new ResourceException("Could not get stack from jmx", e);
               }
  -
  -        } // end of if ()
  +        }
       }
   
       /**
  @@ -159,11 +170,9 @@
        * of this object.
        *
        * @return a <code>ConnectionInterceptor</code> value
  -     *
  -     * @jmx.managed-operation
        */
       public ConnectionInterceptor getStack() {
           return stack;
       }
   
  -} // ProxyConnectionManager
  +}
  
  
  
  1.4       +11 -18    incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptor.java
  
  Index: TransactionEnlistingInterceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TransactionEnlistingInterceptor.java	9 Dec 2003 04:16:25 -0000	1.3
  +++ TransactionEnlistingInterceptor.java	13 Dec 2003 23:33:53 -0000	1.4
  @@ -59,12 +59,8 @@
   import javax.resource.ResourceException;
   import javax.transaction.RollbackException;
   import javax.transaction.SystemException;
  -import javax.transaction.Transaction;
  -import javax.transaction.TransactionManager;
   import javax.transaction.xa.XAResource;
   
  -import org.apache.geronimo.connector.TxUtils;
  -
   /**
    * TransactionEnlistingInterceptor.java
    *
  @@ -76,24 +72,21 @@
   public class TransactionEnlistingInterceptor implements ConnectionInterceptor {
   
       private final ConnectionInterceptor next;
  -    private final TransactionManager transactionManager;
   
       public TransactionEnlistingInterceptor(
  -            ConnectionInterceptor next,
  -            TransactionManager transactionManager) {
  +            ConnectionInterceptor next
  +            ) {
           this.next = next;
  -        this.transactionManager = transactionManager;
       }
   
       public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
           next.getConnection(connectionInfo);
           try {
  -            Transaction tx = transactionManager.getTransaction();
  -            if (TxUtils.isActive(tx)) {
  -                ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
  +            ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
  +            ConnectorTransactionContext transactionContext = mci.getTransactionContext();
  +            if (transactionContext.isActive()) {
                   XAResource xares = mci.getXAResource();
  -                tx.enlistResource(xares);
  -                mci.setTransaction(tx);
  +                transactionContext.getTransaction().enlistResource(xares);
               }
   
           } catch (SystemException e) {
  @@ -119,12 +112,12 @@
               ConnectionInfo connectionInfo,
               ConnectionReturnAction connectionReturnAction) {
           try {
  -            Transaction tx = transactionManager.getTransaction();
  -            if (TxUtils.isActive(tx)) {
  -                ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
  +            ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
  +            ConnectorTransactionContext transactionContext = mci.getTransactionContext();
  +            if (transactionContext.isActive()) {
                   XAResource xares = mci.getXAResource();
  -                tx.delistResource(xares, XAResource.TMSUSPEND);
  -                mci.setTransaction(null);
  +                transactionContext.getTransaction().delistResource(xares, XAResource.TMSUSPEND);
  +                mci.setTransactionContext(null);
               }
   
           } catch (SystemException e) {
  
  
  
  1.2       +5 -1      incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl/DefaultTransactionContext.java
  
  Index: DefaultTransactionContext.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/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	9 Dec 2003 04:13:20 -0000	1.1
  +++ DefaultTransactionContext.java	13 Dec 2003 23:33:54 -0000	1.2
  @@ -124,6 +124,10 @@
           }
       }
   
  +    public Transaction getTransaction() {
  +        return transaction;
  +    }
  +
       public void beforeCompletion() {
       }
   
  
  
  
  1.2       +11 -1     incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
  
  Index: ConnectionManagerTestUtils.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectionManagerTestUtils.java	10 Dec 2003 07:48:12 -0000	1.1
  +++ ConnectionManagerTestUtils.java	13 Dec 2003 23:33:54 -0000	1.2
  @@ -68,10 +68,13 @@
   import javax.resource.spi.LocalTransaction;
   import javax.resource.spi.ManagedConnectionMetaData;
   import javax.resource.spi.DissociatableManagedConnection;
  +import javax.transaction.Transaction;
   import javax.transaction.xa.XAResource;
   
   import junit.framework.TestCase;
   
  +import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultTransactionContext;
  +
   /**
    *
    *
  @@ -121,6 +124,13 @@
   
       protected ConnectionInfo makeConnectionInfo() {
           ManagedConnectionInfo managedConnectionInfo = new ManagedConnectionInfo(null, null);
  +        return new ConnectionInfo(managedConnectionInfo);
  +    }
  +
  +    protected ConnectionInfo makeConnectionInfo(Transaction transaction) throws Exception {
  +        DefaultTransactionContext transactionContext = new DefaultTransactionContext(transaction);
  +        ManagedConnectionInfo managedConnectionInfo = new ManagedConnectionInfo(null, null);
  +        managedConnectionInfo.setTransactionContext(transactionContext);
           return new ConnectionInfo(managedConnectionInfo);
       }
   
  
  
  
  1.3       +2 -1      incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptorTest.java
  
  Index: ConnectionTrackingInterceptorTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptorTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConnectionTrackingInterceptorTest.java	10 Dec 2003 07:48:12 -0000	1.2
  +++ ConnectionTrackingInterceptorTest.java	13 Dec 2003 23:33:54 -0000	1.3
  @@ -198,6 +198,7 @@
           managedConnectionInfo.setConnectionEventListener(new GeronimoConnectionEventListener(null, managedConnectionInfo));
           managedConnectionInfo.setSubject(subject);
           managedConnectionInfo.setManagedConnection(managedConnection);
  +        managedConnectionInfo.addConnectionHandle(connectionInfo);
       }
   
   }
  
  
  
  1.3       +7 -7      incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptorTest.java
  
  Index: TransactionEnlistingInterceptorTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptorTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TransactionEnlistingInterceptorTest.java	10 Dec 2003 07:48:12 -0000	1.2
  +++ TransactionEnlistingInterceptorTest.java	13 Dec 2003 23:33:54 -0000	1.3
  @@ -57,6 +57,7 @@
   package org.apache.geronimo.connector.outbound;
   
   import javax.resource.ResourceException;
  +import javax.transaction.Transaction;
   import javax.transaction.TransactionManager;
   import javax.transaction.xa.XAResource;
   import javax.transaction.xa.Xid;
  @@ -74,7 +75,6 @@
       implements XAResource {
   
       private TransactionEnlistingInterceptor transactionEnlistingInterceptor;
  -    private TransactionManager transactionManager;
       private boolean started;
       private boolean ended;
       private boolean returned;
  @@ -82,13 +82,11 @@
   
       protected void setUp() throws Exception {
           super.setUp();
  -        transactionManager = new TransactionManagerImpl();
  -        transactionEnlistingInterceptor = new TransactionEnlistingInterceptor(this, transactionManager);
  +        transactionEnlistingInterceptor = new TransactionEnlistingInterceptor(this);
       }
   
       protected void tearDown() throws Exception {
           super.tearDown();
  -        transactionManager = null;
           transactionEnlistingInterceptor = null;
           started = false;
           ended = false;
  @@ -97,7 +95,7 @@
       }
   
       public void testNoTransaction() throws Exception {
  -        ConnectionInfo connectionInfo = makeConnectionInfo();
  +        ConnectionInfo connectionInfo = makeConnectionInfo(null);
           transactionEnlistingInterceptor.getConnection(connectionInfo);
           assertTrue("Expected not started", !started);
           assertTrue("Expected not ended", !ended);
  @@ -107,8 +105,10 @@
       }
   
       public void testTransaction() throws Exception {
  -        ConnectionInfo connectionInfo = makeConnectionInfo();
  +        TransactionManager transactionManager = new TransactionManagerImpl();
           transactionManager.begin();
  +        Transaction transaction = transactionManager.getTransaction();
  +        ConnectionInfo connectionInfo = makeConnectionInfo(transaction);
           transactionEnlistingInterceptor.getConnection(connectionInfo);
           assertTrue("Expected started", started);
           assertTrue("Expected not ended", !ended);