Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 58214 invoked from network); 18 Feb 2011 07:27:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Feb 2011 07:27:26 -0000 Received: (qmail 24983 invoked by uid 500); 18 Feb 2011 07:27:26 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 24848 invoked by uid 500); 18 Feb 2011 07:27:23 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 24841 invoked by uid 99); 18 Feb 2011 07:27:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Feb 2011 07:27:22 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Feb 2011 07:27:14 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6511323889B3; Fri, 18 Feb 2011 07:26:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: scm@geronimo.apache.org From: djencks@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110218072652.6511323889B3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ org.osgi.core provided + + org.osgi + org.osgi.compendium + provided + junit junit + 4.8.2 test 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 listeners = new ArrayList(); + + 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 load(Class clazz, String className, Map configParams, Bundle bundle) throws ResourceException { + try { + Class resultClass = bundle.loadClass(className).asSubclass(clazz); + T result = resultClass.newInstance(); + for (Map.Entry 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 serviceRegistrations = new ArrayList(); + + + 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 configProperties = new HashMap(); + +} 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 configProperties = new HashMap(); + + 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 configProperties = new HashMap(); + public final List managedConnectionFactoryInfos = new ArrayList(); + public final List adminObjectInfos = new ArrayList(); +} 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 resourceAdapterInfos = new ArrayList(); + public final List adminObjectInfos = new ArrayList(); + public final List managedConnectionFactoryInfos = new ArrayList(); + +} 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> connectionManagerToManagedConnectionInfoMap = context.getConnectionManagerMap(); - for (Map.Entry> entry : connectionManagerToManagedConnectionInfoMap.entrySet()) { - ConnectionTrackingInterceptor mcci = entry.getKey(); - Set 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> connectionManagerToManagedConnectionInfoMap = context.getConnectionManagerMap(); + for (Map.Entry> entry : connectionManagerToManagedConnectionInfoMap.entrySet()) { + ConnectionTrackingInterceptor mcci = entry.getKey(); + Set 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 @@ geronimo-txmanager-server karaf-assembly - - 2.1.99-SNAPSHOT - + org.apache.karaf.features.assembly 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 @@ org.apache.geronimo.genesis - genesis-java5-flava + genesis-java6-flava 2.0 @@ -43,6 +43,7 @@ http://geronimo.apache.org/maven/${siteId}/${project.version} components/${project.artifactId} + 2.99.99-SNAPSHOT @@ -117,6 +118,11 @@ org.osgi.core 4.2.0 + + org.osgi + org.osgi.compendium + 4.2.0 + @@ -155,7 +161,7 @@ org.apache.karaf.tooling features-maven-plugin - 2.1.99-SNAPSHOT + ${karafVersion} true