You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2005/08/26 10:02:15 UTC

svn commit: r240185 - in /geronimo/trunk/modules: client-builder/src/java/org/apache/geronimo/client/builder/ client-builder/src/schema/ j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/ jetty-builder/src/java/org/apache/geronimo/jetty/deploym...

Author: djencks
Date: Fri Aug 26 01:02:04 2005
New Revision: 240185

URL: http://svn.apache.org/viewcvs?rev=240185&view=rev
Log:
GERONIMO-892, GERONIMO-767 Deal with message-destination and message-destination-link elements correctly

Added:
    geronimo/trunk/modules/naming-builder/src/test/org/apache/geronimo/naming/MessageDestinationTest.java
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.xsd
    geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/RefContext.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.xsd
    geronimo/trunk/modules/tomcat-builder/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
    geronimo/trunk/modules/web-builder/src/schema/geronimo-web.xsd

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=240185&r1=240184&r2=240185&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 Fri Aug 26 01:02:04 2005
@@ -69,9 +69,11 @@
 import org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientDocument;
 import org.apache.geronimo.xbeans.geronimo.client.GerApplicationClientType;
 import org.apache.geronimo.xbeans.geronimo.client.GerResourceType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerMessageDestinationType;
 import org.apache.geronimo.xbeans.j2ee.ApplicationClientDocument;
 import org.apache.geronimo.xbeans.j2ee.ApplicationClientType;
 import org.apache.geronimo.xbeans.j2ee.EjbLocalRefType;
+import org.apache.geronimo.xbeans.j2ee.MessageDestinationType;
 import org.apache.geronimo.security.deploy.DefaultPrincipal;
 import org.apache.geronimo.security.deployment.SecurityBuilder;
 import org.apache.xmlbeans.XmlException;
@@ -271,7 +273,6 @@
     }
 
     public void initContext(EARContext earContext, Module clientModule, ClassLoader cl) {
-        // application clients do not add anything to the shared context
     }
 
     public void addGBeans(EARContext earContext, Module module, ClassLoader earClassLoader) throws DeploymentException {
@@ -361,6 +362,11 @@
                     throw new DeploymentException("Could not create a deployment context for the app client", e);
                 }
 
