geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1071905 - in /geronimo/sandbox/djencks/txmanager: ./ geronimo-connector/ geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/ geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/impl/ geronimo-conn...
Date Fri, 18 Feb 2011 07:26:52 GMT
Author: djencks
Date: Fri Feb 18 07:26:51 2011
New Revision: 1071905

URL: http://svn.apache.org/viewvc?rev=1071905&view=rev
Log:
add a data model, an assembler, and the beginnings of a bundle extender

Added:
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/Assembler.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/
    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/
    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/model/
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/AdminObjectInfo.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/ManagedConnectionFactoryInfo.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/ResourceAdapterInfo.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/ResourceAdapterModuleInfo.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/AssemblerTest.java
Removed:
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/GeronimoTransactionListener.java
Modified:
    geronimo/sandbox/djencks/txmanager/geronimo-connector/pom.xml
    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/connectiontracking/TrackedConnectionAssociator.java
    geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
    geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/DSTransactionManager.java
    geronimo/sandbox/djencks/txmanager/geronimo-txmanager-server/pom.xml
    geronimo/sandbox/djencks/txmanager/pom.xml

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/pom.xml?rev=1071905&r1=1071904&r2=1071905&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/pom.xml (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/pom.xml Fri Feb 18 07:26:51 2011
@@ -76,10 +76,16 @@
             <artifactId>org.osgi.core</artifactId>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
 
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
+            <version>4.8.2</version>
             <scope>test</scope>
         </dependency>
     </dependencies>

Added: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/Assembler.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/Assembler.java?rev=1071905&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/Assembler.java (added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/Assembler.java Fri Feb 18 07:26:51 2011
@@ -0,0 +1,37 @@
+/*
+ * 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.assembler;
+
+import javax.resource.ResourceException;
+import org.apache.geronimo.connector.model.ResourceAdapterModuleInfo;
+import org.apache.geronimo.connector.outbound.SubjectSource;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
+import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
+import org.osgi.framework.Bundle;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public interface Assembler {
+
+    void assemble(ResourceAdapterModuleInfo resourceAdapterModuleInfo, Bundle bundle, ClassLoader threadClassLoader, SubjectSource subjectSource, ConnectionTracker connectionTracker, RecoverableTransactionManager transactionManager) throws ResourceException;
+
+}

Added: 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=1071905&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/AssemblyListener.java (added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/AssemblyListener.java Fri Feb 18 07:26:51 2011
@@ -0,0 +1,39 @@
+/*
+ * 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.assembler;
+
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.ResourceAdapter;
+import org.apache.geronimo.connector.outbound.GenericConnectionManager;
+
+/**
+ * notified when a new object is created so it can be bound appropriately.
+ * @version $Rev:$ $Date:$
+ */
+public interface AssemblyListener {
+
+    void newResourceAdapter(String name, ResourceAdapter resourceAdapter);
+
+    void newAdminObject(String name, String adminObjectInterface, Object adminObject);
+
+    void newManagedConnectionFactory(String name, ManagedConnectionFactory managedConnectionFactory, GenericConnectionManager connectionManager);
+
+}

Added: 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=1071905&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/impl/AssemblerImpl.java (added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/assembler/impl/AssemblerImpl.java Fri Feb 18 07:26:51 2011
@@ -0,0 +1,221 @@
+/*
+ * 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.assembler.impl;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.ResourceAdapter;
+import javax.resource.spi.ResourceAdapterAssociation;
+import org.apache.geronimo.connector.assembler.Assembler;
+import org.apache.geronimo.connector.assembler.AssemblyListener;
+import org.apache.geronimo.connector.model.AdminObjectInfo;
+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.GenericConnectionManager;
+import org.apache.geronimo.connector.outbound.SubjectSource;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.LocalTransactions;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoPool;
+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.SinglePool;
+import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionLog;
+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.osgi.framework.Bundle;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class AssemblerImpl implements Assembler {
+
+    private final List<AssemblyListener> listeners = new ArrayList<AssemblyListener>();
+
+    public void addListener(AssemblyListener listener) {
+        listeners.add(listener);
+    }
+
+    public void removeListener(AssemblyListener listener) {
+        listeners.remove(listener);
+    }
+
+    public void assemble(ResourceAdapterModuleInfo resourceAdapterModuleInfo,
+                         Bundle bundle,
+                         ClassLoader threadClassLoader,
+                         SubjectSource subjectSource,
+                         ConnectionTracker connectionTracker,
+                         RecoverableTransactionManager transactionManager) throws ResourceException {
+        for (ResourceAdapterInfo resourceAdapterInfo: resourceAdapterModuleInfo.resourceAdapterInfos) {
+            assembleResourceAdapter(resourceAdapterInfo, bundle, threadClassLoader, subjectSource, connectionTracker, transactionManager);
+        }
+        for (ManagedConnectionFactoryInfo managedConnectionFactoryInfo: resourceAdapterModuleInfo.managedConnectionFactoryInfos) {
+            assembleManagedConnectionFactory(managedConnectionFactoryInfo, bundle, null, threadClassLoader, subjectSource, connectionTracker, transactionManager);
+        }
+        for (AdminObjectInfo adminObjectInfo: resourceAdapterModuleInfo.adminObjectInfos) {
+            assembleAdminObject(adminObjectInfo, bundle, null);
+        }
+    }
+
+    private void assembleResourceAdapter(ResourceAdapterInfo resourceAdapterInfo, Bundle bundle, ClassLoader threadClassLoader, SubjectSource subjectSource, ConnectionTracker connectionTracker, RecoverableTransactionManager transactionManager) throws ResourceException {
+        ResourceAdapter resourceAdapter = load(ResourceAdapter.class, resourceAdapterInfo.resourceAdapterClass, resourceAdapterInfo.configProperties, bundle);
+        for (ManagedConnectionFactoryInfo managedConnectionFactoryInfo: resourceAdapterInfo.managedConnectionFactoryInfos) {
+            assembleManagedConnectionFactory(managedConnectionFactoryInfo, bundle, resourceAdapter, threadClassLoader, subjectSource, connectionTracker, transactionManager);
+        }
+        for (AdminObjectInfo adminObjectInfo: resourceAdapterInfo.adminObjectInfos) {
+            assembleAdminObject(adminObjectInfo, bundle, resourceAdapter);
+        }
+        for (AssemblyListener listener: listeners) {
+            listener.newResourceAdapter(resourceAdapterInfo.name, resourceAdapter);
+        }
+    }
+
+    private void assembleManagedConnectionFactory(ManagedConnectionFactoryInfo managedConnectionFactoryInfo, Bundle bundle, ResourceAdapter resourceAdapter, ClassLoader threadClassLoader, SubjectSource subjectSource, ConnectionTracker connectionTracker, RecoverableTransactionManager transactionManager) throws ResourceException {
+        ManagedConnectionFactory managedConnectionFactory = load(ManagedConnectionFactory.class, managedConnectionFactoryInfo.managedConnectionFactoryClass, managedConnectionFactoryInfo.configProperties, bundle);
+        if (resourceAdapter != null & managedConnectionFactory instanceof ResourceAdapterAssociation) {
+            ((ResourceAdapterAssociation)managedConnectionFactory).setResourceAdapter(resourceAdapter);
+        }
+        TransactionSupport transactionSupport = transactionSupport(managedConnectionFactoryInfo.transactionSupport);
+        PoolingSupport poolingSupport = poolingSupport(managedConnectionFactoryInfo);
+        GenericConnectionManager connectionManager = new GenericConnectionManager(transactionSupport,
+                poolingSupport,
+                subjectSource,
+                connectionTracker,
+                transactionManager,
+                managedConnectionFactory,
+                managedConnectionFactoryInfo.name,
+                threadClassLoader);
+
+        for (AssemblyListener listener: listeners) {
+            listener.newManagedConnectionFactory(managedConnectionFactoryInfo.name, managedConnectionFactory, connectionManager);
+        }
+    }
+
+    private PoolingSupport poolingSupport(ManagedConnectionFactoryInfo managedConnectionFactoryInfo) throws ResourceException {
+        switch (managedConnectionFactoryInfo.poolCardinality) {
+            case none: return new NoPool();
+            case single:
+                return new SinglePool(managedConnectionFactoryInfo.maxPoolSize,
+                        managedConnectionFactoryInfo.minPoolSize,
+                        managedConnectionFactoryInfo.blockingTimeoutMilliseconds,
+                        managedConnectionFactoryInfo.idleTimeoutMinutes,
+                        managedConnectionFactoryInfo.matchingPolicy == ManagedConnectionFactoryInfo.MatchingPolicy.selectOne,
+                        managedConnectionFactoryInfo.matchingPolicy == ManagedConnectionFactoryInfo.MatchingPolicy.selectAll,
+                        managedConnectionFactoryInfo.matchingPolicy == ManagedConnectionFactoryInfo.MatchingPolicy.selectOneAssumeMatch
+                        );
+            case partitionedBySubject:
+                return new PartitionedPool(managedConnectionFactoryInfo.maxPoolSize,
+                        managedConnectionFactoryInfo.minPoolSize,
+                        managedConnectionFactoryInfo.blockingTimeoutMilliseconds,
+                        managedConnectionFactoryInfo.idleTimeoutMinutes,
+                        managedConnectionFactoryInfo.matchingPolicy == ManagedConnectionFactoryInfo.MatchingPolicy.selectOne,
+                        managedConnectionFactoryInfo.matchingPolicy == ManagedConnectionFactoryInfo.MatchingPolicy.selectAll,
+                        managedConnectionFactoryInfo.matchingPolicy == ManagedConnectionFactoryInfo.MatchingPolicy.selectOneAssumeMatch,
+                        false,
+                        true);
+            case partitionedByConnectionRequestInfo:
+                return new PartitionedPool(managedConnectionFactoryInfo.maxPoolSize,
+                        managedConnectionFactoryInfo.minPoolSize,
+                        managedConnectionFactoryInfo.blockingTimeoutMilliseconds,
+                        managedConnectionFactoryInfo.idleTimeoutMinutes,
+                        managedConnectionFactoryInfo.matchingPolicy == ManagedConnectionFactoryInfo.MatchingPolicy.selectOne,
+                        managedConnectionFactoryInfo.matchingPolicy == ManagedConnectionFactoryInfo.MatchingPolicy.selectAll,
+                        managedConnectionFactoryInfo.matchingPolicy == ManagedConnectionFactoryInfo.MatchingPolicy.selectOneAssumeMatch,
+                        true,
+                        false);
+            case partitionedBySubjectAndConnectionRequestInfo:
+                return new PartitionedPool(managedConnectionFactoryInfo.maxPoolSize,
+                        managedConnectionFactoryInfo.minPoolSize,
+                        managedConnectionFactoryInfo.blockingTimeoutMilliseconds,
+                        managedConnectionFactoryInfo.idleTimeoutMinutes,
+                        managedConnectionFactoryInfo.matchingPolicy == ManagedConnectionFactoryInfo.MatchingPolicy.selectOne,
+                        managedConnectionFactoryInfo.matchingPolicy == ManagedConnectionFactoryInfo.MatchingPolicy.selectAll,
+                        managedConnectionFactoryInfo.matchingPolicy == ManagedConnectionFactoryInfo.MatchingPolicy.selectOneAssumeMatch,
+                        true,
+                        true);
+            default: throw new ResourceException("unknown enum constant " + managedConnectionFactoryInfo.poolCardinality);
+        }
+    }
+
+    private TransactionSupport transactionSupport(ManagedConnectionFactoryInfo.TransactionSupport transactionSupport) throws ResourceException {
+        switch (transactionSupport) {
+            case none: return NoTransactions.INSTANCE;
+            case local: return LocalTransactions.INSTANCE;
+            case xaNoCache: return new XATransactions(false, false);
+            case xaTxCached: return new XATransactions(true, false);
+            case xaThreadCached: return new XATransactions(false, true);
+            case xaTxLog: return TransactionLog.INSTANCE;
+            default: throw new ResourceException("unknown enum constant" + transactionSupport);
+        }
+    }
+
+    private void assembleAdminObject(AdminObjectInfo adminObjectInfo, Bundle bundle, ResourceAdapter resourceAdapter) throws ResourceException {
+        Object adminObject = load(Object.class, adminObjectInfo.adminObjectClass, adminObjectInfo.configProperties, bundle);
+        if (resourceAdapter != null & adminObject instanceof ResourceAdapterAssociation) {
+            ((ResourceAdapterAssociation)adminObject).setResourceAdapter(resourceAdapter);
+        }
+        for (AssemblyListener listener: listeners) {
+            listener.newAdminObject(adminObjectInfo.name, adminObjectInfo.adminObjectInterface, adminObject);
+        }
+    }
+
+    private <T> T load(Class<T> clazz, String className, Map<String, Object> configParams, Bundle bundle) throws ResourceException {
+        try {
+            Class<T> resultClass = bundle.loadClass(className).asSubclass(clazz);
+            T result = resultClass.newInstance();
+            for (Map.Entry<String, Object> entry: configParams.entrySet()) {
+                String propertyName = entry.getKey();
+                Object propertyValue = entry.getValue();
+                Method setter;
+                try {
+                    setter = resultClass.getMethod("set" + propertyName, propertyValue.getClass());
+                } catch (NoSuchMethodException e) {
+                    setter = resultClass.getMethod("set" + swapCase(propertyName), propertyValue.getClass());
+                }
+                setter.invoke(result, propertyValue);
+            }
+            return result;
+        } catch (ClassNotFoundException e) {
+            throw new ResourceException(e);
+        } catch (NoSuchMethodException e) {
+            throw new ResourceException(e);
+        } catch (InstantiationException e) {
+            throw new ResourceException(e);
+        } catch (IllegalAccessException e) {
+            throw new ResourceException(e);
+        } catch (InvocationTargetException e) {
+            throw new ResourceException(e);
+        }
+    }
+
+    private String swapCase(String propertyName) {
+        return propertyName;
+    }
+
+}

Added: 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=1071905&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/ConnectorExtender.java (added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/ConnectorExtender.java Fri Feb 18 07:26:51 2011
@@ -0,0 +1,118 @@
+/*
+ * 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.extender;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+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.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.util.tracker.BundleTracker;
+import org.osgi.util.tracker.BundleTrackerCustomizer;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+
+@Component(immediate = true)
+public class ConnectorExtender {
+
+    public final static String PLAN_LOCATION = "OSGI-INF/connector/plan.ser";
+
+    private BundleTracker bt;
+
+    @Activate
+    public void start(BundleContext bundleContext) {
+        bt = new BundleTracker(bundleContext, Bundle.STARTING | Bundle.ACTIVE, new WebBundleTrackerCustomizer());
+        bt.open();
+
+    }
+
+    @Deactivate
+    public void stop() {
+        bt.close();
+        bt = null;
+    }
+
+    private class WebBundleTrackerCustomizer implements BundleTrackerCustomizer {
+
+        public Object addingBundle(Bundle bundle, BundleEvent event) {
+            if (bundle.getState() == Bundle.ACTIVE) {
+                return checkBundle(bundle);
+            } else if (bundle.getState() == Bundle.STARTING) {
+                String activationPolicyHeader = (String) bundle.getHeaders().get(Constants.BUNDLE_ACTIVATIONPOLICY);
+                if (activationPolicyHeader != null && activationPolicyHeader.startsWith(Constants.ACTIVATION_LAZY)) {
+                    return checkBundle(bundle);
+                }
+            }
+            return null;
+        }
+
+        public void modifiedBundle(Bundle bundle, BundleEvent event, Object arg) {
+        }
+
+        public void removedBundle(Bundle bundle, BundleEvent event, Object arg) {
+            destroyContext((Container) arg);
+        }
+
+    }
+
+    private Container checkBundle(Bundle bundle) {
+        URL url = bundle.getEntry(PLAN_LOCATION);
+        if (url != null) {
+            ResourceAdapterModuleInfo moduleInfo = null;
+            try {
+                ObjectInputStream in = new ObjectInputStream(url.openStream());
+                try {
+                    moduleInfo = (ResourceAdapterModuleInfo) in.readObject();
+                } finally {
+                    in.close();
+                }
+            } catch (ClassNotFoundException e) {
+            } catch (IOException e) {
+            }
+            if (moduleInfo != null) {
+                Container container = new Container(bundle, moduleInfo);
+                //TODO use an executor
+                container.run();
+                return container;
+            }
+
+        }
+        return null;
+    }
+
+    private void destroyContext(Container container) {
+        if (container != null) {
+            container.stop();
+        }
+
+
+    }
+
+}

Added: 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=1071905&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/Container.java (added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/extender/Container.java Fri Feb 18 07:26:51 2011
@@ -0,0 +1,121 @@
+/*
+ * 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.extender;
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+
+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.ConnectionManagerContainer;
+import org.apache.geronimo.connector.outbound.GenericConnectionManager;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class Container implements AssemblyListener, Runnable {
+
+    private final Bundle bundle;
+    private final ResourceAdapterModuleInfo moduleInfo;
+    private final List<ServiceRegistration> serviceRegistrations = new ArrayList<ServiceRegistration>();
+
+
+    public Container(Bundle bundle, ResourceAdapterModuleInfo moduleInfo) {
+        this.bundle = bundle;
+        this.moduleInfo = moduleInfo;
+    }
+
+    @Override
+    public void run() {
+        AssemblerImpl assembler = new AssemblerImpl();
+        assembler.addListener(this);
+        ClassLoader cl = null;
+        try {
+            assembler.assemble(moduleInfo, bundle, cl, null, null, null);
+        } catch (ResourceException e) {
+
+        }
+    }
+
+    public void stop() {
+        for (ServiceRegistration sr: serviceRegistrations) {
+            sr.unregister();
+        }
+    }
+
+    @Override
+    public void newResourceAdapter(String name, ResourceAdapter resourceAdapter) {
+        String[] interfaceNames = new String[] {ResourceAdapter.class.getName(), resourceAdapter.getClass().getName()};
+        registerService(interfaceNames, resourceAdapter);
+    }
+
+    @Override
+    public void newAdminObject(String name, String adminObjectInterface, Object adminObject) {
+        String[] interfaceNames = new String[] {adminObjectInterface};
+        registerService(interfaceNames, adminObject);
+    }
+
+    @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);
+    }
+
+    private void registerService(String[] interfaceNames, Object service) {
+        Dictionary properties = new Hashtable();
+        ServiceRegistration sr = bundle.getBundleContext().registerService(interfaceNames, service, properties);
+        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) {
+                //?
+            }
+        }
+    }
+}

Added: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/AdminObjectInfo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/AdminObjectInfo.java?rev=1071905&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/AdminObjectInfo.java (added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/AdminObjectInfo.java Fri Feb 18 07:26:51 2011
@@ -0,0 +1,37 @@
+/*
+ * 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.model;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class AdminObjectInfo implements Serializable {
+
+    public String name;
+    public String adminObjectInterface;
+    public String adminObjectClass;
+    public final Map<String, Object> configProperties = new HashMap<String, Object>();
+
+}

Added: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/ManagedConnectionFactoryInfo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/ManagedConnectionFactoryInfo.java?rev=1071905&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/ManagedConnectionFactoryInfo.java (added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/ManagedConnectionFactoryInfo.java Fri Feb 18 07:26:51 2011
@@ -0,0 +1,67 @@
+/*
+ * 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.model;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class ManagedConnectionFactoryInfo implements Serializable {
+
+    public static enum TransactionSupport {
+        none,
+        local,
+        xaNoCache,
+        xaTxCached,
+        xaThreadCached,
+        xaTxLog
+    }
+
+    public static enum MatchingPolicy {
+        selectOne,
+        selectAll,
+        selectOneAssumeMatch
+    }
+
+    public static enum PoolCardinality {
+        none,
+        single,
+        partitionedBySubject,
+        partitionedByConnectionRequestInfo,
+        partitionedBySubjectAndConnectionRequestInfo;
+    }
+
+    public String name;
+    public String managedConnectionFactoryClass;
+    public final Map<String, Object> configProperties = new HashMap<String, Object>();
+
+    public int minPoolSize;
+    public int maxPoolSize;
+    public int blockingTimeoutMilliseconds;
+    public int idleTimeoutMinutes;
+    public MatchingPolicy matchingPolicy;
+    public PoolCardinality poolCardinality;
+    public TransactionSupport transactionSupport;
+
+}

Added: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/ResourceAdapterInfo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/ResourceAdapterInfo.java?rev=1071905&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/ResourceAdapterInfo.java (added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/ResourceAdapterInfo.java Fri Feb 18 07:26:51 2011
@@ -0,0 +1,40 @@
+/*
+ * 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.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class ResourceAdapterInfo implements Serializable {
+
+    public String name;
+    public String resourceAdapterClass;
+    public final Map<String, Object> configProperties = new HashMap<String, Object>();
+    public final List<ManagedConnectionFactoryInfo> managedConnectionFactoryInfos = new ArrayList<ManagedConnectionFactoryInfo>();
+    public final List<AdminObjectInfo> adminObjectInfos = new ArrayList<AdminObjectInfo>();
+}

Added: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/ResourceAdapterModuleInfo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/ResourceAdapterModuleInfo.java?rev=1071905&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/ResourceAdapterModuleInfo.java (added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/model/ResourceAdapterModuleInfo.java Fri Feb 18 07:26:51 2011
@@ -0,0 +1,37 @@
+/*
+ * 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.model;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class ResourceAdapterModuleInfo implements Serializable {
+
+    public String name;
+    public final List<ResourceAdapterInfo> resourceAdapterInfos = new ArrayList<ResourceAdapterInfo>();
+    public final List<AdminObjectInfo> adminObjectInfos = new ArrayList<AdminObjectInfo>();
+    public final List<ManagedConnectionFactoryInfo> managedConnectionFactoryInfos = new ArrayList<ManagedConnectionFactoryInfo>();
+
+}

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java?rev=1071905&r1=1071904&r2=1071905&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinator.java Fri Feb 18 07:26:51 2011
@@ -31,11 +31,15 @@ import java.util.concurrent.ConcurrentMa
 
 import javax.resource.ResourceException;
 import javax.resource.spi.DissociatableManagedConnection;
+import javax.transaction.Transaction;
 
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
 import org.apache.geronimo.connector.outbound.ConnectionInfo;
 import org.apache.geronimo.connector.outbound.ConnectionReturnAction;
 import org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor;
 import org.apache.geronimo.connector.outbound.ManagedConnectionInfo;
+import org.apache.geronimo.transaction.manager.TransactionManagerMonitor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -55,7 +59,9 @@ import org.slf4j.LoggerFactory;
  *
  * @version $Rev$ $Date$
  */
-public class ConnectionTrackingCoordinator implements TrackedConnectionAssociator, ConnectionTracker {
+@Component(metatype = true, immediate = true)
+@Service
+public class ConnectionTrackingCoordinator implements TransactionManagerMonitor, TrackedConnectionAssociator, ConnectionTracker {
     private static final Logger log = LoggerFactory.getLogger(ConnectionTrackingCoordinator.class.getName());
 
     private final boolean lazyConnect;
@@ -74,6 +80,24 @@ public class ConnectionTrackingCoordinat
         return lazyConnect;
     }
 
+    @Override
+    public void threadAssociated(Transaction transaction) {
+        ConnectorInstanceContext currentContext = currentInstanceContexts.get();
+        if (currentContext == null) {
+            return;
+        }
+        try {
+            associateConnections(currentContext);
+        } catch (ResourceException e) {
+            log.warn("Error notifying connection tranker of transaction association", e);
+        }
+    }
+
+    @Override
+    public void threadUnassociated(Transaction transaction) {
+    }
+
+    @Override
     public ConnectorInstanceContext enter(ConnectorInstanceContext newContext) throws ResourceException {
         ConnectorInstanceContext oldContext = currentInstanceContexts.get();
         currentInstanceContexts.set(newContext);
@@ -81,23 +105,7 @@ public class ConnectionTrackingCoordinat
         return oldContext;
     }
 
-    private void associateConnections(ConnectorInstanceContext context) throws ResourceException {
-        Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> connectionManagerToManagedConnectionInfoMap = context.getConnectionManagerMap();
-        for (Map.Entry<ConnectionTrackingInterceptor, Set<ConnectionInfo>> entry : connectionManagerToManagedConnectionInfoMap.entrySet()) {
-            ConnectionTrackingInterceptor mcci = entry.getKey();
-            Set<ConnectionInfo> connections = entry.getValue();
-            mcci.enter(connections);
-        }
-    }
-
-    public void newTransaction() throws ResourceException {
-        ConnectorInstanceContext currentContext = currentInstanceContexts.get();
-        if (currentContext == null) {
-            return;
-        }
-        associateConnections(currentContext);
-    }
-
+    @Override
     public void exit(ConnectorInstanceContext oldContext) throws ResourceException {
         ConnectorInstanceContext currentContext = currentInstanceContexts.get();
         try {
@@ -132,6 +140,15 @@ public class ConnectionTrackingCoordinat
         }
     }
 
+    private void associateConnections(ConnectorInstanceContext context) throws ResourceException {
+        Map<ConnectionTrackingInterceptor, Set<ConnectionInfo>> connectionManagerToManagedConnectionInfoMap = context.getConnectionManagerMap();
+        for (Map.Entry<ConnectionTrackingInterceptor, Set<ConnectionInfo>> entry : connectionManagerToManagedConnectionInfoMap.entrySet()) {
+            ConnectionTrackingInterceptor mcci = entry.getKey();
+            Set<ConnectionInfo> connections = entry.getValue();
+            mcci.enter(connections);
+        }
+    }
+
     /**
      * A new connection (handle) has been obtained.  If we are within a component context, store the connection handle
      * so we can disassociate connections that support disassociation on exit.
@@ -139,6 +156,7 @@ public class ConnectionTrackingCoordinat
      * @param connectionInfo the connection that was obtained
      * @param reassociate
      */
+    @Override
     public void handleObtained(ConnectionTrackingInterceptor connectionTrackingInterceptor,
             ConnectionInfo connectionInfo,
             boolean reassociate) throws ResourceException {
@@ -170,6 +188,7 @@ public class ConnectionTrackingCoordinat
      * @param connectionInfo the connection that was released
      * @param connectionReturnAction
      */
+    @Override
     public void handleReleased(ConnectionTrackingInterceptor connectionTrackingInterceptor,
             ConnectionInfo connectionInfo,
             ConnectionReturnAction connectionReturnAction) {
@@ -211,6 +230,7 @@ public class ConnectionTrackingCoordinat
      * @param connectionInfo the connection to be obtained
      * @param key the unique id of the connection manager
      */
+    @Override
     public void setEnvironment(ConnectionInfo connectionInfo, String key) {
         ConnectorInstanceContext currentContext = currentInstanceContexts.get();
         if (currentContext != null) {

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/TrackedConnectionAssociator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/TrackedConnectionAssociator.java?rev=1071905&r1=1071904&r2=1071905&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/TrackedConnectionAssociator.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/TrackedConnectionAssociator.java Fri Feb 18 07:26:51 2011
@@ -35,7 +35,5 @@ public interface TrackedConnectionAssoci
 
     ConnectorInstanceContext enter(ConnectorInstanceContext newConnectorInstanceContext) throws ResourceException;
 
-    void newTransaction() throws ResourceException;
-
     void exit(ConnectorInstanceContext connectorInstanceContext) throws ResourceException;
 }

Added: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/AssemblerTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/AssemblerTest.java?rev=1071905&view=auto
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/AssemblerTest.java (added)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/AssemblerTest.java Fri Feb 18 07:26:51 2011
@@ -0,0 +1,240 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Map;
+
+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.mock.MockAdminObjectImpl;
+import org.apache.geronimo.connector.mock.MockManagedConnectionFactory;
+import org.apache.geronimo.connector.mock.MockResourceAdapter;
+import org.apache.geronimo.connector.model.AdminObjectInfo;
+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.GenericConnectionManager;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class AssemblerTest {
+
+    @Test
+    public void testAssemble() throws Exception {
+        AssemblerImpl assembler = new AssemblerImpl();
+        Listener listener = new Listener();
+        assembler.addListener(listener);
+
+        ResourceAdapterModuleInfo module = new ResourceAdapterModuleInfo();
+        module.name = "module1";
+
+        ResourceAdapterInfo ra = new ResourceAdapterInfo();
+        ra.name = "ra1";
+        ra.resourceAdapterClass = MockResourceAdapter.class.getName();
+        ra.configProperties.put("RAStringProperty", "value1");
+
+        ra.managedConnectionFactoryInfos.add(newMcf("mcf1"));
+        ra.managedConnectionFactoryInfos.add(newMcf("mcf2"));
+
+
+        ra.adminObjectInfos.add(newAdminObject("ao1"));
+        ra.adminObjectInfos.add(newAdminObject("ao2"));
+
+        module.resourceAdapterInfos.add(ra);
+
+        module.managedConnectionFactoryInfos.add(newMcf("mcf3"));
+        module.adminObjectInfos.add(newAdminObject("ao2"));
+
+        assembler.assemble(module, new MockBundle(), getClass().getClassLoader(), null, null, null);
+
+        assertEquals(1, listener.raCount);
+        assertEquals(3, listener.aoCount);
+        assertEquals(3, listener.mcfCount);
+    }
+
+    private AdminObjectInfo newAdminObject(String name) {
+        AdminObjectInfo ao = new AdminObjectInfo();
+        ao.name = name;
+        ao.adminObjectClass = MockAdminObjectImpl.class.getName();
+        ao.configProperties.put("Tweedle", "Dum");
+        return ao;
+    }
+
+    private ManagedConnectionFactoryInfo newMcf(String name) {
+        ManagedConnectionFactoryInfo mcf = new ManagedConnectionFactoryInfo();
+        mcf.name = name;
+        mcf.managedConnectionFactoryClass = MockManagedConnectionFactory.class.getName();
+        mcf.maxPoolSize = 10;
+        mcf.poolCardinality = ManagedConnectionFactoryInfo.PoolCardinality.single;
+        mcf.matchingPolicy = ManagedConnectionFactoryInfo.MatchingPolicy.selectAll;
+        mcf.transactionSupport = ManagedConnectionFactoryInfo.TransactionSupport.xaTxCached;
+        return mcf;
+    }
+
+    private static class Listener implements AssemblyListener {
+
+        int raCount;
+        int aoCount;
+        int mcfCount;
+
+        public void newResourceAdapter(String name, ResourceAdapter resourceAdapter) {
+            raCount++;
+            assertEquals("ra1", name);
+            assertNotNull(resourceAdapter);
+            assertEquals(MockResourceAdapter.class, resourceAdapter.getClass());
+            assertEquals("value1", ((MockResourceAdapter)resourceAdapter).getRAStringProperty());
+        }
+
+        public void newAdminObject(String name, String adminObjectInterface, Object adminObject) {
+            aoCount++;
+        }
+
+        public void newManagedConnectionFactory(String name, ManagedConnectionFactory managedConnectionFactory, GenericConnectionManager connectionManager) {
+            mcfCount++;
+            assertTrue(name.startsWith("mcf"));
+            assertNotNull(managedConnectionFactory);
+            assertEquals(MockManagedConnectionFactory.class, managedConnectionFactory.getClass());
+
+            assertNotNull(connectionManager);
+            assertEquals(10, connectionManager.getPartitionMaxSize());
+        }
+
+    }
+
+    private static class MockBundle implements Bundle {
+
+        public int getState() {
+            return 0;
+        }
+
+        public void start(int i) throws BundleException {
+        }
+
+        public void start() throws BundleException {
+        }
+
+        public void stop(int i) throws BundleException {
+        }
+
+        public void stop() throws BundleException {
+        }
+
+        public void update(InputStream inputStream) throws BundleException {
+        }
+
+        public void update() throws BundleException {
+        }
+
+        public void uninstall() throws BundleException {
+        }
+
+        public Dictionary getHeaders() {
+            return null;
+        }
+
+        public long getBundleId() {
+            return 0;
+        }
+
+        public String getLocation() {
+            return null;
+        }
+
+        public ServiceReference[] getRegisteredServices() {
+            return new ServiceReference[0];
+        }
+
+        public ServiceReference[] getServicesInUse() {
+            return new ServiceReference[0];
+        }
+
+        public boolean hasPermission(Object o) {
+            return false;
+        }
+
+        public URL getResource(String s) {
+            return null;
+        }
+
+        public Dictionary getHeaders(String s) {
+            return null;
+        }
+
+        public String getSymbolicName() {
+            return null;
+        }
+
+        public Class loadClass(String s) throws ClassNotFoundException {
+            return getClass().getClassLoader().loadClass(s);
+        }
+
+        public Enumeration getResources(String s) throws IOException {
+            return null;
+        }
+
+        public Enumeration getEntryPaths(String s) {
+            return null;
+        }
+
+        public URL getEntry(String s) {
+            return null;
+        }
+
+        public long getLastModified() {
+            return 0;
+        }
+
+        public Enumeration findEntries(String s, String s1, boolean b) {
+            return null;
+        }
+
+        public BundleContext getBundleContext() {
+            return null;
+        }
+
+        public Map getSignerCertificates(int i) {
+            return null;
+        }
+
+        public Version getVersion() {
+            return null;
+        }
+    }
+
+}

Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java?rev=1071905&r1=1071904&r2=1071905&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java Fri Feb 18 07:26:51 2011
@@ -22,7 +22,7 @@ import java.util.Set;
 
 import javax.security.auth.Subject;
 import javax.transaction.UserTransaction;
-
+import junit.framework.TestCase;
 import org.apache.geronimo.connector.mock.ConnectionExtension;
 import org.apache.geronimo.connector.mock.MockConnectionFactory;
 import org.apache.geronimo.connector.mock.MockManagedConnection;
@@ -36,12 +36,10 @@ import org.apache.geronimo.connector.out
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContextImpl;
 import org.apache.geronimo.connector.outbound.connectiontracking.DefaultComponentInterceptor;
 import org.apache.geronimo.connector.outbound.connectiontracking.DefaultInterceptor;
-import org.apache.geronimo.connector.outbound.connectiontracking.GeronimoTransactionListener;
 import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
 import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import junit.framework.TestCase;
 
 /**
  * ???
@@ -98,7 +96,7 @@ public class ConnectionManagerTestUtils 
         this.transactionManager = transactionManager;
 
         connectionTrackingCoordinator = new ConnectionTrackingCoordinator();
-        transactionManager.addTransactionAssociationListener(new GeronimoTransactionListener(connectionTrackingCoordinator));
+        transactionManager.addTransactionAssociationListener(connectionTrackingCoordinator);
 
         mockManagedConnectionFactory = new MockManagedConnectionFactory();
         subject = new Subject();

Modified: geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/DSTransactionManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/DSTransactionManager.java?rev=1071905&r1=1071904&r2=1071905&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/DSTransactionManager.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/DSTransactionManager.java Fri Feb 18 07:26:51 2011
@@ -41,6 +41,9 @@ import javax.transaction.xa.Xid;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 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.transaction.log.HOWLLog;
 import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
@@ -60,11 +63,17 @@ import org.osgi.framework.BundleContext;
 /**
  * @version $Rev$ $Date$
  */
-@Component(metatype = true)
+@Component(metatype = true, immediate = true)
 @Service
+@Reference(name = "TransactionManagerMonitor",
+        bind = "addTransactionAssociationListener",
+        unbind = "removeTransactionAssociationListener",
+        cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE,
+        referenceInterface = TransactionManagerMonitor.class,
+        policy = ReferencePolicy.DYNAMIC)
 public class DSTransactionManager implements TransactionManager, UserTransaction, TransactionSynchronizationRegistry, XidImporter, MonitorableTransactionManager, RecoverableTransactionManager, XATerminator, XAWork {
 
-    @Property(byteValue = {71,84,77,73,68})
+    @Property(byteValue = {71, 84, 77, 73, 68})
     private static final String TM_ID = "tmId";
 
     @Property(value = "org.objectweb.howl.log.BlockLogBuffer")
@@ -151,7 +160,7 @@ public class DSTransactionManager implem
                 serverBaseDir);
 
         //tm
-        int defaultTransactionTimeoutSeconds = (Integer)properties.get(DEFAULT_TRANSACTION_TIMEOUT_SECONDS);
+        int defaultTransactionTimeoutSeconds = (Integer) properties.get(DEFAULT_TRANSACTION_TIMEOUT_SECONDS);
         delegate = new GeronimoTransactionManager(defaultTransactionTimeoutSeconds, xidFactory, howlLog);
     }
 

Modified: geronimo/sandbox/djencks/txmanager/geronimo-txmanager-server/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-txmanager-server/pom.xml?rev=1071905&r1=1071904&r2=1071905&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-txmanager-server/pom.xml (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-txmanager-server/pom.xml Fri Feb 18 07:26:51 2011
@@ -26,9 +26,7 @@
     </parent>
     <artifactId>geronimo-txmanager-server</artifactId>
     <packaging>karaf-assembly</packaging>
-    <properties>
-        <karafVersion>2.1.99-SNAPSHOT</karafVersion>
-    </properties>
+
     <dependencies>
         <dependency>
             <groupId>org.apache.karaf.features.assembly</groupId>

Modified: geronimo/sandbox/djencks/txmanager/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/pom.xml?rev=1071905&r1=1071904&r2=1071905&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/pom.xml (original)
+++ geronimo/sandbox/djencks/txmanager/pom.xml Fri Feb 18 07:26:51 2011
@@ -21,7 +21,7 @@
 
     <parent>
         <groupId>org.apache.geronimo.genesis</groupId>
-        <artifactId>genesis-java5-flava</artifactId>
+        <artifactId>genesis-java6-flava</artifactId>
         <version>2.0</version>
         <relativePath/>
     </parent>
@@ -43,6 +43,7 @@
     <url>http://geronimo.apache.org/maven/${siteId}/${project.version}</url>
     <properties>
         <siteId>components/${project.artifactId}</siteId>
+        <karafVersion>2.99.99-SNAPSHOT</karafVersion>
     </properties>
 
     <dependencyManagement>
@@ -117,6 +118,11 @@
                 <artifactId>org.osgi.core</artifactId>
                 <version>4.2.0</version>
             </dependency>
+            <dependency>
+                <groupId>org.osgi</groupId>
+                <artifactId>org.osgi.compendium</artifactId>
+                <version>4.2.0</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 
@@ -155,7 +161,7 @@
                 <plugin>
                     <groupId>org.apache.karaf.tooling</groupId>
                     <artifactId>features-maven-plugin</artifactId>
-                    <version>2.1.99-SNAPSHOT</version>
+                    <version>${karafVersion}</version>
                     <extensions>true</extensions>
                 </plugin>
             </plugins>



Mime
View raw message