geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: rev 53828 - in geronimo/trunk/modules/connector/src: java/org/apache/geronimo/connector/deployment java/org/apache/geronimo/connector/outbound schema test/org/apache/geronimo/connector/mock test/org/apache/geronimo/connector/outbound
Date Tue, 05 Oct 2004 22:18:23 GMT
Author: djencks
Date: Tue Oct  5 15:18:22 2004
New Revision: 53828

Modified:
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
   geronimo/trunk/modules/connector/src/schema/geronimo-connector_1_5.xsd
   geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/mock/ConnectionFactoryExtension.java
   geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/mock/MockConnectionFactory.java
   geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapperTest.java
Log:
GERONIMO-362. You can specify implemented-interface elements with additional interfaces the
ConnectionFactory implementation class implements.  These will be implemented by the proxy
you get from jndi.  For instance, it the ra-declared interface is javax.jms.ConnectionFactory,
you might specify javax.jms.QueueConnectionFactory and javax.jms.TopicConnectionFactory

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
Tue Oct  5 15:18:22 2004
@@ -79,6 +79,7 @@
 import org.apache.geronimo.xbeans.j2ee.MessagelistenerType;
 import org.apache.geronimo.xbeans.j2ee.RequiredConfigPropertyType;
 import org.apache.geronimo.xbeans.j2ee.ResourceadapterType;
+import org.apache.geronimo.xbeans.j2ee.FullyQualifiedClassType;
 import org.apache.geronimo.xbeans.j2ee.connector_1_0.ConfigPropertyType10;
 import org.apache.geronimo.xbeans.j2ee.connector_1_0.ConnectorDocument10;
 import org.apache.geronimo.xbeans.j2ee.connector_1_0.ConnectorType10;
@@ -675,6 +676,15 @@
                 earContext.addGBean(realmObjectNam, realmGBean);
                 managedConnectionFactoryGBean.setReferencePattern("ManagedConnectionFactoryListener",
realmObjectNam);
             }
+            //additional interfaces implemented by connection factory
+            FullyQualifiedClassType[] implementedInterfaceElements = connectionfactoryInstance.getImplementedInterfaceArray();
+            Class[] implementedInterfaces = new Class[implementedInterfaceElements == null?
0:implementedInterfaceElements.length];
+            for (int i = 0; i < implementedInterfaceElements.length; i++) {
+                FullyQualifiedClassType additionalInterfaceType = implementedInterfaceElements[i];
+                implementedInterfaces[i] = cl.loadClass(additionalInterfaceType.getStringValue());
+            }
+            managedConnectionFactoryGBean.setAttribute("implementedInterfaces", implementedInterfaces);
+
         } catch (Exception e) {
             throw new DeploymentException(e);
         }

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
Tue Oct  5 15:18:22 2004
@@ -52,10 +52,12 @@
 
     private final Class managedConnectionFactoryClass;
     private final Class connectionFactoryInterface;
+    private final Class[] implementedInterfaces;
     private final Class connectionFactoryImplClass;
     private final Class connectionInterface;
     private final Class connectionImplClass;
 
+    private final Class[] allImplementedInterfaces;
 
     private String globalJNDIName;
 
@@ -80,15 +82,18 @@
     public ManagedConnectionFactoryWrapper() {
         managedConnectionFactoryClass = null;
         connectionFactoryInterface = null;
+        implementedInterfaces = null;
         connectionFactoryImplClass = null;
         connectionInterface = null;
         connectionImplClass = null;
         kernel = null;
         objectName = null;
+        allImplementedInterfaces = null;
     }
 
     public ManagedConnectionFactoryWrapper(Class managedConnectionFactoryClass,
             Class connectionFactoryInterface,
+            Class[] implementedInterfaces,
             Class connectionFactoryImplClass,
             Class connectionInterface,
             Class connectionImplClass,
@@ -100,10 +105,15 @@
             String objectName) throws InstantiationException, IllegalAccessException {
         this.managedConnectionFactoryClass = managedConnectionFactoryClass;
         this.connectionFactoryInterface = connectionFactoryInterface;
+        this.implementedInterfaces = implementedInterfaces;
         this.connectionFactoryImplClass = connectionFactoryImplClass;
         this.connectionInterface = connectionInterface;
         this.connectionImplClass = connectionImplClass;
 
+        allImplementedInterfaces = new Class[1 + implementedInterfaces.length];
+        allImplementedInterfaces[0]= connectionFactoryInterface;
+        System.arraycopy(implementedInterfaces, 0, allImplementedInterfaces, 1, implementedInterfaces.length);
+
         this.globalJNDIName = globalJNDIName;
         this.resourceAdapterWrapper = resourceAdapterWrapper;
         this.connectionManagerFactory = connectionManagerFactory;
@@ -126,6 +136,10 @@
         return connectionFactoryInterface;
     }
 
+    public Class[] getImplementedInterfaces() {
+        return implementedInterfaces;
+    }
+
     public Class getConnectionFactoryImplClass() {
         return connectionFactoryImplClass;
     }