+                //register the message destinations in the app client ear context.
+                MessageDestinationType[] messageDestinations = appClient.getMessageDestinationArray();
+                GerMessageDestinationType[] gerMessageDestinations = geronimoAppClient.getMessageDestinationArray();
+
+                ENCConfigBuilder.registerMessageDestinations(appClientDeploymentContext.getRefContext(), appClientModule.getName(), messageDestinations, gerMessageDestinations);
                 // extract the client Jar file into a standalone packed jar file and add the contents to the output
                 URI moduleBase = new URI(appClientModule.getTargetPath());
                 try {

Modified: geronimo/trunk/modules/client-builder/src/schema/geronimo-application-client.xsd
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/client-builder/src/schema/geronimo-application-client.xsd?rev=240185&r1=240184&r2=240185&view=diff
==============================================================================
--- geronimo/trunk/modules/client-builder/src/schema/geronimo-application-client.xsd (original)
+++ geronimo/trunk/modules/client-builder/src/schema/geronimo-application-client.xsd Fri Aug 26 01:02:04 2005
@@ -40,13 +40,12 @@
             <xs:element name="include" type="sys:dependencyType" minOccurs="0" maxOccurs="unbounded"/>
             <xs:element ref="sys:dependency" minOccurs="0" maxOccurs="unbounded"/>
 
-            <!--xs:group ref="naming:jndiEnvironmentRefsGroup"/-->
 
             <xs:element ref="naming:ejb-ref" minOccurs="0" maxOccurs="unbounded"/>
-            <!--<xs:element ref="naming:ejb-local-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"/>
             <xs:element ref="naming:resource-env-ref" minOccurs="0" maxOccurs="unbounded"/>
+            <xs:element ref="naming:message-destination" minOccurs="0" maxOccurs="unbounded"/>
 
             <xs:element ref="security:default-principal" minOccurs="0"/>
 

Modified: geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/RefContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/RefContext.java?rev=240185&r1=240184&r2=240185&view=diff
==============================================================================
--- geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/RefContext.java (original)
+++ geronimo/trunk/modules/j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/RefContext.java Fri Aug 26 01:02:04 2005
@@ -20,6 +20,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.HashMap;
+import java.util.Iterator;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.naming.Reference;
@@ -33,6 +35,7 @@
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.xbeans.j2ee.MessageDestinationType;
 
 
 /**
@@ -45,6 +48,8 @@
     private final ServiceReferenceBuilder serviceReferenceBuilder;
     private final Kernel kernel;
 
+    private final Map messageDestinations = new HashMap();
+
     public RefContext(EJBReferenceBuilder ejbReferenceBuilder, ResourceReferenceBuilder resourceReferenceBuilder, ServiceReferenceBuilder serviceReferenceBuilder, Kernel kernel) {
         assert ejbReferenceBuilder != null: "ejbReferenceBuilder is null";
         assert resourceReferenceBuilder != null: "resourceReferenceBuilder is null";
@@ -71,6 +76,12 @@
         this.kernel = refContext.kernel;
     }
 
+    //registration methods
+
+    public void registerMessageDestionations(String moduleName, Map nameMap) throws DeploymentException {
+        messageDestinations.put(moduleName, nameMap);
+    }
+
 
     //lookup methods
 
@@ -124,15 +135,32 @@
         return containerName.getCanonicalName();
     }
 
-
-    public String getAdminObjectContainerId(URI module, String resourceLink, NamingContext context) throws UnresolvedReferenceException {
-        J2eeContext j2eeContext = context.getJ2eeContext();
-        //TODO deal correctly with message-destination-links and message-destination elements. see GERONIMO-892
-        int pos = resourceLink.indexOf('#');
+    public Object getMessageDestination(String messageDestinationLink) throws DeploymentException {
+        Object destination = null;
+        int pos = messageDestinationLink.indexOf('#');
         if (pos > -1) {
-            resourceLink = resourceLink.substring(pos + 1);
+            String targetModule = messageDestinationLink.substring(0, pos);
+            Map destinations = (Map) messageDestinations.get(targetModule);
+            messageDestinationLink = messageDestinationLink.substring(pos + 1);
+            destination = destinations.get(messageDestinationLink);
+        } else {
+            for (Iterator iterator = messageDestinations.values().iterator(); iterator.hasNext();) {
+                Map destinations = (Map) iterator.next();
+                Object destinationTest = destinations.get(messageDestinationLink);
+                if (destinationTest != null) {
+                    if (destination != null) {
+                        throw new DeploymentException("Duplicate message destination " + messageDestinationLink + " accessed from a message-destination-link without a module");
+                    }
+                    destination = destinationTest;
+                }
+            }
         }
-        ObjectName containerName = locateComponentName(resourceLink, module, NameFactory.JCA_RESOURCE, NameFactory.JCA_ADMIN_OBJECT, j2eeContext, context, "admin object");
+        return destination;
+    }
+
+    public String getAdminObjectContainerId(URI moduleURI, String resourceLink, NamingContext context) throws DeploymentException {
+        J2eeContext j2eeContext = context.getJ2eeContext();
+        ObjectName containerName = locateComponentName(resourceLink, moduleURI, NameFactory.JCA_RESOURCE, NameFactory.JCA_ADMIN_OBJECT, j2eeContext, context, "admin object");
         return containerName.getCanonicalName();
     }
 
@@ -258,7 +286,7 @@
         try {
             query = NameFactory.getComponentNameQuery(null, null, null, moduleType, moduleName, name, type, j2eeContext);
         } catch (MalformedObjectNameException e1) {
-            throw (UnresolvedReferenceException)new UnresolvedReferenceException("Could not construct " + queryType + " object name query", false, null).initCause(e1);
+            throw (UnresolvedReferenceException) new UnresolvedReferenceException("Could not construct " + queryType + " object name query", false, null).initCause(e1);
         }
         Set matches = context.listGBeans(query);
         if (matches.size() > 1) {
@@ -287,7 +315,7 @@
         try {
             query = NameFactory.getComponentRestrictedQueryName(null, null, name, type, j2eeContext);
         } catch (MalformedObjectNameException e1) {
-            throw (UnresolvedReferenceException)new UnresolvedReferenceException("Could not construct " + queryType + " object name query", false, null).initCause(e1);
+            throw (UnresolvedReferenceException) new UnresolvedReferenceException("Could not construct " + queryType + " object name query", false, null).initCause(e1);
         }
         return locateUniqueGBeanData(query, queryType);
     }

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=240185&r1=240184&r2=240185&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 Fri Aug 26 01:02:04 2005
@@ -91,6 +91,7 @@
 import org.apache.geronimo.xbeans.geronimo.web.GerWebAppType;
 import org.apache.geronimo.xbeans.geronimo.web.GerContainerConfigType;
 import org.apache.geronimo.xbeans.geronimo.web.jetty.GerJettyConfigType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerMessageDestinationType;
 import org.apache.geronimo.xbeans.j2ee.DispatcherType;
 import org.apache.geronimo.xbeans.j2ee.ErrorPageType;
 import org.apache.geronimo.xbeans.j2ee.FilterMappingType;
@@ -116,6 +117,7 @@
 import org.apache.geronimo.xbeans.j2ee.WebAppType;
 import org.apache.geronimo.xbeans.j2ee.WebResourceCollectionType;
 import org.apache.geronimo.xbeans.j2ee.WelcomeFileListType;
+import org.apache.geronimo.xbeans.j2ee.MessageDestinationType;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.mortbay.http.BasicAuthenticator;
@@ -418,8 +420,13 @@
         }
     }
 
-    public void initContext(EARContext earContext, Module module, ClassLoader cl) {
-        // web application do not add anything to the shared context
+    public void initContext(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {
+        WebAppType webApp = (WebAppType) module.getSpecDD();
+        MessageDestinationType[] messageDestinations = webApp.getMessageDestinationArray();
+        GerWebAppType gerWebApp = (GerWebAppType) module.getVendorDD();
+        GerMessageDestinationType[] gerMessageDestinations = gerWebApp.getMessageDestinationArray();
+
+        ENCConfigBuilder.registerMessageDestinations(earContext.getRefContext(), module.getName(), messageDestinations, gerMessageDestinations);
     }
 
     public void addGBeans(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {

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=240185&r1=240184&r2=240185&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 Fri Aug 26 01:02:04 2005
@@ -28,6 +28,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Iterator;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.naming.NamingException;
@@ -55,6 +56,7 @@
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerCssType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerMessageDestinationType;
 import org.apache.geronimo.xbeans.j2ee.EjbLocalRefType;
 import org.apache.geronimo.xbeans.j2ee.EjbRefType;
 import org.apache.geronimo.xbeans.j2ee.EnvEntryType;
@@ -67,6 +69,7 @@
 import org.apache.geronimo.xbeans.j2ee.ServiceRefType;
 import org.apache.geronimo.xbeans.j2ee.XsdQNameType;
 import org.apache.geronimo.xbeans.j2ee.XsdStringType;
+import org.apache.geronimo.xbeans.j2ee.MessageDestinationType;
 
 /**
  * @version $Rev$ $Date$
@@ -75,6 +78,28 @@
 
     private static final String JAXR_CONNECTION_FACTORY_CLASS = "javax.xml.registry.ConnectionFactory";
 
+    public static void registerMessageDestinations(RefContext refContext, String moduleName, MessageDestinationType[] specDestinations, GerMessageDestinationType[] destinations) throws DeploymentException {
+        Map nameMap = new HashMap();
+        for (int i = 0; i < destinations.length; i++) {
+            GerMessageDestinationType destination = destinations[i];
+            String name = destination.getMessageDestinationName().trim();
+            nameMap.put(name, destination);
+            boolean found = false;
+            for (int j = 0; j < specDestinations.length; j++) {
+                MessageDestinationType specDestination = specDestinations[j];
+                if (specDestination.getMessageDestinationName().getStringValue().trim().equals(name)) {
+                    found = true;
+                    break;
+                }
+            }
+            if (!found) {
+                throw new DeploymentException("No spec DD message-destination for " + name);
+            }
+        }
+        refContext.registerMessageDestionations(moduleName, nameMap);
+    }
+
+
     public static ObjectName getGBeanId(String j2eeType, GerGbeanLocatorType gerGbeanLocator, J2eeContext j2eeContext, DeploymentContext context, Kernel kernel) throws DeploymentException {
         ObjectName containerId = null;
         if (gerGbeanLocator.isSetGbeanLink()) {
@@ -239,7 +264,7 @@
         return containerId;
     }
 
-    public static void addResourceEnvRefs(EARContext earContext, URI moduleURI, ResourceEnvRefType[] resourceEnvRefArray, Map refMap, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
+    public static void addResourceEnvRefs(EARContext earContext, ResourceEnvRefType[] resourceEnvRefArray, Map refMap, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
         if (refMap == null) {
             refMap = Collections.EMPTY_MAP;
         }
@@ -256,7 +281,7 @@
             }
             GerResourceEnvRefType gerResourceEnvRef = (GerResourceEnvRefType) refMap.get(name);
             try {
-                String containerId = getAdminObjectContainerId(name, moduleURI, gerResourceEnvRef, earContext);
+                String containerId = getAdminObjectContainerId(name, gerResourceEnvRef, earContext);
                 Reference ref = earContext.getRefContext().getAdminObjectRef(containerId, iface);
 
                 builder.bind(name, ref);
@@ -266,15 +291,25 @@
         }
     }
 
-    private static String getAdminObjectContainerId(String name, URI uri, GerResourceEnvRefType gerResourceEnvRef, EARContext context) throws DeploymentException {
+    private static String getAdminObjectContainerId(String name, GerResourceEnvRefType gerResourceEnvRef, EARContext context) throws DeploymentException {
         String containerId = null;
         RefContext refContext = context.getRefContext();
+        URI moduleURI = URI.create("");
         if (gerResourceEnvRef == null) {
             //try to resolve ref based only matching resource-ref-name
             //throws exception if it can't locate ref.
-            containerId = refContext.getAdminObjectContainerId(uri, name, context);
+            containerId = refContext.getAdminObjectContainerId(moduleURI, name, context);
         } else if (gerResourceEnvRef.isSetMessageDestinationLink()) {
-            containerId = refContext.getAdminObjectContainerId(uri, getStringValue(gerResourceEnvRef.getMessageDestinationLink()), context);
+            containerId = refContext.getAdminObjectContainerId(moduleURI, gerResourceEnvRef.getMessageDestinationLink().trim(), context);
+        } else if (gerResourceEnvRef.isSetAdminObjectLink()) {
+            if (gerResourceEnvRef.isSetAdminObjectModule()) {
+                try {
+                    moduleURI = new URI(gerResourceEnvRef.getAdminObjectModule().trim());
+                } catch (URISyntaxException e) {
+                    throw new DeploymentException("Could not construct module URI", e);
+                }
+            }
+            containerId = refContext.getAdminObjectContainerId(moduleURI, gerResourceEnvRef.getMessageDestinationLink().trim(), context);
         } else if (gerResourceEnvRef.isSetTargetName()) {
             containerId = getStringValue(gerResourceEnvRef.getTargetName());
         } else {
@@ -296,8 +331,7 @@
         return containerId;
     }
 
-    public static void addMessageDestinationRefs(EARContext earContext, URI moduleURI, MessageDestinationRefType[] messageDestinationRefs, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
-        RefContext refContext = earContext.getRefContext();
+    public static void addMessageDestinationRefs(RefContext refContext, NamingContext namingContext, MessageDestinationRefType[] messageDestinationRefs, ClassLoader cl, ComponentContextBuilder builder) throws DeploymentException {
         for (int i = 0; i < messageDestinationRefs.length; i++) {
             MessageDestinationRefType messageDestinationRef = messageDestinationRefs[i];
             String name = getStringValue(messageDestinationRef.getMessageDestinationRefName());
@@ -309,9 +343,25 @@
             } catch (ClassNotFoundException e) {
                 throw new DeploymentException("could not load class " + type, e);
             }
+            URI moduleURI = URI.create("");
+            GerMessageDestinationType destination = (GerMessageDestinationType)refContext.getMessageDestination(linkName);
+            if (destination != null) {
+                if (destination.isSetAdminObjectLink()) {
+                    if (destination.isSetAdminObjectModule()) {
+                        String module = destination.getAdminObjectModule().trim();
+                        try {
+                            moduleURI = new URI(module);
+                        } catch (URISyntaxException e) {
+                            throw new DeploymentException("Could not construct module URI", e);
+                        }
+                    }
+                    linkName = destination.getAdminObjectLink().trim();
+                }
+            }
+
             //try to resolve ref based only matching resource-ref-name
             //throws exception if it can't locate ref.
-            String containerId = refContext.getAdminObjectContainerId(moduleURI, linkName, earContext);
+            String containerId = refContext.getAdminObjectContainerId(moduleURI, linkName, namingContext);
             Reference ref = refContext.getAdminObjectRef(containerId, iface);
             builder.bind(name, ref);
 
@@ -705,9 +755,9 @@
         addResourceRefs(earContext, moduleURI, resourceRefs, mapResourceRefs(gerResourceRef), cl, builder);
 
         // resource-env-ref
-        addResourceEnvRefs(earContext, moduleURI, resourceEnvRefs, mapResourceEnvRefs(gerResourceEnvRef), cl, builder);
+        addResourceEnvRefs(earContext, resourceEnvRefs, mapResourceEnvRefs(gerResourceEnvRef), cl, builder);
 
-        addMessageDestinationRefs(earContext, moduleURI, messageDestinationRefs, cl, builder);
+        addMessageDestinationRefs(earContext.getRefContext(), earContext, messageDestinationRefs, cl, builder);
 
 //        Map serviceRefMap = new HashMap();
 //        Map serviceRefCredentialsNameMap = new HashMap();

Modified: geronimo/trunk/modules/naming-builder/src/schema/geronimo-naming.xsd
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming-builder/src/schema/geronimo-naming.xsd?rev=240185&r1=240184&r2=240185&view=diff
==============================================================================
--- geronimo/trunk/modules/naming-builder/src/schema/geronimo-naming.xsd (original)
+++ geronimo/trunk/modules/naming-builder/src/schema/geronimo-naming.xsd Fri Aug 26 01:02:04 2005
@@ -32,16 +32,15 @@
         </xsd:documentation>
     </xsd:annotation>
 
-    <!--
- temporary (I hope) individual elements while xmlbeans group handling is straightened out
- -->
 
     <xsd:element name="ejb-ref" type="gernaming:ejb-refType"/>
-    <xsd:element name="ejb-local-ref" type="gernaming:ejb-local-refType"/>
+    <!--    <xsd:element name="ejb-local-ref" type="gernaming:ejb-local-refType"/>-->
     <xsd:element name="service-ref" type="gernaming:service-refType"/>
     <xsd:element name="resource-ref" type="gernaming:resource-refType"/>
     <xsd:element name="resource-env-ref" type="gernaming:resource-env-refType"/>
 
+    <xsd:element name="message-destination" type="gernaming:message-destinationType"/>
+
     <xsd:group name="jndiEnvironmentRefsGroup">
         <xsd:annotation>
             <xsd:documentation>
@@ -141,6 +140,24 @@
             <xsd:choice>
                 <xsd:group ref="gernaming:objectNameGroup"/>
                 <xsd:element name="message-destination-link" type="xsd:string"/>
+                <xsd:sequence>
+                    <xsd:element name="admin-object-module" type="xsd:string" minOccurs="0"/>
+                    <xsd:element name="admin-object-link" type="xsd:string"/>
+                </xsd:sequence>
+                <xsd:element name="target-name" type="xsd:string"/>
+            </xsd:choice>
+        </xsd:sequence>
+    </xsd:complexType>
+
+    <xsd:complexType name="message-destinationType">
+        <xsd:sequence>
+            <xsd:element name="message-destination-name" type="xsd:string"/>
+            <xsd:choice>
+                <xsd:group ref="gernaming:objectNameGroup"/>
+                <xsd:sequence>
+                    <xsd:element name="admin-object-module" type="xsd:string" minOccurs="0"/>
+                    <xsd:element name="admin-object-link" type="xsd:string"/>
+                </xsd:sequence>
                 <xsd:element name="target-name" type="xsd:string"/>
             </xsd:choice>
         </xsd:sequence>

Added: geronimo/trunk/modules/naming-builder/src/test/org/apache/geronimo/naming/MessageDestinationTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/naming-builder/src/test/org/apache/geronimo/naming/MessageDestinationTest.java?rev=240185&view=auto
==============================================================================
--- geronimo/trunk/modules/naming-builder/src/test/org/apache/geronimo/naming/MessageDestinationTest.java (added)
+++ geronimo/trunk/modules/naming-builder/src/test/org/apache/geronimo/naming/MessageDestinationTest.java Fri Aug 26 01:02:04 2005
@@ -0,0 +1,215 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ *  Licensed 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.naming;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.List;
+import java.util.Set;
+import javax.naming.Reference;
+import javax.management.ObjectName;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+import org.apache.geronimo.j2ee.deployment.RefContext;
+import org.apache.geronimo.j2ee.deployment.EJBReferenceBuilder;
+import org.apache.geronimo.j2ee.deployment.NamingContext;
+import org.apache.geronimo.j2ee.deployment.ResourceReferenceBuilder;
+import org.apache.geronimo.j2ee.deployment.ServiceReferenceBuilder;
+import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContext;
+import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContextImpl;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.DeploymentContext;
+import org.apache.geronimo.deployment.GBeanDataRegistry;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.xbeans.j2ee.MessageDestinationType;
+import org.apache.geronimo.xbeans.j2ee.MessageDestinationRefType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerMessageDestinationType;
+import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
+import org.apache.geronimo.naming.java.ComponentContextBuilder;
+
+/**
+ * @version $Rev:  $ $Date:  $
+ */
+public class MessageDestinationTest extends TestCase {
+    private Kernel kernel = null;
+    private RefContext refContext =  new RefContext(new EJBReferenceBuilder() {
+            public Reference createEJBLocalReference(String objectName, GBeanData gbeanData, boolean isSession, String localHome, String local) throws DeploymentException {
+                return null;
+            }
+
+            public Reference createEJBRemoteReference(String objectName, GBeanData gbeanData, boolean isSession, String home, String remote) throws DeploymentException {
+                return null;
+            }
+
+            public Reference createCORBAReference(URI corbaURL, String objectName, ObjectName containerName, String home) throws DeploymentException {
+                return null;
+            }
+
+            public Object createHandleDelegateReference() throws DeploymentException {
+                return null;
+            }
+
+            public Reference getImplicitEJBRemoteRef(URI module, String refName, boolean isSession, String home, String remote, NamingContext context) throws DeploymentException {
+                return null;
+            }
+
+            public Reference getImplicitEJBLocalRef(URI module, String refName, boolean isSession, String localHome, String local, NamingContext context) throws DeploymentException {
+                return null;
+            }
+        }, new ResourceReferenceBuilder() {
+            public Reference createResourceRef(String containerId, Class iface) throws DeploymentException {
+                return null;
+            }
+
+            public Reference createAdminObjectRef(String containerId, Class iface) throws DeploymentException {
+                return null;
+            }
+
+            public GBeanData locateActivationSpecInfo(GBeanData resourceAdapterModuleData, String messageListenerInterface) throws DeploymentException {
+                return null;
+            }
+
+            public GBeanData locateResourceAdapterGBeanData(GBeanData resourceAdapterModuleData) throws DeploymentException {
+                return null;
+            }
+
+            public GBeanData locateAdminObjectInfo(GBeanData resourceAdapterModuleData, String adminObjectInterfaceName) throws DeploymentException {
+                return null;
+            }
+
+            public GBeanData locateConnectionFactoryInfo(GBeanData resourceAdapterModuleData, String connectionFactoryInterfaceName) throws DeploymentException {
+                return null;
+            }
+        }, new ServiceReferenceBuilder() {
+            //it could return a Service or a Reference, we don't care
+            public Object createService(Class serviceInterface, URI wsdlURI, URI jaxrpcMappingURI, QName serviceQName, Map portComponentRefMap, List handlerInfos, Object serviceRefType, DeploymentContext deploymentContext, Module module, ClassLoader classLoader) throws DeploymentException {
+                return null;
+            }
+        }, kernel
+
+                );
+    J2eeContext j2eeContext = new J2eeContextImpl("domain", "server", "app", NameFactory.JCA_RESOURCE, "module1", null, null);
+    NamingContext namingContext = new MockNamingContext(j2eeContext);
+
+    ComponentContextBuilder builder = new ComponentContextBuilder();
+
+    public void testMessageDestinations() throws Exception {
+        MessageDestinationType[] specdests = new MessageDestinationType[] {makeMD("d1"), makeMD("d2")};
+        GerMessageDestinationType[] gerdests = new GerMessageDestinationType[] {makeGerMD("d1", "l1"), makeGerMD("d2", "l2")};
+        MessageDestinationRefType[] destRefs = new MessageDestinationRefType[] {makeMDR("n1", "d1"), makeMDR("n2", "d2")};
+        ENCConfigBuilder.registerMessageDestinations(refContext, "module1", specdests, gerdests);
+        ObjectName n1 = NameFactory.getComponentName(null, null, null, null, null, "l1", NameFactory.JCA_ADMIN_OBJECT, j2eeContext);
+        ObjectName n2 = NameFactory.getComponentName(null, null, null, null, null, "l2", NameFactory.JCA_ADMIN_OBJECT, j2eeContext);
+        namingContext.addGBean(new GBeanData(n1, null));
+        namingContext.addGBean(new GBeanData(n2, null));
+        ENCConfigBuilder.addMessageDestinationRefs(refContext, namingContext, destRefs, this.getClass().getClassLoader(), builder);
+        Map context = builder.getContext();
+        assertEquals(2, context.size());
+    }
+
+    public void testMessageDestinationsWithModule() throws Exception {
+        MessageDestinationType[] specdests = new MessageDestinationType[] {makeMD("d1"), makeMD("d2")};
+        GerMessageDestinationType[] gerdests = new GerMessageDestinationType[] {makeGerMD("d1", "module1", "l1"), makeGerMD("d2", "module1", "l2")};
+        MessageDestinationRefType[] destRefs = new MessageDestinationRefType[] {makeMDR("n1", "d1"), makeMDR("n2", "d2")};
+        ENCConfigBuilder.registerMessageDestinations(refContext, "module1", specdests, gerdests);
+        ObjectName n1 = NameFactory.getComponentName(null, null, null, null, null, "l1", NameFactory.JCA_ADMIN_OBJECT, j2eeContext);
+        ObjectName n2 = NameFactory.getComponentName(null, null, null, null, null, "l2", NameFactory.JCA_ADMIN_OBJECT, j2eeContext);
+        namingContext.addGBean(new GBeanData(n1, null));
+        namingContext.addGBean(new GBeanData(n2, null));
+        ENCConfigBuilder.addMessageDestinationRefs(refContext, namingContext, destRefs, this.getClass().getClassLoader(), builder);
+        Map context = builder.getContext();
+        assertEquals(2, context.size());
+    }
+
+    public void testMessageDestinationsMatch() throws Exception {
+        MessageDestinationType[] specdests = new MessageDestinationType[] {makeMD("d1")};
+        GerMessageDestinationType[] gerdests = new GerMessageDestinationType[] {makeGerMD("d1", "l1"), makeGerMD("d2", "l2")};
+        try {
+            ENCConfigBuilder.registerMessageDestinations(refContext, "module1", specdests, gerdests);
+            fail("tried to register a GerMessageDestination witout a MessageDestination and it succeeded");
+        } catch (DeploymentException e) {
+
+        }
+    }
+
+    private MessageDestinationRefType makeMDR(String name, String link) {
+        MessageDestinationRefType mdr = MessageDestinationRefType.Factory.newInstance();
+        mdr.addNewMessageDestinationRefName().setStringValue(name);
+        mdr.addNewMessageDestinationType().setStringValue(Object.class.getName());
+        mdr.addNewMessageDestinationLink().setStringValue(link);
+        return mdr;
+    }
+
+    private MessageDestinationType makeMD(String name) {
+        MessageDestinationType d1 = MessageDestinationType.Factory.newInstance();
+        d1.addNewMessageDestinationName().setStringValue(name);
+        return d1;
+    }
+
+    private GerMessageDestinationType makeGerMD(String name, String link) {
+        GerMessageDestinationType d1 = GerMessageDestinationType.Factory.newInstance();
+        d1.setMessageDestinationName(name);
+        d1.setAdminObjectLink(link);
+        return d1;
+    }
+
+    private GerMessageDestinationType makeGerMD(String name, String module, String link) {
+        GerMessageDestinationType d1 = makeGerMD(name, link);
+        d1.setAdminObjectModule(module);
+        return d1;
+    }
+    class MockNamingContext implements NamingContext {
+
+        private final GBeanDataRegistry gbeans = new GBeanDataRegistry();
+        private final J2eeContext j2eeContext;
+
+        public MockNamingContext(J2eeContext j2eeContext) {
+            this.j2eeContext = j2eeContext;
+        }
+
+        public J2eeContext getJ2eeContext() {
+            return j2eeContext;
+        }
+
+        public void addGBean(GBeanData gbean) {
+            gbeans.register(gbean);
+        }
+
+        public Set getGBeanNames() {
+            return gbeans.getGBeanNames();
+        }
+
+        public Set listGBeans(ObjectName pattern) {
+            return gbeans.listGBeans(pattern);
+        }
+
+        public GBeanData getGBeanInstance(ObjectName name) throws GBeanNotFoundException {
+            return gbeans.getGBeanInstance(name);
+        }
+
+        public URI getConfigID() {
+            return URI.create("MockNamingContextID");
+        }
+    }
+
+
+}

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=240185&r1=240184&r2=240185&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 Fri Aug 26 01:02:04 2005
@@ -81,6 +81,7 @@
 import org.apache.geronimo.xbeans.geronimo.web.GerWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.web.GerWebAppType;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.GerTomcatConfigType;
+import org.apache.geronimo.xbeans.geronimo.naming.GerMessageDestinationType;
 import org.apache.geronimo.xbeans.j2ee.FilterMappingType;
 import org.apache.geronimo.xbeans.j2ee.HttpMethodType;
 import org.apache.geronimo.xbeans.j2ee.RoleNameType;
@@ -93,6 +94,7 @@
 import org.apache.geronimo.xbeans.j2ee.WebAppDocument;
 import org.apache.geronimo.xbeans.j2ee.WebAppType;
 import org.apache.geronimo.xbeans.j2ee.WebResourceCollectionType;
+import org.apache.geronimo.xbeans.j2ee.MessageDestinationType;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 
@@ -329,8 +331,13 @@
         }
     }
 
