geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r928000 - in /geronimo/server/trunk/plugins/connector-1_6: geronimo-connector-1_6/src/main/java/org/apache/geronimo/connector/wrapper/outbound/ geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ geronimo-...
Date Fri, 26 Mar 2010 18:22:41 GMT
Author: gawor
Date: Fri Mar 26 18:22:40 2010
New Revision: 928000

URL: http://svn.apache.org/viewvc?rev=928000&view=rev
Log:
GERONIMO-5170: Register connection factories into service registry. Also, allow connection
factories to specify custom jndi name for jndi lookups via osgi:service/ scheme

Modified:
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/connector/wrapper/outbound/GenericConnectionManagerGBean.java
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/connector/wrapper/outbound/ManagedConnectionFactoryWrapper.java
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/connector/wrapper/outbound/ManagedConnectionFactoryWrapperGBean.java
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/xsd/geronimo-connector-1.2.xsd
    geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/connector/wrapper/outbound/GenericConnectionManagerGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/connector/wrapper/outbound/GenericConnectionManagerGBean.java?rev=928000&r1=927999&r2=928000&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/connector/wrapper/outbound/GenericConnectionManagerGBean.java
(original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/connector/wrapper/outbound/GenericConnectionManagerGBean.java
Fri Mar 26 18:22:40 2010
@@ -23,19 +23,17 @@ import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.io.ObjectStreamException;
 import java.io.Serializable;
+import java.util.Hashtable;
 
 import javax.resource.ResourceException;
 import javax.resource.spi.ConnectionManager;
 import javax.security.auth.Subject;
 import org.apache.geronimo.connector.outbound.GenericConnectionManager;
-import org.apache.geronimo.connector.outbound.PoolingAttributes;
 import org.apache.geronimo.connector.outbound.SubjectSource;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.PoolingSupport;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.TransactionSupport;
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
 import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamAttribute;
@@ -47,9 +45,13 @@ import org.apache.geronimo.kernel.GBeanN
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.KernelRegistry;
 import org.apache.geronimo.kernel.proxy.ProxyManager;
-import org.apache.geronimo.naming.ResourceSource;
 import org.apache.geronimo.security.ContextManager;
 import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceException;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
 
 /**
  * @version $Revision$
@@ -58,22 +60,28 @@ import org.apache.geronimo.transaction.m
 public class GenericConnectionManagerGBean extends GenericConnectionManager implements GBeanLifecycle,
Serializable, Externalizable {
     private Kernel kernel;
     private AbstractName abstractName;
+    private BundleContext bundleContext;
+    private ManagedConnectionFactoryWrapper managedConnectionFactoryWrapper;
+    private ServiceRegistration serviceRegistration;
     //externalizable format version
     private static final int VERSION = 1;
 
     public GenericConnectionManagerGBean(@ParamAttribute(name="transactionSupport") TransactionSupport
transactionSupport,
                                          @ParamAttribute(name="pooling")PoolingSupport pooling,
                                          @ParamAttribute(name="containerManagedSecurity")boolean
containerManagedSecurity,
-                                         @ParamReference(name="ConnectionTracker", namingType
= NameFactory.JCA_CONNECTION_TRACKER)ConnectionTracker connectionTracker,
-                                         @ParamReference(name="TransactionManager", namingType
= NameFactory.JTA_RESOURCE)RecoverableTransactionManager transactionManager,
-                                         @ParamReference(name="ManagedConnectionFactory",
namingType = NameFactory.JCA_MANAGED_CONNECTION_FACTORY)ManagedConnectionFactoryWrapper managedConnectionFactoryWrapper,
-                                         @ParamSpecial(type= SpecialAttributeType.objectName)String
objectName,
-                                         @ParamSpecial(type= SpecialAttributeType.abstractName)AbstractName
abstractName,
-                                         @ParamSpecial(type= SpecialAttributeType.classLoader)ClassLoader
classLoader,
-                                         @ParamSpecial(type= SpecialAttributeType.kernel)Kernel
kernel) {
+                                         @ParamReference(name="ConnectionTracker", namingType
= NameFactory.JCA_CONNECTION_TRACKER) ConnectionTracker connectionTracker,
+                                         @ParamReference(name="TransactionManager", namingType
= NameFactory.JTA_RESOURCE) RecoverableTransactionManager transactionManager,
+                                         @ParamReference(name="ManagedConnectionFactory",
namingType = NameFactory.JCA_MANAGED_CONNECTION_FACTORY) ManagedConnectionFactoryWrapper managedConnectionFactoryWrapper,
+                                         @ParamSpecial(type=SpecialAttributeType.objectName)
String objectName,
+                                         @ParamSpecial(type=SpecialAttributeType.abstractName)
AbstractName abstractName,
+                                         @ParamSpecial(type=SpecialAttributeType.classLoader)
ClassLoader classLoader,
+                                         @ParamSpecial(type=SpecialAttributeType.bundleContext)
BundleContext bundleContext,
+                                         @ParamSpecial(type=SpecialAttributeType.kernel)
Kernel kernel) {
         super(transactionSupport, pooling, getSubjectSource(containerManagedSecurity), connectionTracker,
transactionManager, managedConnectionFactoryWrapper.getManagedConnectionFactory(), objectName,
classLoader);
         this.kernel = kernel;
         this.abstractName = abstractName;
+        this.bundleContext = bundleContext;
+        this.managedConnectionFactoryWrapper = managedConnectionFactoryWrapper;
         doRecovery();
     }
 
@@ -91,6 +99,46 @@ public class GenericConnectionManagerGBe
         }
     }
 
+    public void doFail() {
+    }
+
+    public void doStart() throws Exception {
+        String connectionInterface = managedConnectionFactoryWrapper.getConnectionFactoryInterface();
+        String jndiName = managedConnectionFactoryWrapper.getJndiName();
+        if (jndiName == null) {
+            jndiName = abstractName.getArtifact().getGroupId() + "/" + 
+                       abstractName.getArtifact().getArtifactId() + "/" + 
+                       abstractName.getNameProperty("j2eeType") + "/" + 
+                       abstractName.getNameProperty("name");
+        }
+                
+        Hashtable properties = new Hashtable();
+        properties.put("osgi.jndi.service.name", jndiName);
+        // register ServiceFactory so that each bundle gets its own instance of the connection
factory
+        serviceRegistration = bundleContext.registerService(connectionInterface, new ConnectionFactoryService(),
properties);
+    }
+
+    private class ConnectionFactoryService implements ServiceFactory {
+
+        public Object getService(Bundle bundle, ServiceRegistration registration) {
+            try {
+                return createConnectionFactory();
+            } catch (ResourceException e) {
+                throw new ServiceException("Error creating connection factory", e);
+            }
+        }
+
+        public void ungetService(Bundle bundle, ServiceRegistration registration, Object
service) {
+        }
+        
+    }
+    
+    public void doStop() throws Exception {
+        if (serviceRegistration != null) {
+            serviceRegistration.unregister();
+        }
+    }
+    
     private static SubjectSource getSubjectSource(boolean containerManagedSecurity) {
         if (containerManagedSecurity) {
             return new SubjectSource() {

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/connector/wrapper/outbound/ManagedConnectionFactoryWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/connector/wrapper/outbound/ManagedConnectionFactoryWrapper.java?rev=928000&r1=927999&r2=928000&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/connector/wrapper/outbound/ManagedConnectionFactoryWrapper.java
(original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/connector/wrapper/outbound/ManagedConnectionFactoryWrapper.java
Fri Mar 26 18:22:40 2010
@@ -51,6 +51,7 @@ public class ManagedConnectionFactoryWra
     private final String connectionFactoryImplClass;
     private final String connectionInterface;
     private final String connectionImplClass;
+    private final String jndiName;
 
     private final LinkedHashSet<Class> allImplementedInterfaces = new LinkedHashSet<Class>();
 
@@ -79,6 +80,7 @@ public class ManagedConnectionFactoryWra
         objectName = null;
         classLoader = null;
         resourceAdapterWrapper = null;
+        jndiName = null;
     }
 
     public ManagedConnectionFactoryWrapper(String managedConnectionFactoryClass,
@@ -87,6 +89,7 @@ public class ManagedConnectionFactoryWra
                                            String connectionFactoryImplClass,
                                            String connectionInterface,
                                            String connectionImplClass,
+                                           String jndiName,
                                            ResourceAdapterWrapper resourceAdapterWrapper,
                                            Kernel kernel,
                                            AbstractName abstractName,
@@ -98,6 +101,7 @@ public class ManagedConnectionFactoryWra
         this.connectionFactoryImplClass = connectionFactoryImplClass;
         this.connectionInterface = connectionInterface;
         this.connectionImplClass = connectionImplClass;
+        this.jndiName = jndiName;
 
         allImplementedInterfaces.add(cl.loadClass(connectionFactoryInterface));
         for (String interfaceName: implementedInterfaces) {
@@ -117,6 +121,10 @@ public class ManagedConnectionFactoryWra
         this.objectName = objectName;
     }
 
+    public String getJndiName() {
+        return jndiName;
+    }
+    
     public String getManagedConnectionFactoryClass() {
         return managedConnectionFactoryClass;
     }

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/connector/wrapper/outbound/ManagedConnectionFactoryWrapperGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/connector/wrapper/outbound/ManagedConnectionFactoryWrapperGBean.java?rev=928000&r1=927999&r2=928000&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/connector/wrapper/outbound/ManagedConnectionFactoryWrapperGBean.java
(original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-1_6/src/main/java/org/apache/geronimo/connector/wrapper/outbound/ManagedConnectionFactoryWrapperGBean.java
Fri Mar 26 18:22:40 2010
@@ -41,6 +41,7 @@ public class ManagedConnectionFactoryWra
         infoFactory.addAttribute("connectionFactoryImplClass", String.class, true);
         infoFactory.addAttribute("connectionInterface", String.class, true);
         infoFactory.addAttribute("connectionImplClass", String.class, true);
+        infoFactory.addAttribute("jndiName", String.class, true);
         infoFactory.addAttribute("kernel", Kernel.class, false);
         infoFactory.addAttribute("abstractName", AbstractName.class, false);
         infoFactory.addAttribute("objectName", String.class, false);
@@ -55,6 +56,7 @@ public class ManagedConnectionFactoryWra
             "connectionFactoryImplClass",
             "connectionInterface",
             "connectionImplClass",
+            "jndiName",
             "ResourceAdapterWrapper",
             "kernel",
             "abstractName",

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java?rev=928000&r1=927999&r2=928000&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
Fri Mar 26 18:22:40 2010
@@ -1256,6 +1256,11 @@ public class ConnectorModuleBuilder impl
         // ManagedConnectionFactory
         setDynamicGBeanDataAttributes(managedConnectionFactoryInstanceGBeanData, connectiondefinitionInstance.getConfigPropertySettingArray(),
bundle);
 
+        String jndiName = connectiondefinitionInstance.getJndiName();
+        if (jndiName != null) {
+            managedConnectionFactoryInstanceGBeanData.setAttribute("jndiName", jndiName.trim());
+        }
+        
         //Check if Driver class is available here. This should be available in cl. If not
log a warning as
         //the plan gets deployed and while starting GBean an error is thrown
 

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/xsd/geronimo-connector-1.2.xsd
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/xsd/geronimo-connector-1.2.xsd?rev=928000&r1=927999&r2=928000&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/xsd/geronimo-connector-1.2.xsd
(original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/main/xsd/geronimo-connector-1.2.xsd
Fri Mar 26 18:22:40 2010
@@ -275,6 +275,15 @@
                     </xs:documentation>
                 </xs:annotation>
             </xs:element>
+            
+            <xs:element name="jndi-name" type="xs:string" minOccurs="0">
+                <xs:annotation>
+                    <xs:documentation>
+                        The jndi name for this connection factory used for
+                        jndi lookups using osgi:service/ scheme.
+                    </xs:documentation>
+                </xs:annotation>
+            </xs:element>
 
             <xs:element name="implemented-interface"
                 type="ger:fully-qualified-classType" minOccurs="0"

Modified: geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java?rev=928000&r1=927999&r2=928000&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
(original)
+++ geronimo/server/trunk/plugins/connector-1_6/geronimo-connector-builder-1_6/src/test/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
Fri Mar 26 18:22:40 2010
@@ -447,7 +447,7 @@ public class ConnectorModuleBuilderTest 
                 assertNotNull(managedConnectionFactoryInfo);
                 GBeanInfo managedConnectionFactoryGBeanInfo = managedConnectionFactoryInfo.getGBeanInfo();
                 List attributes3 = managedConnectionFactoryGBeanInfo.getPersistentAttributes();
-                assertEquals(11, attributes3.size());
+                assertEquals(12, attributes3.size());
             }
 
             // FirstTestOutboundConnectionFactory



Mime
View raw message