@@ -178,7 +192,7 @@
         //build proxy
         if (proxy == null) {
             Enhancer enhancer = new Enhancer();
-            enhancer.setSuperclass(connectionFactoryInterface);
+            enhancer.setInterfaces(allImplementedInterfaces);
             enhancer.setCallbackType(net.sf.cglib.proxy.MethodInterceptor.class);
             enhancer.setUseFactory(false);//????
             interceptor = new ConnectorMethodInterceptor(kernel.getKernelName(), ObjectName.getInstance(objectName));
@@ -255,6 +269,7 @@
 
         infoFactory.addAttribute("managedConnectionFactoryClass", Class.class, true);
         infoFactory.addAttribute("connectionFactoryInterface", Class.class, true);
+        infoFactory.addAttribute("implementedInterfaces", Class[].class, true);
         infoFactory.addAttribute("connectionFactoryImplClass", Class.class, true);
         infoFactory.addAttribute("connectionInterface", Class.class, true);
         infoFactory.addAttribute("connectionImplClass", Class.class, true);
@@ -274,6 +289,7 @@
         infoFactory.setConstructor(new String[]{
             "managedConnectionFactoryClass",
             "connectionFactoryInterface",
+            "implementedInterfaces",
             "connectionFactoryImplClass",
             "connectionInterface",
             "connectionImplClass",

Modified: geronimo/trunk/modules/connector/src/schema/geronimo-connector_1_5.xsd
==============================================================================
--- geronimo/trunk/modules/connector/src/schema/geronimo-connector_1_5.xsd	(original)
+++ geronimo/trunk/modules/connector/src/schema/geronimo-connector_1_5.xsd	Tue Oct  5 15:18:22
2004
@@ -219,6 +219,18 @@
         <xsd:sequence>
             <xsd:element name="name"
                 type="xsd:string"/>
+
+            <xsd:element name="implemented-interface"
+                type="j2ee:fully-qualified-classType"
+                minOccurs="0"
+                maxOccurs="unbounded">
+                <xsd:annotation>
+                    <xsd:documentation>
+                        <![CDATA[Additional interfaces implemented by the connectionfactory,
used by the application]]>
+                    </xsd:documentation>
+                </xsd:annotation>
+            </xsd:element>
+
             <xsd:element name="config-property-setting"
                 type="ger:config-property-settingType"
                 minOccurs="0"

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/mock/ConnectionFactoryExtension.java
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/mock/ConnectionFactoryExtension.java
(original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/mock/ConnectionFactoryExtension.java
Tue Oct  5 15:18:22 2004
@@ -10,5 +10,5 @@
  * */
 public interface ConnectionFactoryExtension extends ConnectionFactory{
 
-    void doSomethingElse();
+    String doSomethingElse();
 }

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/mock/MockConnectionFactory.java
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/mock/MockConnectionFactory.java
(original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/mock/MockConnectionFactory.java
Tue Oct  5 15:18:22 2004
@@ -68,6 +68,7 @@
         return reference;
     }
 
-    public void doSomethingElse() {
+    public String doSomethingElse() {
+        return "SomethingElse";
     }
 }

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapperTest.java
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapperTest.java
(original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapperTest.java
Tue Oct  5 15:18:22 2004
@@ -21,6 +21,7 @@
 import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
+import java.io.Serializable;
 import java.util.Collections;
 import java.util.Hashtable;
 import javax.management.ObjectName;
@@ -34,6 +35,7 @@
 import org.apache.geronimo.connector.mock.MockConnection;
 import org.apache.geronimo.connector.mock.MockConnectionFactory;
 import org.apache.geronimo.connector.mock.MockManagedConnectionFactory;
+import org.apache.geronimo.connector.mock.ConnectionFactoryExtension;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoPool;
 import org.apache.geronimo.connector.outbound.connectionmanagerconfig.NoTransactions;
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
@@ -74,6 +76,10 @@
         }
         kernel.startGBean(managedConnectionFactoryName);
         ((ConnectionFactory) proxy).getConnection();
+        //check implemented interfaces
+        assertTrue(proxy instanceof Serializable);
+        assertTrue(proxy instanceof ConnectionFactoryExtension);
+        assertEquals("SomethingElse", ((ConnectionFactoryExtension)proxy).doSomethingElse());
     }
 
     public void testSerialization() throws Exception {
@@ -157,6 +163,7 @@
         GBeanMBean mcfw = new GBeanMBean(ManagedConnectionFactoryWrapper.getGBeanInfo());
         mcfw.setAttribute("managedConnectionFactoryClass", MockManagedConnectionFactory.class);
         mcfw.setAttribute("connectionFactoryInterface", ConnectionFactory.class);
+        mcfw.setAttribute("implementedInterfaces", new Class[] {Serializable.class, ConnectionFactoryExtension.class});
         mcfw.setAttribute("connectionFactoryImplClass", MockConnectionFactory.class);
         mcfw.setAttribute("connectionInterface", Connection.class);
         mcfw.setAttribute("connectionImplClass", MockConnection.class);

Mime
View raw message