-    public void initContext(EARContext earContext, Module module, ClassLoader cl) {
-        // web application do not add anything to the shared context
+    public void initContext(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {
+        WebAppType webApp = (WebAppType) module.getSpecDD();
+        MessageDestinationType[] messageDestinations = webApp.getMessageDestinationArray();
+        GerWebAppType gerWebApp = (GerWebAppType) module.getVendorDD();
+        GerMessageDestinationType[] gerMessageDestinations = gerWebApp.getMessageDestinationArray();
+
+        ENCConfigBuilder.registerMessageDestinations(earContext.getRefContext(), module.getName(), messageDestinations, gerMessageDestinations);
     }
 
     public void addGBeans(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException {

Modified: geronimo/trunk/modules/web-builder/src/schema/geronimo-web.xsd
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/web-builder/src/schema/geronimo-web.xsd?rev=240185&r1=240184&r2=240185&view=diff
==============================================================================
--- geronimo/trunk/modules/web-builder/src/schema/geronimo-web.xsd (original)
+++ geronimo/trunk/modules/web-builder/src/schema/geronimo-web.xsd Fri Aug 26 01:02:04 2005
@@ -48,13 +48,8 @@
             </xs:sequence>
 
             <xs:group ref="naming:jndiEnvironmentRefsGroup"/>
+            <xs:element ref="naming:message-destination" minOccurs="0" maxOccurs="unbounded"/>
 
-         <!--   <xs:element ref="naming:ejb-ref" minOccurs="0" maxOccurs="unbounded"/>
-            <xs:element ref="naming:ejb-local-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"/>
-            <xs:element ref="naming:resource-env-ref" minOccurs="0" maxOccurs="unbounded"/>
--->
             <xs:element ref="sys:gbean" minOccurs="0" maxOccurs="unbounded"/>
 
         </xs:sequence>