geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1074024 [1/2] - in /geronimo/sandbox/djencks/txmanager: ./ connector-itests/src/test/java/org/apache/geronimo/components/connector/itests/ geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/ geronimo-connector/src/mai...
Date Thu, 24 Feb 2011 02:25:53 GMT
Author: djencks
Date: Thu Feb 24 02:25:51 2011
New Revision: 1074024

URL: http://svn.apache.org/viewvc?rev=1074024&view=rev
Log:
add a lot of service references for wiring.  Use a DS component factory to construct the connection manager

Added:
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/BaseConnectionManager.java   (contents, props changed)
      - copied, changed from r1071447, geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/DSFactoryConnectionManager.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/InterceptorsImpl.java
Removed:
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionInterceptorSource.java
Modified:
    geronimo/sandbox/djencks/txmanager/connector-itests/src/test/java/org/apache/geronimo/components/connector/itests/ConnectorTest.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/AssemblyListener.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/impl/AssemblerImpl.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/ConnectorExtender.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/Container.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionHandleInterceptor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionInterceptor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/LocalXAResourceInsertionInterceptor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/MCFConnectionInterceptor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/MultiPoolConnectionInterceptor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SubjectInterceptor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TCCLInterceptor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ThreadLocalCachingConnectionInterceptor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionEnlistingInterceptor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TxUtil.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/XAResourceInsertionInterceptor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/transactionlog/LogXAResourceInsertionInterceptor.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/AssemblerTest.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolTest.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionInterceptorTestUtils.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorProxyTest.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorTest.java
    geronimo/sandbox/djencks/txmanager/pom.xml

Modified: geronimo/sandbox/djencks/txmanager/connector-itests/src/test/java/org/apache/geronimo/components/connector/itests/ConnectorTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/connector-itests/src/test/java/org/apache/geronimo/components/connector/itests/ConnectorTest.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/connector-itests/src/test/java/org/apache/geronimo/components/connector/itests/ConnectorTest.java (original)
+++ geronimo/sandbox/djencks/txmanager/connector-itests/src/test/java/org/apache/geronimo/components/connector/itests/ConnectorTest.java Thu Feb 24 02:25:51 2011
@@ -16,6 +16,7 @@ import org.apache.geronimo.connector.ass
 import org.apache.geronimo.connector.extender.ConnectorExtender;
 import org.apache.geronimo.connector.mock.MockAdminObject;
 import org.apache.geronimo.connector.mock.MockAdminObjectImpl;
+import org.apache.geronimo.connector.mock.MockConnectionFactory;
 import org.apache.geronimo.connector.mock.MockManagedConnectionFactory;
 import org.apache.geronimo.connector.mock.MockResourceAdapter;
 import org.apache.geronimo.connector.model.AdminObjectInfo;
@@ -36,8 +37,11 @@ import org.ops4j.pax.exam.junit.JUnit4Te
 import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentFactory;
 
 import static org.junit.Assert.assertEquals;
+import static org.ops4j.pax.exam.CoreOptions.bundle;
 import static org.ops4j.pax.exam.CoreOptions.equinox;
 import static org.ops4j.pax.exam.CoreOptions.options;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
