geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r382352 - in /geronimo/trunk/modules: client-builder/src/java/org/apache/geronimo/client/builder/ client-builder/src/schema/ j2ee-schema/src/java/org/apache/geronimo/schema/ jetty-builder/src/java/org/apache/geronimo/jetty/deployment/ namin...
Date Thu, 02 Mar 2006 11:13:15 GMT
Author: gdamour
Date: Thu Mar  2 03:13:09 2006
New Revision: 382352

URL: http://svn.apache.org/viewcvs?rev=382352&view=rev
Log:
GERONIMO-1434 Allow GBeans to be bound into a component's java:comp/env namespace

This commit allows to bind a GBean reference into the ENC of a J2EE component. 

Based on the XSD, it seems that we also need to support the case where a
collection of GBeans is put in the ENC.

Modified:
    geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
    geronimo/trunk/modules/client-builder/src/schema/geronimo-application-client-1.0.xsd
    geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
    geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
    geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java
    geronimo/trunk/modules/naming-builder/src/schema/geronimo-naming-1.0.xsd
    geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java

Modified: geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java?rev=382352&r1=382351&r2=382352&view=diff
==============================================================================
--- geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
(original)
+++ geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
Thu Mar  2 03:13:09 2006
@@ -615,6 +615,7 @@
                 appClient.getResourceEnvRefArray(), geronimoAppClient.getResourceEnvRefArray(),
                 appClient.getMessageDestinationRefArray(),
                 appClient.getServiceRefArray(), geronimoAppClient.getServiceRefArray(),
+                geronimoAppClient.getGbeanRefArray(),
                 cl);
 
     }

Modified: geronimo/trunk/modules/client-builder/src/schema/geronimo-application-client-1.0.xsd
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/client-builder/src/schema/geronimo-application-client-1.0.xsd?rev=382352&r1=382351&r2=382352&view=diff
==============================================================================
--- geronimo/trunk/modules/client-builder/src/schema/geronimo-application-client-1.0.xsd (original)
+++ geronimo/trunk/modules/client-builder/src/schema/geronimo-application-client-1.0.xsd Thu
Mar  2 03:13:09 2006
@@ -45,6 +45,7 @@
             <xs:group ref="sys:classloader-include-infoGroup"/>
 
 
+            <xs:element ref="naming:gbean-ref" minOccurs="0" maxOccurs="unbounded"/>
             <xs:element ref="naming:ejb-ref" minOccurs="0" maxOccurs="unbounded"/>
             <xs:element ref="naming:service-ref" minOccurs="0" maxOccurs="unbounded"/>
             <xs:element ref="naming:resource-ref" minOccurs="0" maxOccurs="unbounded"/>

Modified: geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java?rev=382352&r1=382351&r2=382352&view=diff
==============================================================================
--- geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
(original)
+++ geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
Thu Mar  2 03:13:09 2006
@@ -53,6 +53,7 @@
 
     static {
 
+        GERONIMO_SCHEMA_CONVERSIONS.put("gbean-ref", new NamespaceElementConverter(GERONIMO_NAMING_NAMESPACE));
         GERONIMO_SCHEMA_CONVERSIONS.put("ejb-ref", new NamespaceElementConverter(GERONIMO_NAMING_NAMESPACE));
         GERONIMO_SCHEMA_CONVERSIONS.put("ejb-local-ref", new NamespaceElementConverter(GERONIMO_NAMING_NAMESPACE));
         GERONIMO_SCHEMA_CONVERSIONS.put("service-ref", new NamespaceElementConverter(GERONIMO_NAMING_NAMESPACE));

Modified: geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java?rev=382352&r1=382351&r2=382352&view=diff
==============================================================================
--- geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
Thu Mar  2 03:13:09 2006
@@ -1308,6 +1308,7 @@
                 webApp.getResourceEnvRefArray(), jettyWebApp.getResourceEnvRefArray(),
                 webApp.getMessageDestinationRefArray(),
                 webApp.getServiceRefArray(), jettyWebApp.getServiceRefArray(),
+                jettyWebApp.getGbeanRefArray(),
                 cl);
     }
 

Modified: geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java?rev=382352&r1=382351&r2=382352&view=diff
==============================================================================
--- geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java
(original)
+++ geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/ENCConfigBuilder.java
Thu Mar  2 03:13:09 2006
@@ -17,9 +17,29 @@
 
 package org.apache.geronimo.naming.deployment;
 
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.transaction.UserTransaction;
+import javax.xml.namespace.QName;
+
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.common.UnresolvedReferenceException;
 import org.apache.geronimo.deployment.DeploymentContext;
+import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.NamingContext;
@@ -30,10 +50,12 @@
 import org.apache.geronimo.kernel.ClassLoading;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.naming.java.ComponentContextBuilder;
+import org.apache.geronimo.naming.reference.GBeanProxyReference;
 import org.apache.geronimo.xbeans.geronimo.naming.GerCssType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerEjbLocalRefType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerEjbRefType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerGbeanLocatorType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerGbeanRefType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerMessageDestinationType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceEnvRefType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
@@ -52,24 +74,6 @@
 import org.apache.geronimo.xbeans.j2ee.XsdQNameType;
 import org.apache.geronimo.xbeans.j2ee.XsdStringType;
 
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.transaction.UserTransaction;
-import javax.xml.namespace.QName;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * @version $Rev$ $Date$
  */
