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/09 05:13:21 UTC

cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl DefaultComponentContext.java DefaultComponentInterceptor.java DefaultInterceptor.java DefaultTransactionContext.java

djencks     2003/12/08 20:13:21

  Added:       modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking
                        ConnectionTracker.java
                        ConnectionTrackingCoordinator.java
                        TrackedConnectionAssociator.java
               modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl
                        DefaultComponentContext.java
                        DefaultComponentInterceptor.java
                        DefaultInterceptor.java
                        DefaultTransactionContext.java
  Log:
  refactored framework for tracking connection handles and connections enrolled in transactions, without synchronization
  
  Revision  Changes    Path
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTracker.java
  
  Index: ConnectionTracker.java
  ===================================================================
  package org.apache.geronimo.connector.outbound.connectiontracking;
  
  import org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor;
  import org.apache.geronimo.connector.outbound.ConnectionInfo;
  import org.apache.geronimo.connector.outbound.ConnectorTransactionContext;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2003/12/09 04:13:20 $
   *
   * */
  public interface ConnectionTracker {
      void handleObtained(
              ConnectionTrackingInterceptor connectionTrackingInterceptor,
              ConnectionInfo connectionInfo);
  
      void handleReleased(
              ConnectionTrackingInterceptor connectionTrackingInterceptor,
              ConnectionInfo connectionInfo);
  
      ConnectorTransactionContext getConnectorTransactionContext();
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java
  
  Index: ConnectionTrackingCoordinator.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.connector.outbound.connectiontracking;
  
  import java.util.HashSet;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.Set;
  
  import javax.resource.ResourceException;
  
  import org.apache.geronimo.connector.outbound.ConnectorComponentContext;
  import org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor;
  import org.apache.geronimo.connector.outbound.ConnectionInfo;
  import org.apache.geronimo.connector.outbound.ConnectorTransactionContext;
  import org.apache.geronimo.kernel.service.GeronimoMBeanInfo;
  
  /**
   * CachedConnectionManager tracks connections that are in use by
   * components such as EJB's.  The component must notify the ccm
   * when a method enters and exits.  On entrance, the ccm will
   * notify ConnectionManager stacks so the stack can make sure all
   * connection handles left open from previous method calls are
   * attached to ManagedConnections of the correct security context, and
   *  the ManagedConnections are enrolled in any current transaction.
   * On exit, the ccm will notify ConnectionManager stacks of the handles
   * left open, so they may be disassociated if appropriate.
   * In addition, when a UserTransaction is started the ccm will notify
   * ConnectionManager stacks so the existing ManagedConnections can be
   * enrolled properly.
   *
   * TODO make sure tx enlistment on method entry works
   * TODO implement UserTransaction notifications and tx enlistment.
   *
   * @version $Revision: 1.1 $ $Date: 2003/12/09 04:13:20 $
   *
   * */
  public class ConnectionTrackingCoordinator implements TrackedConnectionAssociator, ConnectionTracker {
  
      private final ThreadLocal currentConnectorComponentContexts = new ThreadLocal();
      private final ThreadLocal currentConnectorTransactionContexts = new ThreadLocal();
  
      public ConnectorComponentContext enter(ConnectorComponentContext newConnectorComponentContext,
                                             Set unshareableResources)
              throws ResourceException {
          ConnectorComponentContext oldConnectorComponentContext = (ConnectorComponentContext) currentConnectorComponentContexts.get();
          currentConnectorComponentContexts.set(newConnectorComponentContext);
          Map connectionManagerToManagedConnectionInfoMap = newConnectorComponentContext.getConnectionManagerMap();
          for (Iterator i = connectionManagerToManagedConnectionInfoMap.entrySet().iterator(); i.hasNext();) {
              Map.Entry entry = (Map.Entry) i.next();
              ConnectionTrackingInterceptor mcci =
                      (ConnectionTrackingInterceptor) entry.getKey();
              Set connections = (Set) entry.getValue();
              mcci.enter(connections, unshareableResources);
          }
          return oldConnectorComponentContext;
      }
  
      public void exit(ConnectorComponentContext reenteringConnectorComponentContext,
                       Set unshareableResources)
              throws ResourceException {
          ConnectorComponentContext oldConnectorComponentContext = (ConnectorComponentContext) currentConnectorComponentContexts.get();
          Map resources = oldConnectorComponentContext.getConnectionManagerMap();
          for (Iterator i = resources.entrySet().iterator(); i.hasNext();) {
              Map.Entry entry = (Map.Entry) i.next();
              ConnectionTrackingInterceptor mcci =
                      (ConnectionTrackingInterceptor) entry.getKey();
              Set connections = (Set) entry.getValue();
              mcci.exit(connections, unshareableResources);
              if (connections.isEmpty()) {
                  i.remove();
              }
          }
          currentConnectorComponentContexts.set(reenteringConnectorComponentContext);
      }
  
      public ConnectorTransactionContext setConnectorTransactionContext(ConnectorTransactionContext newConnectorTransactionContext) {
          ConnectorTransactionContext oldConnectorTransactionContext = (ConnectorTransactionContext) currentConnectorTransactionContexts.get();
          currentConnectorTransactionContexts.set(newConnectorTransactionContext);
          return oldConnectorTransactionContext;
      }
  
      public void handleObtained(
              ConnectionTrackingInterceptor connectionTrackingInterceptor,
              ConnectionInfo connectionInfo) {
          ConnectorComponentContext connectorComponentContext = (ConnectorComponentContext) currentConnectorComponentContexts.get();
          if (connectorComponentContext == null) {
              return;
          }
          Map resources = connectorComponentContext.getConnectionManagerMap();
          Set infos = (Set) resources.get(connectionTrackingInterceptor);
          if (infos == null) {
              infos = new HashSet();
              resources.put(connectionTrackingInterceptor, infos);
          }
          infos.add(connectionInfo);
      }
  
      public void handleReleased(
              ConnectionTrackingInterceptor connectionTrackingInterceptor,
              ConnectionInfo connectionInfo) {
          ConnectorComponentContext connectorComponentContext = (ConnectorComponentContext) currentConnectorComponentContexts.get();
          if (connectorComponentContext == null) {
              return;
          }
          Map resources = connectorComponentContext.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 static GeronimoMBeanInfo getGeronimoMBeanInfo() {
          GeronimoMBeanInfo mbeanInfo = new GeronimoMBeanInfo();
          mbeanInfo.setTargetClass(ConnectionTrackingCoordinator.class.getName());
          mbeanInfo.addOperationsDeclaredIn(TrackedConnectionAssociator.class );
          mbeanInfo.addOperationsDeclaredIn(ConnectionTracker.class);
          return mbeanInfo;
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/TrackedConnectionAssociator.java
  
  Index: TrackedConnectionAssociator.java
  ===================================================================
  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;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2003/12/09 04:13:20 $
   *
   * */
  public interface TrackedConnectionAssociator {
      ConnectorComponentContext enter(ConnectorComponentContext newConnectorComponentContext,
                                      Set unshareableResources)
              throws ResourceException;
  
      void exit(ConnectorComponentContext reenteringConnectorComponentContext,
                Set unshareableResources)
              throws ResourceException;
  
      ConnectorTransactionContext setConnectorTransactionContext(ConnectorTransactionContext newConnectorTransactionContext);
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl/DefaultComponentContext.java
  
  Index: DefaultComponentContext.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.connector.outbound.connectiontracking.defaultimpl;
  
  import java.util.Map;
  import java.util.HashMap;
  
  import org.apache.geronimo.connector.outbound.ConnectorComponentContext;
  import org.apache.geronimo.connector.outbound.ConnectorTransactionContext;
  
  /**
   * Simple implementation of ComponentContext satisfying invariant.
   *
   * @version $Revision: 1.1 $ $Date: 2003/12/09 04:13:20 $
   *
   * */
  public class DefaultComponentContext implements ConnectorComponentContext{
  
      private final Map connectionManagerMap = new HashMap();
  
      public Map getConnectionManagerMap() {
          return connectionManagerMap;
      }
  
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl/DefaultComponentInterceptor.java
  
  Index: DefaultComponentInterceptor.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.connector.outbound.connectiontracking.defaultimpl;
  
  import java.util.Set;
  import java.util.Map;
  import java.util.HashMap;
  
  import javax.transaction.TransactionManager;
  import javax.transaction.Transaction;
  import javax.transaction.Status;
  
  import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
  import org.apache.geronimo.connector.outbound.ConnectorComponentContext;
  import org.apache.geronimo.connector.outbound.ConnectorTransactionContext;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2003/12/09 04:13:20 $
   *
   * */
  public class DefaultComponentInterceptor implements DefaultInterceptor{
  
      private final DefaultInterceptor next;
      private final TrackedConnectionAssociator cachedConnectionAssociator;
      private final Set unshareableResources;
      private final TransactionManager transactionManager;
      private final Map transactionToTransactionContextMap = new HashMap();
  
      public DefaultComponentInterceptor(DefaultInterceptor next,
                                         TrackedConnectionAssociator cachedConnectionManager,
                                         Set unshareableResources,
                                         TransactionManager transactionManager) {
          this.next = next;
          this.cachedConnectionAssociator = cachedConnectionManager;
          this.unshareableResources = unshareableResources;
          this.transactionManager = transactionManager;
      }
  
      public Object invoke(ConnectorComponentContext newConnectorComponentContext) throws Throwable {
          Transaction transaction = transactionManager.getTransaction();
          ConnectorTransactionContext newConnectorTransactionContext;
          if (transaction == null || transaction.getStatus() == Status.STATUS_COMMITTED || transaction.getStatus() == Status.STATUS_ROLLEDBACK) {
              newConnectorTransactionContext = new DefaultTransactionContext(null);
          } else {
              newConnectorTransactionContext = (ConnectorTransactionContext) transactionToTransactionContextMap.get(transaction);
              if (newConnectorTransactionContext == null) {
                  newConnectorTransactionContext = new DefaultTransactionContext(transaction);
              }
          }
          ConnectorComponentContext oldConnectorComponentContext = cachedConnectionAssociator.enter(newConnectorComponentContext, unshareableResources);
          ConnectorTransactionContext oldConnectorTransactionContext = cachedConnectionAssociator.setConnectorTransactionContext(newConnectorTransactionContext);
          try {
              return next.invoke(newConnectorComponentContext);
          } finally {
              cachedConnectionAssociator.exit(oldConnectorComponentContext, unshareableResources);
              cachedConnectionAssociator.setConnectorTransactionContext(oldConnectorTransactionContext);
          }
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl/DefaultInterceptor.java
  
  Index: DefaultInterceptor.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.connector.outbound.connectiontracking.defaultimpl;
  
  import org.apache.geronimo.connector.outbound.ConnectorComponentContext;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2003/12/09 04:13:20 $
   *
   * */
  public interface DefaultInterceptor {
  
      Object invoke(ConnectorComponentContext newConnectorComponentContextontext) throws Throwable;
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/connectiontracking/defaultimpl/DefaultTransactionContext.java
  
  Index: DefaultTransactionContext.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.connector.outbound.connectiontracking.defaultimpl;
  
  import java.util.Map;
  import java.util.HashMap;
  import java.util.Iterator;
  
  import javax.transaction.Transaction;
  import javax.transaction.Status;
  import javax.transaction.SystemException;
  import javax.transaction.Synchronization;
  import javax.transaction.RollbackException;
  
  import org.apache.geronimo.connector.outbound.ConnectorTransactionContext;
  import org.apache.geronimo.connector.outbound.ManagedConnectionInfo;
  import org.apache.geronimo.connector.outbound.ConnectionReleaser;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2003/12/09 04:13:20 $
   *
   * */
  public class DefaultTransactionContext implements ConnectorTransactionContext, Synchronization {
  
      private Map managedConnections;
  
      private final Transaction transaction;
  
      public DefaultTransactionContext(Transaction transaction) throws SystemException, RollbackException {
          this.transaction = transaction;
          if (transaction != null) {
              assert transaction.getStatus() == Status.STATUS_ACTIVE;
              transaction.registerSynchronization(this);
          }
      }
  
      /**
       * 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) {
          if (isActive()) {
              if (managedConnections == null) {
                  managedConnections = new HashMap();
              }
              managedConnections.put(key, info);
          }
      }
  
      public ManagedConnectionInfo getManagedConnectionInfo(ConnectionReleaser key) {
          if (managedConnections == null) {
              return null;
          }
          return (ManagedConnectionInfo) managedConnections.get(key);
      }
  
      /**
       * I'm not sure I got the condition right here.
       * @return
       */
      public boolean isActive() {
          try {
              return transaction != null && (transaction.getStatus() == Status.STATUS_ACTIVE);
          } catch (SystemException e) {
              return false; //this is doubtful
          }
      }
  
      public void beforeCompletion() {
      }
  
      public void afterCompletion(int status) {
          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((ManagedConnectionInfo)entry.getValue());
              }
              //should we clear managedConnections?  might be less work for garbage collector.  any other reason?
          }
      }
  }