@@ -107,10 +111,18 @@ public class ConnectorTest {
         Assert.assertNotNull(bundleContext.getServiceReference(BootstrapContext.class.getName()));
         Assert.assertNotNull(bundleContext.getServiceReference(ConnectionTracker.class.getName()));
 
+        //connectionmanager factory component
+        Assert.assertNotNull(bundleContext.getServiceReference(ComponentFactory.class.getName()));
+
+
         //mock connector services
         Assert.assertNotNull(bundleContext.getServiceReference(ResourceAdapter.class.getName()));
         Assert.assertNotNull(bundleContext.getServiceReference(MockAdminObject.class.getName()));
         Assert.assertNotNull(bundleContext.getServiceReference(ConnectionManagerContainer.class.getName()));
+        ServiceReference sr = bundleContext.getServiceReference(ConnectionManagerContainer.class.getName());
+        ConnectionManagerContainer cm = (ConnectionManagerContainer) bundleContext.getService(sr);
+        MockConnectionFactory cf = (MockConnectionFactory) cm.createConnectionFactory();
+        cf.getConnection();
     }
 
     private static InputStream raInputStream() throws ResourceException, IOException {

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/AssemblyListener.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/AssemblyListener.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/AssemblyListener.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/AssemblyListener.java Thu Feb 24 02:25:51 2011
@@ -22,6 +22,7 @@ package org.apache.geronimo.connector.as
 
 import javax.resource.spi.ManagedConnectionFactory;
 import javax.resource.spi.ResourceAdapter;
+import org.apache.geronimo.connector.outbound.BaseConnectionManager;
 import org.apache.geronimo.connector.outbound.GenericConnectionManager;
 
 /**
@@ -34,6 +35,6 @@ public interface AssemblyListener {
 
     void newAdminObject(String name, String adminObjectInterface, Object adminObject);
 
-    void newManagedConnectionFactory(String name, ManagedConnectionFactory managedConnectionFactory, GenericConnectionManager connectionManager);
+    void newManagedConnectionFactory(String name, ManagedConnectionFactory managedConnectionFactory, BaseConnectionManager.Interceptors interceptors);
 
 }

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/impl/AssemblerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/impl/AssemblerImpl.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/impl/AssemblerImpl.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/impl/AssemblerImpl.java Thu Feb 24 02:25:51 2011
@@ -36,7 +36,9 @@ import org.apache.geronimo.connector.mod
 import org.apache.geronimo.connector.model.ManagedConnectionFactoryInfo;
 import org.apache.geronimo.connector.model.ResourceAdapterInfo;
 import org.apache.geronimo.connector.model.ResourceAdapterModuleInfo;
+import org.apache.geronimo.connector.outbound.BaseConnectionManager;
 import org.apache.geronimo.connector.outbound.GenericConnectionManager;
+import org.apache.geronimo.connector.outbound.InterceptorsImpl;
 import org.apache.geronimo.connector.outbound.SubjectSource;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoPool;
@@ -103,17 +105,17 @@ public class AssemblerImpl implements As
         }
         TransactionSupport transactionSupport = transactionSupport(managedConnectionFactoryInfo.transactionSupport);
         PoolingSupport poolingSupport = poolingSupport(managedConnectionFactoryInfo);
-        GenericConnectionManager connectionManager = new GenericConnectionManager(transactionSupport,
+        BaseConnectionManager.Interceptors interceptors = new InterceptorsImpl(transactionSupport,
                 poolingSupport,
-                subjectSource,
-                connectionTracker,
-                transactionManager,
-                managedConnectionFactory,
+                null,
                 managedConnectionFactoryInfo.name,
+                null,
+                null,
+                managedConnectionFactory,
                 threadClassLoader);
 
         for (AssemblyListener listener: listeners) {
-            listener.newManagedConnectionFactory(managedConnectionFactoryInfo.name, managedConnectionFactory, connectionManager);
+            listener.newManagedConnectionFactory(managedConnectionFactoryInfo.name, managedConnectionFactory, interceptors);
         }
     }
 

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/ConnectorExtender.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/ConnectorExtender.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/ConnectorExtender.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/ConnectorExtender.java Thu Feb 24 02:25:51 2011
@@ -27,11 +27,14 @@ import java.net.URL;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
 import org.apache.geronimo.connector.model.ResourceAdapterModuleInfo;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.Constants;
+import org.osgi.service.component.ComponentFactory;
 import org.osgi.util.tracker.BundleTracker;
 import org.osgi.util.tracker.BundleTrackerCustomizer;
 
@@ -44,6 +47,9 @@ public class ConnectorExtender {
 
     public final static String PLAN_LOCATION = "OSGI-INF/connector/plan.ser";
 
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY, target = "(component.factory=org.apache.geronimo.connector.outbound.DSFactoryConnectionManager)")
+    private ComponentFactory cmFactory;
+
     private BundleTracker bt;
 
     @Activate
@@ -97,7 +103,7 @@ public class ConnectorExtender {
             } catch (IOException e) {
             }
             if (moduleInfo != null) {
-                Container container = new Container(bundle, moduleInfo);
+                Container container = new Container(bundle, moduleInfo, cmFactory);
                 //TODO use an executor
                 container.run();
                 return container;
@@ -115,4 +121,11 @@ public class ConnectorExtender {
 
     }
 
+    public void setCmFactory(ComponentFactory cmFactory) {
+        this.cmFactory = cmFactory;
+    }
+
+    public void unsetCmFactory(ComponentFactory cmFactory) {
+        this.cmFactory = null;
+    }
 }

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/Container.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/Container.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/Container.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/Container.java Thu Feb 24 02:25:51 2011
@@ -25,17 +25,21 @@ import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.List;
 
+import javax.naming.spi.DirStateFactory;
 import javax.resource.ResourceException;
 import javax.resource.spi.ManagedConnectionFactory;
 import javax.resource.spi.ResourceAdapter;
 import org.apache.geronimo.connector.assembler.AssemblyListener;
 import org.apache.geronimo.connector.assembler.impl.AssemblerImpl;
 import org.apache.geronimo.connector.model.ResourceAdapterModuleInfo;
+import org.apache.geronimo.connector.outbound.BaseConnectionManager;
 import org.apache.geronimo.connector.outbound.ConnectionManagerContainer;
+import org.apache.geronimo.connector.outbound.DSFactoryConnectionManager;
 import org.apache.geronimo.connector.outbound.GenericConnectionManager;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.ComponentFactory;
 
 /**
  * @version $Rev:$ $Date:$
@@ -44,12 +48,14 @@ public class Container implements Assemb
 
     private final Bundle bundle;
     private final ResourceAdapterModuleInfo moduleInfo;
+    private final ComponentFactory cmFactory;
     private final List<ServiceRegistration> serviceRegistrations = new ArrayList<ServiceRegistration>();
 
 
-    public Container(Bundle bundle, ResourceAdapterModuleInfo moduleInfo) {
+    public Container(Bundle bundle, ResourceAdapterModuleInfo moduleInfo, ComponentFactory cmFactory) {
         this.bundle = bundle;
         this.moduleInfo = moduleInfo;
+        this.cmFactory = cmFactory;
     }
 
     @Override
@@ -83,10 +89,12 @@ public class Container implements Assemb
     }
 
     @Override
-    public void newManagedConnectionFactory(String name, ManagedConnectionFactory managedConnectionFactory, GenericConnectionManager connectionManager) {
-        String[] interfaceNames = new String[] {ConnectionManagerContainer.class.getName()};
-        Object service = new CMServiceFactory(connectionManager);
-        registerService(interfaceNames, service);
+    public void newManagedConnectionFactory(String name, ManagedConnectionFactory managedConnectionFactory, BaseConnectionManager.Interceptors interceptors) {
+        Dictionary properties = new Hashtable();
+        properties.put(DSFactoryConnectionManager.INTERCEPTORS, interceptors);
+        properties.put(DSFactoryConnectionManager.MCF, managedConnectionFactory);
+        properties.put(DSFactoryConnectionManager.NAME, name);
+        cmFactory.newInstance(properties);
     }
 
     private void registerService(String[] interfaceNames, Object service) {
@@ -95,27 +103,4 @@ public class Container implements Assemb
         serviceRegistrations.add(sr);
     }
 
-
-    private static class CMServiceFactory implements ServiceFactory {
-
-        private final GenericConnectionManager cm;
-
-        private CMServiceFactory(GenericConnectionManager cm) {
-            this.cm = cm;
-        }
-
-        @Override
-        public Object getService(Bundle bundle, ServiceRegistration serviceRegistration) {
-            return cm;
-        }
-
-        @Override
-        public void ungetService(Bundle bundle, ServiceRegistration serviceRegistration, Object o) {
-            try {
-                cm.doStop();
-            } catch (Exception e) {
-                //?
-            }
-        }
-    }
 }

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractSinglePoolConnectionInterceptor.java Thu Feb 24 02:25:51 2011
@@ -30,7 +30,9 @@ import javax.resource.spi.ConnectionRequ
 import javax.resource.spi.ManagedConnection;
 import javax.resource.spi.ManagedConnectionFactory;
 import javax.security.auth.Subject;
+import javax.transaction.TransactionManager;
 
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -65,6 +67,7 @@ public abstract class AbstractSinglePool
         permits = new Semaphore(maxSize, true);
     }
 
+    @Override
     public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
         if (connectionInfo.getManagedConnectionInfo().getManagedConnection() != null) {
             if (log.isTraceEnabled()) {
@@ -100,6 +103,7 @@ public abstract class AbstractSinglePool
 
     protected abstract void internalGetConnection(ConnectionInfo connectionInfo) throws ResourceException;
 
+    @Override
     public void returnConnection(ConnectionInfo connectionInfo,
                                  ConnectionReturnAction connectionReturnAction) {
         if (log.isTraceEnabled()) {
@@ -190,6 +194,7 @@ public abstract class AbstractSinglePool
     protected abstract void internalDestroy();
 
     // Cancel the IdleReleaser TimerTask (fixes memory leak) and clean up the pool
+    @Override
     public void destroy() {
         destroyed = true;
         if (idleReleaser != null)
@@ -198,6 +203,36 @@ public abstract class AbstractSinglePool
         next.destroy();
     }
 
+    @Override
+    public void setConnectionTracker(ConnectionTracker connectionTracker) {
+        next.setConnectionTracker(connectionTracker);
+    }
+
+    @Override
+    public void unsetConnectionTracker() {
+        next.unsetConnectionTracker();
+    }
+
+    @Override
+    public void setTransactionManager(TransactionManager transactionManager) {
+        next.setTransactionManager(transactionManager);
+    }
+
+    @Override
+    public void unsetTransactionManager() {
+        next.unsetTransactionManager();
+    }
+
+    @Override
+    public void setSubjectSource(SubjectSource subjectSource) {
+        next.setSubjectSource(subjectSource);
+    }
+
+    @Override
+    public void unsetSubjectSource() {
+        next.unsetSubjectSource();
+    }
+
     public int getPartitionCount() {
         return 1;
     }

Copied: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/BaseConnectionManager.java (from r1071447, geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/BaseConnectionManager.java?p2=geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/BaseConnectionManager.java&p1=geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java&r1=1071447&r2=1074024&rev=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/AbstractConnectionManager.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/BaseConnectionManager.java Thu Feb 24 02:25:51 2011
@@ -23,27 +23,31 @@ import javax.resource.spi.ConnectionRequ
 import javax.resource.spi.LazyAssociatableConnectionManager;
 import javax.resource.spi.ManagedConnectionFactory;
 
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.felix.scr.annotations.Service;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport;
 import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
 
 /**
  * @version $Rev$ $Date$
  */
-public abstract class AbstractConnectionManager implements ConnectionManagerContainer, ConnectionManager, LazyAssociatableConnectionManager, PoolingAttributes {
-    protected transient final Interceptors interceptors;
-    private transient final RecoverableTransactionManager transactionManager;
-    private transient final ManagedConnectionFactory managedConnectionFactory;
-    private final String name;
+
+public class BaseConnectionManager implements ConnectionManagerContainer, ConnectionManager, LazyAssociatableConnectionManager, PoolingAttributes {
+    protected transient Interceptors interceptors;
+    private transient ManagedConnectionFactory managedConnectionFactory;
+
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY, policy = ReferencePolicy.DYNAMIC, target = "(service.ranking>=0)")
+    private transient RecoverableTransactionManager transactionManager;
+    private String name;
 
     //default constructor to support externalizable subclasses
-    public AbstractConnectionManager() {
-        interceptors = null;
-        transactionManager = null;
-        managedConnectionFactory = null;
-        this.name = null;
+    public BaseConnectionManager() {
     }
 
-    public AbstractConnectionManager(Interceptors interceptors, RecoverableTransactionManager transactionManager, ManagedConnectionFactory mcf, String name) {
+    public BaseConnectionManager(Interceptors interceptors, RecoverableTransactionManager transactionManager, ManagedConnectionFactory mcf, String name) {
         this.interceptors = interceptors;
         this.transactionManager = transactionManager;
         this.managedConnectionFactory = mcf;
@@ -54,14 +58,6 @@ public abstract class AbstractConnection
         return managedConnectionFactory.createConnectionFactory(this);
     }
 
-    protected ConnectionManager getConnectionManager() {
-        return this;
-    }
-
-    public ManagedConnectionFactory getManagedConnectionFactory() {
-        return managedConnectionFactory;
-    }
-
     public void doRecovery() {
         if (!getIsRecoverable()) {
             return;
@@ -114,6 +110,74 @@ public abstract class AbstractConnection
         return getStack();
     }
 
+    public Interceptors getInterceptors() {
+        return interceptors;
+    }
+
+    public void setInterceptors(Interceptors interceptors) {
+        this.interceptors = interceptors;
+        checkRecovery();
+    }
+
+    public void unsetInterceptors(Interceptors interceptors) {
+        this.interceptors = null;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+        checkRecovery();
+    }
+
+    public RecoverableTransactionManager getTransactionManager() {
+        return transactionManager;
+    }
+
+    public void setTransactionManager(RecoverableTransactionManager transactionManager) {
+        this.transactionManager = transactionManager;
+        checkRecovery();
+    }
+
+    public void unsetTransactionManager(RecoverableTransactionManager transactionManager) {
+        this.transactionManager = null;
+    }
+
+
+    public ManagedConnectionFactory getManagedConnectionFactory() {
+        return managedConnectionFactory;
+    }
+
+    public void setManagedConnectionFactory(ManagedConnectionFactory managedConnectionFactory) {
+        this.managedConnectionFactory = managedConnectionFactory;
+        checkRecovery();
+    }
+
+    public void unsetManagedConnectionFactory(ManagedConnectionFactory managedConnectionFactory) {
+        this.managedConnectionFactory = null;
+    }
+
+    private void checkRecovery() {
+        if (interceptors != null) {
+            interceptors.getStack().setTransactionManager(transactionManager);
+        }
+        if (isComplete()) {
+            transactionManager.registerNamedXAResourceFactory(new OutboundNamedXAResourceFactory(name, getRecoveryStack(), managedConnectionFactory));
+        }
+    }
+
+    private void unregister() {
+        if (isComplete()) {
+            transactionManager.unregisterNamedXAResourceFactory(name);
+        }
+    }
+
+    private boolean isComplete() {
+        return name != null && transactionManager != null && interceptors != null && managedConnectionFactory != null && getIsRecoverable();
+    }
+
     //statistics
 
     public int getPartitionCount() {
@@ -185,10 +249,6 @@ public abstract class AbstractConnection
         PoolingSupport getPoolingAttributes();
     }
 
-    public void doStart() throws Exception {
-
-    }
-
     public void doStop() throws Exception {
         if (transactionManager != null) {
             transactionManager.unregisterNamedXAResourceFactory(name);
@@ -196,10 +256,4 @@ public abstract class AbstractConnection
         interceptors.getStack().destroy();
     }
 
-    public void doFail() {
-        if (transactionManager != null) {
-            transactionManager.unregisterNamedXAResourceFactory(name);
-        }
-        interceptors.getStack().destroy();
-    }
 }

Propchange: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/BaseConnectionManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/BaseConnectionManager.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/BaseConnectionManager.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionHandleInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionHandleInterceptor.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionHandleInterceptor.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionHandleInterceptor.java Thu Feb 24 02:25:51 2011
@@ -18,6 +18,8 @@
 package org.apache.geronimo.connector.outbound;
 
 import javax.resource.ResourceException;
+import javax.transaction.TransactionManager;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
 
 /**
  * ConnectionHandleInterceptor.java
@@ -39,6 +41,7 @@ public class ConnectionHandleInterceptor
      * @param connectionInfo
      * @throws ResourceException
      */
+    @Override
     public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
         next.getConnection(connectionInfo);
         ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
@@ -63,6 +66,7 @@ public class ConnectionHandleInterceptor
      * @param connectionInfo
      * @param connectionReturnAction
      */
+    @Override
     public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) {
         if (connectionInfo.getConnectionHandle() != null) {
             connectionInfo.getManagedConnectionInfo().removeConnectionHandle(
@@ -71,10 +75,12 @@ public class ConnectionHandleInterceptor
         next.returnConnection(connectionInfo, connectionReturnAction);
     }
 
+    @Override
     public void destroy() {
         next.destroy();
     }
 
+    @Override
     public void info(StringBuilder s) {
         s.append(getClass().getName()).append("\n");
         if (next == null) {
@@ -83,4 +89,34 @@ public class ConnectionHandleInterceptor
             next.info(s);
         }
     }
+
+    @Override
+    public void setConnectionTracker(ConnectionTracker connectionTracker) {
+        next.setConnectionTracker(connectionTracker);
+    }
+
+    @Override
+    public void unsetConnectionTracker() {
+        next.unsetConnectionTracker();
+    }
+
+    @Override
+    public void setTransactionManager(TransactionManager transactionManager) {
+        next.setTransactionManager(transactionManager);
+    }
+
+    @Override
+    public void unsetTransactionManager() {
+        next.unsetTransactionManager();
+    }
+
+    @Override
+    public void setSubjectSource(SubjectSource subjectSource) {
+        next.setSubjectSource(subjectSource);
+    }
+
+    @Override
+    public void unsetSubjectSource() {
+        next.unsetSubjectSource();
+    }
 }

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionInterceptor.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionInterceptor.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionInterceptor.java Thu Feb 24 02:25:51 2011
@@ -18,6 +18,8 @@
 package org.apache.geronimo.connector.outbound;
 
 import javax.resource.ResourceException;
+import javax.transaction.TransactionManager;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
 
 /**
  * ConnectionInterceptor is the interface implemented by
@@ -38,4 +40,13 @@ public interface ConnectionInterceptor {
 
     void info(StringBuilder s);
 
+    void setConnectionTracker(ConnectionTracker connectionTracker);
+    void unsetConnectionTracker();
+
+    void setTransactionManager(TransactionManager transactionManager);
+    void unsetTransactionManager();
+
+    void setSubjectSource(SubjectSource subjectSource);
+    void unsetSubjectSource();
+
 } // ConnectionInterceptor

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java Thu Feb 24 02:25:51 2011
@@ -19,10 +19,12 @@ package org.apache.geronimo.connector.ou
 
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.concurrent.atomic.AtomicReference;
 
 import javax.resource.ResourceException;
 import javax.resource.spi.DissociatableManagedConnection;
 import javax.resource.spi.ManagedConnection;
+import javax.transaction.TransactionManager;
 
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
 
@@ -40,7 +42,7 @@ public class ConnectionTrackingIntercept
 
     private final ConnectionInterceptor next;
     private final String key;
-    private final ConnectionTracker connectionTracker;
+    private final AtomicReference<ConnectionTracker> connectionTracker = new AtomicReference<ConnectionTracker>();
 
     public ConnectionTrackingInterceptor(
             final ConnectionInterceptor next,
@@ -49,7 +51,7 @@ public class ConnectionTrackingIntercept
             ) {
         this.next = next;
         this.key = key;
-        this.connectionTracker = connectionTracker;
+        this.connectionTracker.set(connectionTracker);
     }
 
     /**
@@ -62,18 +64,27 @@ public class ConnectionTrackingIntercept
      * @throws ResourceException
      */
     public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
-        connectionTracker.setEnvironment(connectionInfo, key);
-        next.getConnection(connectionInfo);
-        connectionTracker.handleObtained(this, connectionInfo, false);
+        boolean reassociate = false;
+        doGetConnection(connectionInfo, reassociate);
     }
 
     /**
      * Called when a proxied connection which has been released need to be reassociated with a real connection.
      */
     public void reassociateConnection(ConnectionInfo connectionInfo) throws ResourceException {
-        connectionTracker.setEnvironment(connectionInfo, key);
-        next.getConnection(connectionInfo);
-        connectionTracker.handleObtained(this, connectionInfo, true);
+        boolean reassociate = true;
+        doGetConnection(connectionInfo, reassociate);
+    }
+
+    private void doGetConnection(ConnectionInfo connectionInfo, boolean reassociate) throws ResourceException {
+        ConnectionTracker connectionTracker = this.connectionTracker.get();
+        if (connectionTracker != null) {
+            connectionTracker.setEnvironment(connectionInfo, key);
+            next.getConnection(connectionInfo);
+            connectionTracker.handleObtained(this, connectionInfo, reassociate);
+        } else {
+            next.getConnection(connectionInfo);
+        }
     }
 
     /**
@@ -87,7 +98,10 @@ public class ConnectionTrackingIntercept
     public void returnConnection(
             ConnectionInfo connectionInfo,
             ConnectionReturnAction connectionReturnAction) {
-        connectionTracker.handleReleased(this, connectionInfo, connectionReturnAction);
+        ConnectionTracker connectionTracker = this.connectionTracker.get();
+        if (connectionTracker != null) {
+            connectionTracker.handleReleased(this, connectionInfo, connectionReturnAction);
+        }
         next.returnConnection(connectionInfo, connectionReturnAction);
     }
 
@@ -133,4 +147,36 @@ public class ConnectionTrackingIntercept
         }
     }
 
+    @Override
+    public void setConnectionTracker(ConnectionTracker connectionTracker) {
+        this.connectionTracker.set(connectionTracker);
+        next.setConnectionTracker(connectionTracker);
+    }
+
+    @Override
+    public void unsetConnectionTracker() {
+        this.connectionTracker.set(null);
+        next.unsetConnectionTracker();
+    }
+
+    @Override
+    public void setTransactionManager(TransactionManager transactionManager) {
+        next.setTransactionManager(transactionManager);
+    }
+
+    @Override
+    public void unsetTransactionManager() {
+        next.unsetTransactionManager();
+    }
+
+    @Override
+    public void setSubjectSource(SubjectSource subjectSource) {
+        next.setSubjectSource(subjectSource);
+    }
+
+    @Override
+    public void unsetSubjectSource() {
+        next.unsetSubjectSource();
+    }
+
 }

Added: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/DSFactoryConnectionManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/DSFactoryConnectionManager.java?rev=1074024&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/DSFactoryConnectionManager.java (added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/DSFactoryConnectionManager.java Thu Feb 24 02:25:51 2011
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.connector.outbound;
+
+import javax.resource.spi.ManagedConnectionFactory;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Modified;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+@Component(metatype = true, factory = "org.apache.geronimo.connector.outbound.DSFactoryConnectionManager")
+@Service
+@Properties({@Property(name = "transactionManager.target",
+                value = "(service.ranking>=0)"),
+        @Property(name = "connectionTracker.target",
+                value = "(service.ranking>=0)"),
+        @Property(name = "subjectSource.target",
+                value = "(service.ranking>=0)")})
+public class DSFactoryConnectionManager extends BaseConnectionManager {
+
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY, policy = ReferencePolicy.DYNAMIC, target = "(service.ranking>=0)")
+    private transient ConnectionTracker connectionTracker;
+
+    @Reference(cardinality = ReferenceCardinality.OPTIONAL_UNARY, policy = ReferencePolicy.DYNAMIC, target = "(service.ranking>=0)")
+    private transient SubjectSource subjectSource;
+
+    public static final String INTERCEPTORS = "interceptors";
+    public static final String MCF = "managedconnectionfactory";
+    public static final String NAME = "name";
+
+    @Activate
+    public void activate(ComponentContext componentContext) {
+        setName((String) componentContext.getProperties().get(NAME));
+        setManagedConnectionFactory((ManagedConnectionFactory) componentContext.getProperties().get(MCF));
+        setInterceptors((Interceptors) componentContext.getProperties().get(INTERCEPTORS));
+        if (connectionTracker != null) {
+            checkConnectionTracker();
+        }
+        if (subjectSource != null) {
+            checkSubjectSource();
+        }
+    }
+
+    @Deactivate
+    public void deactivate(ComponentContext componentContext) {
+
+    }
+
+    @Modified
+    public void modified(ComponentContext componentContext) {
+
+    }
+
+    public void setConnectionTracker(ConnectionTracker connectionTracker) {
+        this.connectionTracker = connectionTracker;
+        checkConnectionTracker();
+    }
+
+    public void unsetConnectionTracker(ConnectionTracker connectionTracker) {
+        if (this.connectionTracker == connectionTracker) {
+            this.connectionTracker = null;
+            checkConnectionTracker();
+        }
+    }
+
+    public void setSubjectSource(SubjectSource subjectSource) {
+        this.subjectSource = subjectSource;
+        checkSubjectSource();
+    }
+
+    public void unsetSubjectSource(SubjectSource subjectSource) {
+        if (this.subjectSource == subjectSource) {
+            this.subjectSource = null;
+            checkSubjectSource();
+        }
+    }
+
+    private void checkConnectionTracker() {
+        if (interceptors != null) {
+            interceptors.getStack().setConnectionTracker(connectionTracker);
+        }
+    }
+
+    private void checkSubjectSource() {
+        if (interceptors != null) {
+            interceptors.getStack().setSubjectSource(subjectSource);
+        }
+    }
+
+}

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/GenericConnectionManager.java Thu Feb 24 02:25:51 2011
@@ -18,14 +18,9 @@
 package org.apache.geronimo.connector.outbound;
 
 import javax.resource.spi.ManagedConnectionFactory;
-import javax.transaction.TransactionManager;
 
-import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions;
-import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoTransactions;
-import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PartitionedPool;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport;
-import org.apache.geronimo.connector.outbound.connectionmanagerconfig.XATransactions;
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
 import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
 import org.slf4j.Logger;
@@ -37,7 +32,7 @@ import org.slf4j.LoggerFactory;
  *
  * @version $Rev$ $Date$
  */
-public class GenericConnectionManager extends AbstractConnectionManager {
+public class GenericConnectionManager extends BaseConnectionManager {
     protected static final Logger log = LoggerFactory.getLogger(GenericConnectionManager.class);
 
     //default constructor to support externalizable subclasses
@@ -67,113 +62,4 @@ public class GenericConnectionManager ex
         super(new InterceptorsImpl(transactionSupport, pooling, subjectSource, name, connectionTracker, transactionManager, mcf, classLoader), transactionManager, mcf, name);
     }
 
-    private static class InterceptorsImpl implements AbstractConnectionManager.Interceptors {
-
-        private final ConnectionInterceptor stack;
-        private final ConnectionInterceptor recoveryStack;
-        private final PoolingSupport poolingSupport;
-
-        /**
-         * Order of constructed interceptors:
-         * <p/>
-         * ConnectionTrackingInterceptor (connectionTracker != null)
-         * TCCLInterceptor
-         * ConnectionHandleInterceptor
-         * TransactionCachingInterceptor (useTransactions & useTransactionCaching)
-         * TransactionEnlistingInterceptor (useTransactions)
-         * SubjectInterceptor (realmBridge != null)
-         * SinglePoolConnectionInterceptor or MultiPoolConnectionInterceptor
-         * LocalXAResourceInsertionInterceptor or XAResourceInsertionInterceptor (useTransactions (&localTransactions))
-         * MCFConnectionInterceptor
-         */
-        public InterceptorsImpl(TransactionSupport transactionSupport,
-                                PoolingSupport pooling,
-                                SubjectSource subjectSource,
-                                String name,
-                                ConnectionTracker connectionTracker,
-                                TransactionManager transactionManager,
-                                ManagedConnectionFactory mcf, ClassLoader classLoader) {
-            //check for consistency between attributes
-            if (subjectSource == null && pooling instanceof PartitionedPool && ((PartitionedPool) pooling).isPartitionBySubject()) {
-                throw new IllegalStateException("To use Subject in pooling, you need a SecurityDomain");
-            }
-
-            if (mcf == null) {
-                throw new NullPointerException("No ManagedConnectionFactory supplied for " + name);
-            }
-            if (mcf instanceof javax.resource.spi.TransactionSupport) {
-                javax.resource.spi.TransactionSupport txSupport = (javax.resource.spi.TransactionSupport)mcf;
-                javax.resource.spi.TransactionSupport.TransactionSupportLevel txSupportLevel = txSupport.getTransactionSupport();
-                log.info("Runtime TransactionSupport level: " + txSupportLevel);
-                if (txSupportLevel != null) {
-                    if (txSupportLevel == javax.resource.spi.TransactionSupport.TransactionSupportLevel.NoTransaction) {
-                        transactionSupport = NoTransactions.INSTANCE;
-                    } else if (txSupportLevel == javax.resource.spi.TransactionSupport.TransactionSupportLevel.LocalTransaction) {
-                        if (transactionSupport != NoTransactions.INSTANCE) {
-                            transactionSupport = LocalTransactions.INSTANCE;
-                        }
-                    } else {
-                        if (transactionSupport != NoTransactions.INSTANCE && transactionSupport != LocalTransactions.INSTANCE) {
-                            transactionSupport = new XATransactions(true, false);
-                        }
-                    }
-                }
-            } else {
-                log.info("No runtime TransactionSupport");
-            }
-
-            //Set up the interceptor stack
-            MCFConnectionInterceptor tail = new MCFConnectionInterceptor();
-            ConnectionInterceptor stack = tail;
-
-            stack = transactionSupport.addXAResourceInsertionInterceptor(stack, name);
-            stack = pooling.addPoolingInterceptors(stack);
-            if (log.isTraceEnabled()) {
-                log.trace("Connection Manager " + name + " installed pool " + stack);
-            }
-
-            this.poolingSupport = pooling;
-            stack = transactionSupport.addTransactionInterceptors(stack, transactionManager);
-
-            if (subjectSource != null) {
-                stack = new SubjectInterceptor(stack, subjectSource);
-            }
-
-            if (transactionSupport.isRecoverable()) {
-        	this.recoveryStack = new TCCLInterceptor(stack, classLoader);
-            } else {
-        	this.recoveryStack = null;
-            }
-            
-
-            stack = new ConnectionHandleInterceptor(stack);
-            stack = new TCCLInterceptor(stack, classLoader);
-            if (connectionTracker != null) {
-                stack = new ConnectionTrackingInterceptor(stack,
-                        name,
-                        connectionTracker);
-            }
-            tail.setStack(stack);
-            this.stack = stack;
-            if (log.isDebugEnabled()) {
-                StringBuilder s = new StringBuilder("ConnectionManager Interceptor stack;\n");
-                stack.info(s);
-                log.debug(s.toString());
-            }
-        }
-
-        public ConnectionInterceptor getStack() {
-            return stack;
-        }
-
-        public ConnectionInterceptor getRecoveryStack() {
-            return recoveryStack;
-        }
-        
-        public PoolingSupport getPoolingAttributes() {
-            return poolingSupport;
-        }
-
-    }
-
 }

Added: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/InterceptorsImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/InterceptorsImpl.java?rev=1074024&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/InterceptorsImpl.java (added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/InterceptorsImpl.java Thu Feb 24 02:25:51 2011
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.geronimo.connector.outbound;
+
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.transaction.TransactionManager;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoTransactions;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PartitionedPool;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.XATransactions;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
+
+/**
+* @version $Rev:$ $Date:$
+*/
+public class InterceptorsImpl implements BaseConnectionManager.Interceptors {
+
+    private final ConnectionInterceptor stack;
+    private final ConnectionInterceptor recoveryStack;
+    private final PoolingSupport poolingSupport;
+
+    /**
+     * Order of constructed interceptors:
+     * <p/>
+     * ConnectionTrackingInterceptor (connectionTracker != null)
+     * TCCLInterceptor
+     * ConnectionHandleInterceptor
+     * TransactionCachingInterceptor (useTransactions & useTransactionCaching)
+     * TransactionEnlistingInterceptor (useTransactions)
+     * SubjectInterceptor (realmBridge != null)
+     * SinglePoolConnectionInterceptor or MultiPoolConnectionInterceptor
+     * LocalXAResourceInsertionInterceptor or XAResourceInsertionInterceptor (useTransactions (&localTransactions))
+     * MCFConnectionInterceptor
+     */
+    public InterceptorsImpl(TransactionSupport transactionSupport,
+                            PoolingSupport pooling,
+                            SubjectSource subjectSource,
+                            String name,
+                            ConnectionTracker connectionTracker,
+                            TransactionManager transactionManager,
+                            ManagedConnectionFactory mcf, ClassLoader classLoader) {
+        //check for consistency between attributes
+        if (subjectSource == null && pooling instanceof PartitionedPool && ((PartitionedPool) pooling).isPartitionBySubject()) {
+            throw new IllegalStateException("To use Subject in pooling, you need a SecurityDomain");
+        }
+
+        if (mcf == null) {
+            throw new NullPointerException("No ManagedConnectionFactory supplied for " + name);
+        }
+        if (mcf instanceof javax.resource.spi.TransactionSupport) {
+            javax.resource.spi.TransactionSupport txSupport = (javax.resource.spi.TransactionSupport)mcf;
+            javax.resource.spi.TransactionSupport.TransactionSupportLevel txSupportLevel = txSupport.getTransactionSupport();
+            GenericConnectionManager.log.info("Runtime TransactionSupport level: " + txSupportLevel);
+            if (txSupportLevel != null) {
+                if (txSupportLevel == javax.resource.spi.TransactionSupport.TransactionSupportLevel.NoTransaction) {
+                    transactionSupport = NoTransactions.INSTANCE;
+                } else if (txSupportLevel == javax.resource.spi.TransactionSupport.TransactionSupportLevel.LocalTransaction) {
+                    if (transactionSupport != NoTransactions.INSTANCE) {
+                        transactionSupport = LocalTransactions.INSTANCE;
+                    }
+                } else {
+                    if (transactionSupport != NoTransactions.INSTANCE && transactionSupport != LocalTransactions.INSTANCE) {
+                        transactionSupport = new XATransactions(true, false);
+                    }
+                }
+            }
+        } else {
+            GenericConnectionManager.log.info("No runtime TransactionSupport");
+        }
+
+        //Set up the interceptor stack
+        MCFConnectionInterceptor tail = new MCFConnectionInterceptor();
+        ConnectionInterceptor stack = tail;
+
+        stack = transactionSupport.addXAResourceInsertionInterceptor(stack, name);
+        stack = pooling.addPoolingInterceptors(stack);
+        if (GenericConnectionManager.log.isTraceEnabled()) {
+            GenericConnectionManager.log.trace("Connection Manager " + name + " installed pool " + stack);
+        }
+
+        this.poolingSupport = pooling;
+        stack = transactionSupport.addTransactionInterceptors(stack, transactionManager);
+
+        if (subjectSource != null) {
+            stack = new SubjectInterceptor(stack, subjectSource);
+        }
+
+        if (transactionSupport.isRecoverable()) {
+        this.recoveryStack = new TCCLInterceptor(stack, classLoader);
+        } else {
+        this.recoveryStack = null;
+        }
+
+
+        stack = new ConnectionHandleInterceptor(stack);
+        stack = new TCCLInterceptor(stack, classLoader);
+        if (connectionTracker != null) {
+            stack = new ConnectionTrackingInterceptor(stack,
+                    name,
+                    connectionTracker);
+        }
+        tail.setStack(stack);
+        this.stack = stack;
+        if (GenericConnectionManager.log.isDebugEnabled()) {
+            StringBuilder s = new StringBuilder("ConnectionManager Interceptor stack;\n");
+            stack.info(s);
+            GenericConnectionManager.log.debug(s.toString());
+        }
+    }
+
+    public ConnectionInterceptor getStack() {
+        return stack;
+    }
+
+    public ConnectionInterceptor getRecoveryStack() {
+        return recoveryStack;
+    }
+
+    public PoolingSupport getPoolingAttributes() {
+        return poolingSupport;
+    }
+
+}

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/LocalXAResourceInsertionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/LocalXAResourceInsertionInterceptor.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/LocalXAResourceInsertionInterceptor.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/LocalXAResourceInsertionInterceptor.java Thu Feb 24 02:25:51 2011
@@ -18,6 +18,8 @@
 package org.apache.geronimo.connector.outbound;
 
 import javax.resource.ResourceException;
+import javax.transaction.TransactionManager;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
 
 /**
  * LocalXAResourceInsertionInterceptor.java
@@ -37,6 +39,7 @@ public class LocalXAResourceInsertionInt
         this.name = name;
     }
 
+    @Override
     public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
         next.getConnection(connectionInfo);
         ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
@@ -44,16 +47,19 @@ public class LocalXAResourceInsertionInt
                 new LocalXAResource(mci.getManagedConnection().getLocalTransaction(), name));
     }
 
+    @Override
     public void returnConnection(
             ConnectionInfo connectionInfo,
             ConnectionReturnAction connectionReturnAction) {
         next.returnConnection(connectionInfo, connectionReturnAction);
     }
 
+    @Override
     public void destroy() {
         next.destroy();        
     }
 
+    @Override
     public void info(StringBuilder s) {
         s.append(getClass().getName()).append("[name=").append(name).append("]\n");
         if (next == null) {
@@ -63,4 +69,34 @@ public class LocalXAResourceInsertionInt
         }
     }
 
+    @Override
+    public void setConnectionTracker(ConnectionTracker connectionTracker) {
+        next.setConnectionTracker(connectionTracker);
+    }
+
+    @Override
+    public void unsetConnectionTracker() {
+        next.unsetConnectionTracker();
+    }
+
+    @Override
+    public void setTransactionManager(TransactionManager transactionManager) {
+        next.setTransactionManager(transactionManager);
+    }
+
+    @Override
+    public void unsetTransactionManager() {
+        next.unsetTransactionManager();
+    }
+
+    @Override
+    public void setSubjectSource(SubjectSource subjectSource) {
+        next.setSubjectSource(subjectSource);
+    }
+
+    @Override
+    public void unsetSubjectSource() {
+        next.unsetSubjectSource();
+    }
+
 }

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/MCFConnectionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/MCFConnectionInterceptor.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/MCFConnectionInterceptor.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/MCFConnectionInterceptor.java Thu Feb 24 02:25:51 2011
@@ -19,7 +19,9 @@ package org.apache.geronimo.connector.ou
 
 import javax.resource.ResourceException;
 import javax.resource.spi.ManagedConnection;
+import javax.transaction.TransactionManager;
 
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -38,6 +40,7 @@ public class MCFConnectionInterceptor im
     public MCFConnectionInterceptor() {
     }
 
+    @Override
     public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
         ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
         if (mci.getManagedConnection() != null) {
@@ -58,6 +61,7 @@ public class MCFConnectionInterceptor im
         }
     }
 
+    @Override
     public void returnConnection(
             ConnectionInfo connectionInfo,
             ConnectionReturnAction connectionReturnAction) {
@@ -74,6 +78,7 @@ public class MCFConnectionInterceptor im
         }
     }
 
+    @Override
     public void destroy() {
         // MCF is the "tail" of the stack. So, we're all done...
     }
@@ -82,9 +87,33 @@ public class MCFConnectionInterceptor im
         this.stack = stack;
     }
 
+    @Override
     public void info(StringBuilder s) {
         s.append(getClass().getName()).append("[stack=").append(stack).append("]\n");
         s.append("<end>");
     }
 
+    @Override
+    public void setConnectionTracker(ConnectionTracker connectionTracker) {
+    }
+
+    @Override
+    public void unsetConnectionTracker() {
+    }
+
+    @Override
+    public void setTransactionManager(TransactionManager transactionManager) {
+    }
+
+    @Override
+    public void unsetTransactionManager() {
+    }
+
+    @Override
+    public void setSubjectSource(SubjectSource subjectSource) {
+    }
+
+    @Override
+    public void unsetSubjectSource() {
+    }
 }

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/MultiPoolConnectionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/MultiPoolConnectionInterceptor.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/MultiPoolConnectionInterceptor.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/MultiPoolConnectionInterceptor.java Thu Feb 24 02:25:51 2011
@@ -23,8 +23,10 @@ import java.util.Map;
 import javax.resource.ResourceException;
 import javax.resource.spi.ConnectionRequestInfo;
 import javax.security.auth.Subject;
+import javax.transaction.TransactionManager;
 
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
 
 /**
  * MultiPoolConnectionInterceptor maps the provided subject and connection request info to a
@@ -60,6 +62,7 @@ public class MultiPoolConnectionIntercep
         this.useCRI = useCRI;
     }
 
+    @Override
     public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
         ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
         SubjectCRIKey key =
@@ -82,6 +85,7 @@ public class MultiPoolConnectionIntercep
     }
 
     // let underlying pools handle destroyed processing...
+    @Override
     public void returnConnection(
             ConnectionInfo connectionInfo,
             ConnectionReturnAction connectionReturnAction) {
@@ -102,14 +106,17 @@ public class MultiPoolConnectionIntercep
         next.destroy();
     }
     
+    @Override
     public int getPartitionCount() {
         return pools.size();
     }
 
+    @Override
     public int getPartitionMaxSize() {
         return singlePoolFactory.getPartitionMaxSize();
     }
 
+    @Override
     public void setPartitionMaxSize(int maxSize) throws InterruptedException {
         singlePoolFactory.setPartitionMaxSize(maxSize);
         for (PoolingAttributes poolingAttributes : pools.values()) {
@@ -117,10 +124,12 @@ public class MultiPoolConnectionIntercep
         }
     }
 
+    @Override
     public int getPartitionMinSize() {
         return singlePoolFactory.getPartitionMinSize();
     }
 
+    @Override
     public void setPartitionMinSize(int minSize) {
         singlePoolFactory.setPartitionMinSize(minSize);
         for (PoolingAttributes poolingAttributes : pools.values()) {
@@ -128,6 +137,7 @@ public class MultiPoolConnectionIntercep
         }
     }
 
+    @Override
     public int getIdleConnectionCount() {
         int count = 0;
         for (PoolingAttributes poolingAttributes : pools.values()) {
@@ -136,6 +146,7 @@ public class MultiPoolConnectionIntercep
         return count;
     }
 
+    @Override
     public int getConnectionCount() {
         int count = 0;
         for (PoolingAttributes poolingAttributes : pools.values()) {
@@ -144,10 +155,12 @@ public class MultiPoolConnectionIntercep
         return count;
     }
 
+    @Override
     public int getBlockingTimeoutMilliseconds() {
         return singlePoolFactory.getBlockingTimeoutMilliseconds();
     }
 
+    @Override
     public void setBlockingTimeoutMilliseconds(int timeoutMilliseconds) {
         singlePoolFactory.setBlockingTimeoutMilliseconds(timeoutMilliseconds);
         for (PoolingAttributes poolingAttributes : pools.values()) {
@@ -155,10 +168,12 @@ public class MultiPoolConnectionIntercep
         }
     }
 
+    @Override
     public int getIdleTimeoutMinutes() {
         return singlePoolFactory.getIdleTimeoutMinutes();
     }
 
+    @Override
     public void setIdleTimeoutMinutes(int idleTimeoutMinutes) {
         singlePoolFactory.setIdleTimeoutMinutes(idleTimeoutMinutes);
         for (PoolingAttributes poolingAttributes : pools.values()) {
@@ -166,11 +181,41 @@ public class MultiPoolConnectionIntercep
         }
     }
 
+    @Override
     public void info(StringBuilder s) {
         s.append(getClass().getName()).append("[useSubject=").append(useSubject).append(",useCRI=").append(useCRI).append(",pool count=").append(pools.size()).append("]\n");
         next.info(s);
     }
 
+    @Override
+    public void setConnectionTracker(ConnectionTracker connectionTracker) {
+        next.setConnectionTracker(connectionTracker);
+    }
+
+    @Override
+    public void unsetConnectionTracker() {
+        next.unsetConnectionTracker();
+    }
+
+    @Override
+    public void setTransactionManager(TransactionManager transactionManager) {
+        next.setTransactionManager(transactionManager);
+    }
+
+    @Override
+    public void unsetTransactionManager() {
+        next.unsetTransactionManager();
+    }
+
+    @Override
+    public void setSubjectSource(SubjectSource subjectSource) {
+        next.setSubjectSource(subjectSource);
+    }
+
+    @Override
+    public void unsetSubjectSource() {
+        next.unsetSubjectSource();
+    }
 
     static class SubjectCRIKey {
         private final Subject subject;

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SubjectInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SubjectInterceptor.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SubjectInterceptor.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/SubjectInterceptor.java Thu Feb 24 02:25:51 2011
@@ -17,9 +17,13 @@
 
 package org.apache.geronimo.connector.outbound;
 
+import java.util.concurrent.atomic.AtomicReference;
+
 import javax.resource.ResourceException;
 import javax.resource.spi.ApplicationServerInternalException;
 import javax.security.auth.Subject;
+import javax.transaction.TransactionManager;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
 
 /**
  * SubjectInterceptor.java This is installed only when the plan includes a container-managed-security element.
@@ -32,16 +36,21 @@ import javax.security.auth.Subject;
 public class SubjectInterceptor implements ConnectionInterceptor {
 
     private final ConnectionInterceptor next;
-    private final SubjectSource subjectSource;
+    private final AtomicReference<SubjectSource> subjectSource = new AtomicReference<SubjectSource>();
 
     public SubjectInterceptor(final ConnectionInterceptor next, final SubjectSource subjectSource) {
         this.next = next;
-        this.subjectSource = subjectSource;
+        this.subjectSource.set(subjectSource);
     }
 
+    @Override
     public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
         Subject currentSubject = null;
         if (!connectionInfo.isApplicationManagedSecurity()) {
+            SubjectSource subjectSource = this.subjectSource.get();
+            if (subjectSource == null) {
+                throw new ResourceException("No subject source registered for container managed security");
+            }
             try {
                 currentSubject = subjectSource.getSubject();
             } catch (SecurityException e) {
@@ -89,19 +98,53 @@ public class SubjectInterceptor implemen
         }
     }
 
+    @Override
     public void returnConnection(
             ConnectionInfo connectionInfo,
             ConnectionReturnAction connectionReturnAction) {
         next.returnConnection(connectionInfo, connectionReturnAction);
     }
 
+    @Override
     public void destroy() {
         next.destroy();
     }
 
+    @Override
     public void info(StringBuilder s) {
         s.append(getClass().getName()).append("[subjectSource=").append(subjectSource).append("]\n");
         next.info(s);
     }
 
+    @Override
+    public void setConnectionTracker(ConnectionTracker connectionTracker) {
+        next.setConnectionTracker(connectionTracker);
+    }
+
+    @Override
+    public void unsetConnectionTracker() {
+        next.unsetConnectionTracker();
+    }
+
+    @Override
+    public void setTransactionManager(TransactionManager transactionManager) {
+        next.setTransactionManager(transactionManager);
+    }
+
+    @Override
+    public void unsetTransactionManager() {
+        next.unsetTransactionManager();
+    }
+
+    @Override
+    public void setSubjectSource(SubjectSource subjectSource) {
+        this.subjectSource.set(subjectSource);
+        next.setSubjectSource(subjectSource);
+    }
+
+    @Override
+    public void unsetSubjectSource() {
+        this.subjectSource.set(null);
+        next.unsetSubjectSource();
+    }
 }

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TCCLInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TCCLInterceptor.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TCCLInterceptor.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TCCLInterceptor.java Thu Feb 24 02:25:51 2011
@@ -17,6 +17,8 @@
 package org.apache.geronimo.connector.outbound;
 
 import javax.resource.ResourceException;
+import javax.transaction.TransactionManager;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
 
 /**
  * @version $Rev$ $Date$
@@ -31,6 +33,7 @@ public class TCCLInterceptor implements 
     }
 
 
+    @Override
     public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
         Thread currentThread = Thread.currentThread();
         ClassLoader oldClassLoader = currentThread.getContextClassLoader();
@@ -42,6 +45,7 @@ public class TCCLInterceptor implements 
         }
     }
 
+    @Override
     public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) {
         Thread currentThread = Thread.currentThread();
         ClassLoader oldClassLoader = currentThread.getContextClassLoader();
@@ -53,13 +57,45 @@ public class TCCLInterceptor implements 
         }
     }
     
+    @Override
     public void destroy() {
         this.next.destroy();
     }
 
+    @Override
     public void info(StringBuilder s) {
         s.append(getClass().getName()).append("[classLoader=").append(classLoader).append("]\n");
         next.info(s);
     }
-    
+
+    @Override
+    public void setConnectionTracker(ConnectionTracker connectionTracker) {
+        next.setConnectionTracker(connectionTracker);
+    }
+
+    @Override
+    public void unsetConnectionTracker() {
+        next.unsetConnectionTracker();
+    }
+
+    @Override
+    public void setTransactionManager(TransactionManager transactionManager) {
+        next.setTransactionManager(transactionManager);
+    }
+
+    @Override
+    public void unsetTransactionManager() {
+        next.unsetTransactionManager();
+    }
+
+    @Override
+    public void setSubjectSource(SubjectSource subjectSource) {
+        next.setSubjectSource(subjectSource);
+    }
+
+    @Override
+    public void unsetSubjectSource() {
+        next.unsetSubjectSource();
+    }
+
 }

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ThreadLocalCachingConnectionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ThreadLocalCachingConnectionInterceptor.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ThreadLocalCachingConnectionInterceptor.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/ThreadLocalCachingConnectionInterceptor.java Thu Feb 24 02:25:51 2011
@@ -20,6 +20,8 @@ package org.apache.geronimo.connector.ou
 import java.util.Collections;
 
 import javax.resource.ResourceException;
+import javax.transaction.TransactionManager;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
 
 /**
  *
@@ -40,6 +42,7 @@ public class ThreadLocalCachingConnectio
     }
 
 
+    @Override
     public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
         if (connectionInfo.isUnshareable()) {
             next.getConnection(connectionInfo);
@@ -71,6 +74,7 @@ public class ThreadLocalCachingConnectio
         connections.set(connectionInfo.getManagedConnectionInfo());
     }
 
+    @Override
     public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) {
         if (connectionReturnAction == ConnectionReturnAction.DESTROY
                 || connectionInfo.isUnshareable()
@@ -82,13 +86,45 @@ public class ThreadLocalCachingConnectio
         }
     }
     
+    @Override
     public void destroy() {
         next.destroy();
     }
 
+    @Override
     public void info(StringBuilder s) {
         s.append(getClass().getName()).append("[matchConnections=").append(matchConnections).append("]\n");
         next.info(s);
     }
-    
+
+    @Override
+    public void setConnectionTracker(ConnectionTracker connectionTracker) {
+        next.setConnectionTracker(connectionTracker);
+    }
+
+    @Override
+    public void unsetConnectionTracker() {
+        next.unsetConnectionTracker();
+    }
+
+    @Override
+    public void setTransactionManager(TransactionManager transactionManager) {
+        next.setTransactionManager(transactionManager);
+    }
+
+    @Override
+    public void unsetTransactionManager() {
+        next.unsetTransactionManager();
+    }
+
+    @Override
+    public void setSubjectSource(SubjectSource subjectSource) {
+        next.setSubjectSource(subjectSource);
+    }
+
+    @Override
+    public void unsetSubjectSource() {
+        next.unsetSubjectSource();
+    }
+
 }

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java?rev=1074024&r1=1074023&r2=1074024&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/TransactionCachingInterceptor.java Thu Feb 24 02:25:51 2011
@@ -19,6 +19,7 @@ package org.apache.geronimo.connector.ou
 
 import java.util.HashSet;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicReference;
 
 import javax.resource.ResourceException;
 import javax.transaction.SystemException;
@@ -27,6 +28,7 @@ import javax.transaction.TransactionMana
 
 import org.apache.geronimo.connector.ConnectionReleaser;
 import org.apache.geronimo.connector.ConnectorTransactionContext;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -54,19 +56,20 @@ public class TransactionCachingIntercept
     protected static Logger log = LoggerFactory.getLogger(TransactionCachingInterceptor.class.getName());
 
     private final ConnectionInterceptor next;
-    private final TransactionManager transactionManager;
+    private final AtomicReference<TransactionManager> transactionManager = new AtomicReference<TransactionManager>();
 
     public TransactionCachingInterceptor(ConnectionInterceptor next, TransactionManager transactionManager) {
         this.next = next;
-        this.transactionManager = transactionManager;
+        this.transactionManager.set(transactionManager);
     }
 
+    @Override
     public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
         //There can be an inactive transaction context when a connection is requested in
         //Synchronization.afterCompletion().
 
         // get the current transaction and status... if there is a problem just assume there is no transaction present
-        Transaction transaction = TxUtil.getTransactionIfActive(transactionManager);
+        Transaction transaction = TxUtil.getTransactionIfActive(transactionManager.get());
         if (transaction != null) {
             ManagedConnectionInfos managedConnectionInfos = ConnectorTransactionContext.get(transaction, this);
             if (connectionInfo.isUnshareable()) {
@@ -110,6 +113,7 @@ public class TransactionCachingIntercept
         }
     }
 
+    @Override
     public void returnConnection(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) {
 
         if (connectionReturnAction == ConnectionReturnAction.DESTROY) {
@@ -121,20 +125,23 @@ public class TransactionCachingIntercept
         }
         Transaction transaction;
         try {
-            transaction = transactionManager.getTransaction();
-            if (transaction != null) {
-                if (TxUtil.isActive(transaction)) {
+            TransactionManager transactionManager = this.transactionManager.get();
+            if (transactionManager != null) {
+                transaction = transactionManager.getTransaction();
+                if (transaction != null) {
+                    if (TxUtil.isActive(transaction)) {
+                        if (log.isTraceEnabled()) {
+                            log.trace("tx active, not returning connection  " + infoString(connectionInfo));
+                        }
+                        return;
+                    }
+                    //We are called from an afterCompletion synchronization.  Remove the MCI from the ManagedConnectionInfos
+                    //so we don't close it twice
+                    ManagedConnectionInfos managedConnectionInfos = ConnectorTransactionContext.get(transaction, this);
+                    managedConnectionInfos.remove(connectionInfo.getManagedConnectionInfo());
                     if (log.isTraceEnabled()) {
-                        log.trace("tx active, not returning connection  " + infoString(connectionInfo));
+                        log.trace("tx ended, return during synchronization afterCompletion " + infoString(connectionInfo));
                     }
-                    return;
-                }
-                //We are called from an afterCompletion synchronization.  Remove the MCI from the ManagedConnectionInfos
-                //so we don't close it twice
-                ManagedConnectionInfos managedConnectionInfos = ConnectorTransactionContext.get(transaction, this);
-                managedConnectionInfos.remove(connectionInfo.getManagedConnectionInfo());
-                if (log.isTraceEnabled()) {
-                    log.trace("tx ended, return during synchronization afterCompletion " + infoString(connectionInfo));
                 }
             }
         } catch (SystemException e) {
@@ -160,10 +167,12 @@ public class TransactionCachingIntercept
         }
     }
 
+    @Override
     public void destroy() {
         next.destroy();
     }
 
+    @Override
     public void afterCompletion(Object stuff) {
         ManagedConnectionInfos managedConnectionInfos = (ManagedConnectionInfos) stuff;
         ManagedConnectionInfo sharedMCI = managedConnectionInfos.getShared();
@@ -191,11 +200,44 @@ public class TransactionCachingIntercept
         return "for tx caching interceptor " + this + " " + connectionInfo;
     }
 
+    @Override
     public void info(StringBuilder s) {
         s.append(getClass().getName()).append("[transactionManager=").append(transactionManager).append("]\n");
         next.info(s);
     }
-    
+
+    @Override
+    public void setConnectionTracker(ConnectionTracker connectionTracker) {
+        next.setConnectionTracker(connectionTracker);
+    }
+
+    @Override
+    public void unsetConnectionTracker() {
+        next.unsetConnectionTracker();
+    }
+
+    @Override
+    public void setTransactionManager(TransactionManager transactionManager) {
+        this.transactionManager.set(transactionManager);
+        next.setTransactionManager(transactionManager);
+    }
+
+    @Override
+    public void unsetTransactionManager() {
+        this.transactionManager.set(null);
+        next.unsetTransactionManager();
+    }
+
+    @Override
+    public void setSubjectSource(SubjectSource subjectSource) {
+        next.setSubjectSource(subjectSource);
+    }
+
+    @Override
+    public void unsetSubjectSource() {
+        next.unsetSubjectSource();
+    }
+
     public static class ManagedConnectionInfos {
         private ManagedConnectionInfo shared;
         private Set<ManagedConnectionInfo> unshared = new HashSet<ManagedConnectionInfo>(1);



Mime
View raw message