@@ -745,6 +749,7 @@
                                             MessageDestinationRefType[] messageDestinationRefs,
                                             ServiceRefType[] serviceRefs,
                                             GerServiceRefType[] gerServiceRefs,
+                                            GerGbeanRefType[] gerGbeanRefs,
                                             ClassLoader cl) throws DeploymentException {
         ComponentContextBuilder builder = new ComponentContextBuilder();
         RefContext refContext = earContext.getRefContext();
@@ -790,7 +795,67 @@
         Map serviceRefMap = mapServiceRefs(gerServiceRefs);
         addServiceRefs(earContext, module, serviceRefs, serviceRefMap, cl, builder);
 
+        addGBeanRefs(earContext, builder, refContext, gerGbeanRefs, cl);
+        
         return builder.getContext();
+    }
+
+    private static void addGBeanRefs(EARContext earContext, ComponentContextBuilder builder,
RefContext refContext, GerGbeanRefType[] gerGbeanRefs, ClassLoader cl) throws DeploymentException
{
+        if (null == gerGbeanRefs) {
+            return;
+        }
+        
+        J2eeContext j2eeContext = earContext.getJ2eeContext();
+        
+        for (int i = 0; i < gerGbeanRefs.length; i++) {
+            GerGbeanRefType gerGbeanRef = gerGbeanRefs[i];
+            addGBeanRef(earContext, builder, refContext, j2eeContext, gerGbeanRef, cl);
+        }
+    }
+
+    private static void addGBeanRef(EARContext earContext, ComponentContextBuilder builder,
RefContext refContext, J2eeContext j2eeContext, GerGbeanRefType gerGbeanRef, ClassLoader cl)
throws DeploymentException{
+        // TODO support reference to collection of GBean?
+        GerGbeanLocatorType[] gbeanLocatorArray = gerGbeanRef.getGbeanLocatorArray();
+        if (1 < gbeanLocatorArray.length) {
+            throw new UnsupportedOperationException("Cannot create an ENC binding for " +
+                    "a collection of GBean.");
+        }
+        
+        // Locate the referenced GBean
+        GerGbeanLocatorType locator = gbeanLocatorArray[0];
+        ObjectName query;
+        try {
+            query = NameFactory.getComponentName(locator.getDomain(),
+                    locator.getServer(),
+                    locator.getApplication(),
+                    locator.getType(),
+                    locator.getModule(),
+                    locator.getName(),
+                    gerGbeanRef.getRefType(),
+                    j2eeContext);
+        } catch (MalformedObjectNameException e) {
+            throw new DeploymentException("Cannot build GBean query name", e);
+        }
+        ObjectName gBeanName = refContext.locateUniqueName(earContext, query);
+        
+        // Get the GBean proxy type
+        String gBeanTypeName;
+        if (gerGbeanRef.isSetProxyType()) {
+            gBeanTypeName = gerGbeanRef.getProxyType();
+        } else {
+            GBeanData data = refContext.locateComponentData(gBeanName, earContext);
+            gBeanTypeName = data.getGBeanInfo().getClassName();
+        }
+        Class gBeanType;
+        try {
+            gBeanType = ClassLoading.loadClass(gBeanTypeName, cl);
+        } catch (ClassNotFoundException e) {
+            throw new DeploymentException("Cannot load GBean class", e);
+        }
+
+        String refName = gerGbeanRef.getRefName();
+
+        builder.bind(refName, new GBeanProxyReference(gBeanName, gBeanType));
     }
 
     private static Map mapEjbRefs(GerEjbRefType[] refs) {

Modified: geronimo/trunk/modules/naming-builder/src/schema/geronimo-naming-1.0.xsd
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming-builder/src/schema/geronimo-naming-1.0.xsd?rev=382352&r1=382351&r2=382352&view=diff
==============================================================================
--- geronimo/trunk/modules/naming-builder/src/schema/geronimo-naming-1.0.xsd (original)
+++ geronimo/trunk/modules/naming-builder/src/schema/geronimo-naming-1.0.xsd Thu Mar  2 03:13:09
2006
@@ -33,6 +33,7 @@
     </xsd:annotation>
 
 
+    <xsd:element name="gbean-ref" type="gernaming:gbean-refType"/>
     <xsd:element name="ejb-ref" type="gernaming:ejb-refType"/>
     <!--    <xsd:element name="ejb-local-ref" type="gernaming:ejb-local-refType"/>-->
     <xsd:element name="service-ref" type="gernaming:service-refType"/>
@@ -111,8 +112,7 @@
             <xsd:element name="ref-type" type="xsd:string"/>
             <xsd:element name="proxy-type" type="xsd:string" minOccurs="0"/>
             <xsd:choice minOccurs="0" maxOccurs="unbounded">
-                <xsd:group ref="gernaming:objectNameGroup"/>
-                <xsd:element name="target-name" type="xsd:string"/>
+                <xsd:element name="gbean-locator" type="gernaming:gbean-locatorType"/>
             </xsd:choice>
         </xsd:sequence>
     </xsd:complexType>

Modified: geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=382352&r1=382351&r2=382352&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
(original)
+++ geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
Thu Mar  2 03:13:09 2006
@@ -879,6 +879,7 @@
                 webApp.getResourceEnvRefArray(), tomcatWebApp.getResourceEnvRefArray(),
                 webApp.getMessageDestinationRefArray(),
                 webApp.getServiceRefArray(), tomcatWebApp.getServiceRefArray(),
+                tomcatWebApp.getGbeanRefArray(),
                 cl);
     }
 



Mime
View raw message