geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject cvs commit: incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/deployment RAR_1_0ConfigBuilderTest.java
Date Mon, 09 Aug 2004 04:19:36 GMT
gdamour     2004/08/08 21:19:36

  Modified:    modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment
                        EARConfigBuilder.java Module.java
               modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment
                        EARConfigBuilderTest.java MockEJBConfigBuilder.java
                        MockWARConfigBuilder.java
                        MockConnectorConfigBuilder.java
               modules/jetty/src/java/org/apache/geronimo/jetty/deployment
                        JettyModuleBuilder.java
               modules/j2ee/src/schema geronimo-application.xsd
               modules/connector/src/java/org/apache/geronimo/connector/deployment
                        ConnectorModuleBuilder.java
               modules/j2ee maven.xml
               modules/connector/src/test/org/apache/geronimo/connector/deployment
                        RAR_1_0ConfigBuilderTest.java
  Added:       modules/j2ee/src/test-unpacked-ear/META-INF
                        application-alt-dd.xml
                        geronimo-application-alt-dd.xml
  Log:
  o Supports the alt-dd element associated to a module via an EAR deployment descriptor;
  o Updates geronimo-application.xsd such that it is possible to provide an optional alt-dd element defining
  an alternate Geronimo specific deployment descriptor for each module defined by an EAR deployment descriptor; and
  o Impacts JettyModuleBuilder and ConnectorModuleBuilder accordingly to use the alternate deployment
  descriptors, if any.
  
  Revision  Changes    Path
  1.1                  incubator-geronimo/modules/j2ee/src/test-unpacked-ear/META-INF/application-alt-dd.xml
  
  Index: application-alt-dd.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!--
  
      Copyright 2004 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.
  -->
  <application xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"
      version="1.4">
      <description>description</description>
      <display-name>display-name</display-name>
      <icon>
        <small-icon>url/to/small/icon</small-icon>
        <large-icon>url/to/large/icon</large-icon>
      </icon>
      <module>
          <web>
              <!-- supports an exploded WAR within an exploded EAR -->
              <web-uri>test-war/</web-uri>
              <context-root>test</context-root>
          </web>
          <alt-dd>alt-web.xml</alt-dd>
      </module>
      <module>
          <ejb>test-ejb-jar/</ejb>
          <alt-dd>alt-ejb-jar.xml</alt-dd>
      </module>
      <module>
          <!-- supports a standard RAR within an exploded RAR -->
          <connector>test-rar.rar</connector>
          <alt-dd>alt-ra.xml</alt-dd>
      </module>
  </application>
  
  
  
  1.1                  incubator-geronimo/modules/j2ee/src/test-unpacked-ear/META-INF/geronimo-application-alt-dd.xml
  
  Index: geronimo-application-alt-dd.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!--
  
      Copyright 2004 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.
  -->
  
  <application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application"
      configId="org/apache/geronimo/j2ee/deployment/test"
      parentId="org/apache/geronimo/Server">
  
      <!-- a random gbean just to verify that the deployer doesn't die because of it -->
      <gbean name="foo:j2eeType=J2EEDomain,name=foo" class="org.apache.geronimo.j2ee.management.impl.J2EEDomainImpl"/>
  
      <module>
          <web>test-war/</web>
          <alt-dd>alt-ger-war.xml</alt-dd>
      </module>
      <module>
          <ejb>test-ejb-jar/</ejb>
          <alt-dd>alt-ger-ejb-jar.xml</alt-dd>
      </module>
      <module>
          <connector>test-rar.rar</connector>
          <alt-dd>alt-ger-ra.xml</alt-dd>
      </module>
  
  </application>
  
  
  1.20      +67 -11    incubator-geronimo/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
  
  Index: EARConfigBuilder.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- EARConfigBuilder.java	7 Aug 2004 11:22:12 -0000	1.19
  +++ EARConfigBuilder.java	9 Aug 2004 04:19:35 -0000	1.20
  @@ -33,6 +33,7 @@
   import org.apache.geronimo.xbeans.geronimo.j2ee.GerApplicationType;
   import org.apache.geronimo.xbeans.geronimo.j2ee.GerDependencyType;
   import org.apache.geronimo.xbeans.geronimo.j2ee.GerGbeanType;
  +import org.apache.geronimo.xbeans.geronimo.j2ee.GerModuleType;
   import org.apache.geronimo.xbeans.j2ee.ApplicationDocument;
   import org.apache.geronimo.xbeans.j2ee.ApplicationType;
   import org.apache.geronimo.xbeans.j2ee.ModuleType;
  @@ -48,7 +49,17 @@
   import java.net.URI;
   import java.net.URISyntaxException;
   import java.net.URL;
  -import java.util.*;
  +import java.util.ArrayList;
  +import java.util.Collection;
  +import java.util.Collections;
  +import java.util.Enumeration;
  +import java.util.HashMap;
  +import java.util.HashSet;
  +import java.util.Iterator;
  +import java.util.LinkedHashSet;
  +import java.util.List;
  +import java.util.Map;
  +import java.util.Set;
   import java.util.jar.JarEntry;
   import java.util.jar.JarFile;
   import java.util.jar.JarOutputStream;
  @@ -243,6 +254,13 @@
                           }
                           return new FileInputStream(appXMLFile);
                       }
  +                    public URL toURL(String uri) throws DeploymentException {
  +                        try {
  +                            return new File(earFolder, uri).toURL();
  +                        } catch (MalformedURLException e) {
  +                            throw new DeploymentException("Can not create URL", e);
  +                        }
  +                    }
                   };
                   return EARConfigBuilder.this.addModules(configID, plan, locator, moduleLocations, modules);
               }
  @@ -291,6 +309,14 @@
                           }
                           return earFile.getInputStream(appXMLEntry);
                       }
  +                    public URL toURL(String uri) throws DeploymentException {
  +                        try {
  +                            String urlString = "jar:" + new File(earFile.getName()).toURL() + "!/" + uri;
  +                            return new URL(urlString);
  +                        } catch (MalformedURLException e) {
  +                            throw new DeploymentException("Can not create URL", e);
  +                        }
  +                    }
                   };
                   return EARConfigBuilder.this.addModules(configID, plan, locator, moduleLocations, modules);
               }
  @@ -439,38 +465,66 @@
               Set ejbModules = new HashSet();
               Set connectorModules = new HashSet();
               Set webModules = new HashSet();
  +            Map moduleMap = new HashMap();
   
               for (int i = 0; i < moduleTypes.length; i++) {
                   ModuleType module = moduleTypes[i];
  +                Module currentModule = null;
                   if (module.isSetEjb()) {
                       URI uri = URI.create(module.getEjb().getStringValue());
  -                    EJBModule ejbModule = new EJBModule(uri.toString(), uri);
  +                    currentModule = new EJBModule(uri.toString(), uri);
                       if (ejbConfigBuilder == null) {
  -                        throw new DeploymentException("Can not deploy ejb application; No ejb deployer defined: " + ejbModule.getURI());
  +                        throw new DeploymentException("Can not deploy ejb application; No ejb deployer defined: " + currentModule.getURI());
                       }
                       moduleLocations.add(uri.toString());
  -                    ejbModules.add(ejbModule);
  +                    ejbModules.add(currentModule);
                   } else if (module.isSetWeb()) {
                       org.apache.geronimo.xbeans.j2ee.WebType web = module.getWeb();
                       URI uri = URI.create(web.getWebUri().getStringValue());
                       String contextRoot = web.getContextRoot().getStringValue();
  -                    WebModule webModule = new WebModule(uri.toString(), uri, contextRoot);
  +                    currentModule = new WebModule(uri.toString(), uri, contextRoot);
                       if (webConfigBuilder == null) {
  -                        throw new DeploymentException("Can not deploy web application; No war deployer defined: " + webModule.getURI());
  +                        throw new DeploymentException("Can not deploy web application; No war deployer defined: " + currentModule.getURI());
                       }
   
                       moduleLocations.add(uri.toString());
  -                    webModules.add(webModule);
  +                    webModules.add(currentModule);
                   } else if (module.isSetConnector()) {
                       URI uri = URI.create(module.getConnector().getStringValue());
  -                    ConnectorModule connectorModule = new ConnectorModule(uri.toString(), uri);
  +                    currentModule = new ConnectorModule(uri.toString(), uri);
                       if (connectorConfigBuilder == null) {
  -                        throw new DeploymentException("Can not deploy resource adapter; No rar deployer defined: " + connectorModule.getURI());
  +                        throw new DeploymentException("Can not deploy resource adapter; No rar deployer defined: " + currentModule.getURI());
                       }
                       moduleLocations.add(uri.toString());
  -                    connectorModules.add(connectorModule);
  +                    connectorModules.add(currentModule);
  +                }
  +                moduleMap.put(currentModule.getName(), currentModule);
  +                // TODO remove test against null when application clients will be supported.
  +                if ( module.isSetAltDd() && null != currentModule ) {
  +                    URL altDDURL = appLocator.toURL(module.getAltDd().getStringValue());
  +                    currentModule.setAltSpecDD(altDDURL);
  +                }
  +            }
  +            
  +            GerApplicationDocument gerApplication = (GerApplicationDocument) plan;
  +            GerModuleType gerModuleTypes[] = gerApplication.getApplication().getModuleArray();
  +            for (int i = 0; i < gerModuleTypes.length; i++) {
  +                GerModuleType gerModuleType = gerModuleTypes[i];
  +                Module currentModule = null;
  +                if ( gerModuleType.isSetEjb() ) {
  +                    currentModule = (Module) moduleMap.get(gerModuleType.getEjb().getStringValue());
  +                } else if ( gerModuleType.isSetWeb() ) {
  +                    currentModule = (Module) moduleMap.get(gerModuleType.getWeb().getStringValue());
  +                } else if ( gerModuleType.isSetConnector() ) {
  +                    currentModule = (Module) moduleMap.get(gerModuleType.getConnector().getStringValue());
  +                }
  +                // TODO remove test against null when application clients will be supported.
  +                if ( gerModuleType.isSetAltDd() && null != currentModule ) {
  +                    URL altDDURL = appLocator.toURL(gerModuleType.getAltDd().getStringValue());
  +                    currentModule.setAltVendorDD(altDDURL);
                   }
               }
  +            
               modules.addAll(connectorModules);
               modules.addAll(ejbModules);
               modules.addAll(webModules);
  @@ -640,6 +694,8 @@
   
           public InputStream getApplication() throws DeploymentException, IOException;
   
  +        public URL toURL(String uri) throws DeploymentException;
  +        
       }
   
       public static final GBeanInfo GBEAN_INFO;
  
  
  
  1.2       +21 -1     incubator-geronimo/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/Module.java
  
  Index: Module.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/Module.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Module.java	19 May 2004 20:53:59 -0000	1.1
  +++ Module.java	9 Aug 2004 04:19:35 -0000	1.2
  @@ -17,6 +17,7 @@
   package org.apache.geronimo.j2ee.deployment;
   
   import java.net.URI;
  +import java.net.URL;
   
   import org.apache.xmlbeans.XmlObject;
   
  @@ -26,7 +27,9 @@
   public class Module {
       protected final String name;
       protected final URI uri;
  +    protected URL altSpecDD;
       protected XmlObject specDD;
  +    protected URL altVendorDD;
       protected XmlObject vendorDD;
   
       public Module(String name, URI uri) {
  @@ -43,6 +46,14 @@
           return uri;
       }
   
  +    public URL getAltSpecDD() {
  +        return altSpecDD;
  +    }
  +    
  +    public void setAltSpecDD(URL altSpecDD) {
  +        this.altSpecDD = altSpecDD;
  +    }
  +    
       public XmlObject getSpecDD() {
           return specDD;
       }
  @@ -51,6 +62,14 @@
           this.specDD = specDD;
       }
   
  +    public URL getAltVendorDD() {
  +        return altVendorDD;
  +    }
  +    
  +    public void setAltVendorDD(URL altVendorDD) {
  +        this.altVendorDD = altVendorDD;
  +    }
  +    
       public XmlObject getVendorDD() {
           return vendorDD;
       }
  @@ -73,4 +92,5 @@
           }
           return false;
       }
  +    
   }
  
  
  
  1.9       +45 -1     incubator-geronimo/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
  
  Index: EARConfigBuilderTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- EARConfigBuilderTest.java	7 Aug 2004 11:22:12 -0000	1.8
  +++ EARConfigBuilderTest.java	9 Aug 2004 04:19:35 -0000	1.9
  @@ -19,6 +19,8 @@
   
   import java.io.File;
   import java.net.URI;
  +import java.net.URL;
  +
   import javax.management.ObjectName;
   
   import junit.framework.TestCase;
  @@ -127,6 +129,46 @@
               protected void tearDown() {
               }
           };
  +        TestSetup setupUnpackedAltDD = new TestSetup(inner) {
  +            protected void setUp() throws Exception {
  +                EAR_BASE_DIR = "target/test-unpacked-ear";
  +                EAR_PATH = "alt-dd/";
  +                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar/", URI.create("test-ejb-jar/"));
  +                File baseDir = new File(EAR_BASE_DIR + "/" + EAR_PATH);
  +                ejbConfigBuilder.ejbModule.setAltSpecDD(new File(baseDir, "alt-ejb-jar.xml").toURL());
  +                ejbConfigBuilder.ejbModule.setAltVendorDD(new File(baseDir, "alt-ger-ejb-jar.xml").toURL());
  +                webConfigBuilder.contextRoot = "test";
  +                webConfigBuilder.webModule = new WebModule("test-war/", URI.create("test-war/"), "test");
  +                webConfigBuilder.webModule.setAltSpecDD(new File(baseDir, "alt-web.xml").toURL());
  +                webConfigBuilder.webModule.setAltVendorDD(new File(baseDir, "alt-ger-war.xml").toURL());
  +                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar", URI.create("test-rar.rar"));
  +                connectorConfigBuilder.connectorModule.setAltSpecDD(new File(baseDir, "alt-ra.xml").toURL());
  +                connectorConfigBuilder.connectorModule.setAltVendorDD(new File(baseDir, "alt-ger-ra.xml").toURL());
  +            }
  +
  +            protected void tearDown() {
  +            }
  +        };
  +        TestSetup setupPackedAltDD = new TestSetup(inner) {
  +            protected void setUp() throws Exception {
  +                EAR_BASE_DIR = "target/test-unpacked-ear";
  +                EAR_PATH = "alt-dd.ear";
  +                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar/", URI.create("test-ejb-jar/"));
  +                String baseURI = "jar:" + new File(EAR_BASE_DIR + "/" + EAR_PATH).toURL() + "!/";
  +                ejbConfigBuilder.ejbModule.setAltSpecDD(new URL(baseURI + "alt-ejb-jar.xml"));
  +                ejbConfigBuilder.ejbModule.setAltVendorDD(new URL(baseURI + "alt-ger-ejb-jar.xml"));
  +                webConfigBuilder.contextRoot = "test";
  +                webConfigBuilder.webModule = new WebModule("test-war/", URI.create("test-war/"), "test");
  +                webConfigBuilder.webModule.setAltSpecDD(new URL(baseURI + "alt-web.xml"));
  +                webConfigBuilder.webModule.setAltVendorDD(new URL(baseURI + "alt-ger-war.xml"));
  +                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar", URI.create("test-rar.rar"));
  +                connectorConfigBuilder.connectorModule.setAltSpecDD(new URL(baseURI + "alt-ra.xml"));
  +                connectorConfigBuilder.connectorModule.setAltVendorDD(new URL(baseURI + "alt-ger-ra.xml"));
  +            }
  +
  +            protected void tearDown() {
  +            }
  +        };
           
           TestSuite suite = new TestSuite();
           suite.addTest(setup14);
  @@ -135,6 +177,8 @@
           suite.addTest(setupNaked13);
           suite.addTest(setupUnpacked);
           suite.addTest(setupUnpackedNaked);
  +        suite.addTest(setupUnpackedAltDD);
  +        suite.addTest(setupPackedAltDD);
           return suite;
       }
   
  
  
  
  1.4       +14 -2     incubator-geronimo/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockEJBConfigBuilder.java
  
  Index: MockEJBConfigBuilder.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockEJBConfigBuilder.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- MockEJBConfigBuilder.java	7 Aug 2004 11:22:12 -0000	1.3
  +++ MockEJBConfigBuilder.java	9 Aug 2004 04:19:35 -0000	1.4
  @@ -54,11 +54,17 @@
           return null;
       }
   
  -    public void installModule(File earFolder, EARContext earContext, Module module) {
  +    public void installModule(File earFolder, EARContext earContext, Module ejbModule) {
           assertNotNull(earFolder);
           assertNotNull(earContext);
           this.earContext = earContext;
           assertEquals(this.ejbModule, ejbModule);
  +        if ( null != this.ejbModule.getAltSpecDD() ) {
  +            assertEquals(this.ejbModule.getAltSpecDD(), ejbModule.getAltSpecDD());
  +        }
  +        if ( null != this.ejbModule.getAltVendorDD() ) {
  +            assertEquals(this.ejbModule.getAltVendorDD(), ejbModule.getAltVendorDD());
  +        }
       }
   
       public void installModule(JarFile earFile, EARContext earContext, Module ejbModule) {
  @@ -66,6 +72,12 @@
           assertNotNull(earContext);
           this.earContext = earContext;
           assertEquals(this.ejbModule, ejbModule);
  +        if ( null != this.ejbModule.getAltSpecDD() ) {
  +            assertEquals(this.ejbModule.getAltSpecDD(), ejbModule.getAltSpecDD());
  +        }
  +        if ( null != this.ejbModule.getAltVendorDD() ) {
  +            assertEquals(this.ejbModule.getAltVendorDD(), ejbModule.getAltVendorDD());
  +        }
       }
   
       public void initContext(EARContext earContext, Module ejbModule, ClassLoader cl) {
  
  
  
  1.5       +14 -3     incubator-geronimo/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockWARConfigBuilder.java
  
  Index: MockWARConfigBuilder.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockWARConfigBuilder.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MockWARConfigBuilder.java	7 Aug 2004 11:22:12 -0000	1.4
  +++ MockWARConfigBuilder.java	9 Aug 2004 04:19:35 -0000	1.5
  @@ -55,12 +55,17 @@
           return null;
       }
   
  -    public void installModule(File earFolder, EARContext earContext,
  -        Module module) throws DeploymentException {
  +    public void installModule(File earFolder, EARContext earContext, Module webModule) throws DeploymentException {
           assertNotNull(earFolder);
           assertNotNull(earContext);
           this.earContext = earContext;
           assertEquals(this.webModule, webModule);
  +        if ( null != this.webModule.getAltSpecDD() ) {
  +            assertEquals(this.webModule.getAltSpecDD(), webModule.getAltSpecDD());
  +        }
  +        if ( null != this.webModule.getAltVendorDD() ) {
  +            assertEquals(this.webModule.getAltVendorDD(), webModule.getAltVendorDD());
  +        }
       }
       
       public void installModule(JarFile earFile, EARContext earContext, Module webModule) throws DeploymentException {
  @@ -68,6 +73,12 @@
           assertNotNull(earContext);
           this.earContext = earContext;
           assertEquals(this.webModule, webModule);
  +        if ( null != this.webModule.getAltSpecDD() ) {
  +            assertEquals(this.webModule.getAltSpecDD(), webModule.getAltSpecDD());
  +        }
  +        if ( null != this.webModule.getAltVendorDD() ) {
  +            assertEquals(this.webModule.getAltVendorDD(), webModule.getAltVendorDD());
  +        }
       }
   
       public void initContext(EARContext earContext, Module webModule, ClassLoader cl) {
  
  
  
  1.5       +14 -4     incubator-geronimo/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockConnectorConfigBuilder.java
  
  Index: MockConnectorConfigBuilder.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockConnectorConfigBuilder.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MockConnectorConfigBuilder.java	7 Aug 2004 11:22:12 -0000	1.4
  +++ MockConnectorConfigBuilder.java	9 Aug 2004 04:19:35 -0000	1.5
  @@ -23,7 +23,6 @@
   
   import junit.framework.Assert;
   
  -import org.apache.geronimo.deployment.DeploymentException;
   import org.apache.xmlbeans.XmlObject;
   import org.apache.xmlbeans.SchemaTypeLoader;
   
  @@ -55,12 +54,17 @@
           return null;
       }
   
  -    public void installModule(File earFolder, EARContext earContext,
  -        Module module) throws DeploymentException {
  +    public void installModule(File earFolder, EARContext earContext, Module connectorModule) {
           assertNotNull(earFolder);
           assertNotNull(earContext);
           this.earContext = earContext;
           assertEquals(this.connectorModule, connectorModule);
  +        if ( null != this.connectorModule.getAltSpecDD() ) {
  +            assertEquals(this.connectorModule.getAltSpecDD(), connectorModule.getAltSpecDD());
  +        }
  +        if ( null != this.connectorModule.getAltVendorDD() ) {
  +            assertEquals(this.connectorModule.getAltVendorDD(), connectorModule.getAltVendorDD());
  +        }
       }
       
       public void installModule(JarFile earFile, EARContext earContext, Module connectorModule) {
  @@ -68,6 +72,12 @@
           assertNotNull(earContext);
           this.earContext = earContext;
           assertEquals(this.connectorModule, connectorModule);
  +        if ( null != this.connectorModule.getAltSpecDD() ) {
  +            assertEquals(this.connectorModule.getAltSpecDD(), connectorModule.getAltSpecDD());
  +        }
  +        if ( null != this.connectorModule.getAltVendorDD() ) {
  +            assertEquals(this.connectorModule.getAltVendorDD(), connectorModule.getAltVendorDD());
  +        }
       }
   
       public void initContext(EARContext earContext, Module connectorModule, ClassLoader cl) {
  
  
  
  1.22      +71 -19    incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
  
  Index: JettyModuleBuilder.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- JettyModuleBuilder.java	7 Aug 2004 11:22:13 -0000	1.21
  +++ JettyModuleBuilder.java	9 Aug 2004 04:19:35 -0000	1.22
  @@ -244,7 +244,10 @@
                   webApp = getWebAppDocument(ddInputStream).getWebApp();
                   webModule.setSpecDD(webApp);
               } catch (XmlException e) {
  -                throw new DeploymentException("Unable to parse web.xml", e);
  +                throw new DeploymentException("Unable to parse " +
  +                    (null == webModule.getAltSpecDD() ?
  +                        "WEB-INF/web.xml":
  +                            webModule.getAltSpecDD().toString()), e);
               }
   
               // load the geronimo-jetty.xml file
  @@ -261,10 +264,19 @@
                       jettyWebApp = doc.getWebApp();
                       webModule.setVendorDD(jettyWebApp);
                   } catch (XmlException e) {
  -                    throw new DeploymentException("Unable to parse openejb-jar.xml");
  +                    throw new DeploymentException("Unable to parse " +
  +                        (null == webModule.getAltVendorDD() ?
  +                            "WEB-INF/geronimo-jetty.xml":
  +                                webModule.getAltVendorDD().toString()), e);
                   }
               }
  -            
  +
  +            // TODO gets rid of these tests when Jetty will use the
  +            // serialized Geronimo DD.
  +            if ( null != webModule.getAltSpecDD()) {
  +                earContext.addFile(moduleBase.resolve("WEB-INF/web.xml"), webModule.getAltSpecDD().openStream());
  +            }
  +
               // add the warfile's content to the configuration
               callback.installInEARContext(earContext, moduleBase);
   
  @@ -553,25 +565,39 @@
           return baos.toByteArray();
       }
   
  -    private interface InstallCallback {
  +    private static abstract class InstallCallback {
           
  -        public void installInEARContext(EARContext earContext, URI moduleBase) throws DeploymentException, IOException;
  +        protected final Module webModule;
           
  -        public InputStream getWebDD() throws DeploymentException, IOException;
  +        private InstallCallback(Module webModule) {
  +            this.webModule = webModule;
  +        }
  +        
  +        public abstract void installInEARContext(EARContext earContext, URI moduleBase) throws DeploymentException, IOException;
           
  -        public InputStream getGeronimoJettyDD() throws DeploymentException, IOException;
  +        public InputStream getWebDD() throws DeploymentException, IOException {
  +            if ( null == webModule.getAltSpecDD() ) {
  +                return null;
  +            }
  +            return webModule.getAltSpecDD().openStream();
  +        }
  +        
  +        public InputStream getGeronimoJettyDD() throws DeploymentException, IOException {
  +            if ( null == webModule.getAltVendorDD() ) {
  +                return null;
  +            }
  +            return webModule.getAltVendorDD().openStream();
  +        }
   
       }
   
  -    private static final class UnPackedInstallCallback implements InstallCallback {
  +    private static final class UnPackedInstallCallback extends InstallCallback {
           
           private final File webFolder;
           
  -        private final Module webModule;
  -        
           private UnPackedInstallCallback(Module webModule, File webFolder) {
  +            super(webModule);
               this.webFolder = webFolder;
  -            this.webModule = webModule;
           }
           
           public void installInEARContext(EARContext earContext, URI moduleBase) throws DeploymentException, IOException {
  @@ -583,11 +609,21 @@
                   File file = (File) iter.next();
                   URI fileURI = warRoot.relativize(file.toURI());
                   URI target = moduleBase.resolve(fileURI);
  -                earContext.addFile(target, file);
  +                // TODO gets rid of these tests when Jetty will use the
  +                // serialized Geronimo DD.
  +                if ( fileURI.equals("WEB-INF/web.xml") &&
  +                    null != webModule.getAltSpecDD()) {
  +                } else {
  +                    earContext.addFile(target, file);
  +                }
               }
           }
           
           public InputStream getWebDD() throws DeploymentException, IOException {
  +            InputStream in = super.getWebDD();
  +            if ( null != in ) {
  +                return in;
  +            }
               File webAppFile = new File(webFolder, "WEB-INF/web.xml");
               if ( !webAppFile.exists() ) {
                   throw new DeploymentException("No WEB-INF/web.xml in module [" + webModule.getName() + "]");
  @@ -596,6 +632,10 @@
           }
           
           public InputStream getGeronimoJettyDD() throws DeploymentException, IOException {
  +            InputStream in = super.getGeronimoJettyDD();
  +            if ( null != in ) {
  +                return in;
  +            }
               File jettyWebAppFile = new File(webFolder, "WEB-INF/geronimo-jetty.xml");
               if ( jettyWebAppFile.exists() ) {
                   return new FileInputStream(jettyWebAppFile);
  @@ -605,26 +645,34 @@
           
       }
   
  -    private static final class PackedInstallCallback implements InstallCallback {
  +    private static final class PackedInstallCallback extends InstallCallback {
   
  -        private final Module webModule;
  -        
           private final JarFile webAppFile;
           
           private PackedInstallCallback(Module webModule, JarFile webAppFile) {
  -            this.webModule = webModule;
  +            super(webModule);
               this.webAppFile = webAppFile;
           }
  -        
  +
           public void installInEARContext(EARContext earContext, URI moduleBase) throws DeploymentException, IOException {
               JarInputStream jarIS = new JarInputStream(new FileInputStream(webAppFile.getName()));
               for (JarEntry entry; (entry = jarIS.getNextJarEntry()) != null; jarIS.closeEntry()) {
                   URI target = moduleBase.resolve(entry.getName());
  -                earContext.addFile(target, jarIS);
  +                // TODO gets rid of these tests when Jetty will use the
  +                // serialized Geronimo DD.
  +                if ( entry.getName().equals("WEB-INF/web.xml") &&
  +                    null != webModule.getAltSpecDD() ) {
  +                } else {
  +                    earContext.addFile(target, jarIS);
  +                }
               }
           }
           
           public InputStream getWebDD() throws DeploymentException, IOException {
  +            InputStream in = super.getWebDD();
  +            if ( null != in ) {
  +                return in;
  +            }
               JarEntry entry = webAppFile.getJarEntry("WEB-INF/web.xml");
               if (entry == null) {
                   throw new DeploymentException("No WEB-INF/web.xml in module [" + webModule.getName() + "]");
  @@ -633,6 +681,10 @@
           }
           
           public InputStream getGeronimoJettyDD() throws DeploymentException, IOException {
  +            InputStream in = super.getGeronimoJettyDD();
  +            if ( null != in ) {
  +                return in;
  +            }
               JarEntry entry = webAppFile.getJarEntry("WEB-INF/geronimo-jetty.xml");
               if (entry != null) {
                   return webAppFile.getInputStream(entry);
  
  
  
  1.3       +51 -0     incubator-geronimo/modules/j2ee/src/schema/geronimo-application.xsd
  
  Index: geronimo-application.xsd
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/j2ee/src/schema/geronimo-application.xsd,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- geronimo-application.xsd	23 Jun 2004 20:24:45 -0000	1.2
  +++ geronimo-application.xsd	9 Aug 2004 04:19:35 -0000	1.3
  @@ -32,9 +32,60 @@
           <xs:sequence>
               <xs:element name="dependency" type="geronimo:dependencyType" minOccurs="0" maxOccurs="unbounded"/>
               <xs:element name="gbean" type="geronimo:gbeanType" minOccurs="0" maxOccurs="unbounded"/>
  +            <xs:element name="module" type="geronimo:moduleType" minOccurs="0" maxOccurs="unbounded"/>
           </xs:sequence>
   
           <xs:attribute name="configId" type="xs:string" use="required"/>
           <xs:attribute name="parentId" type="xs:string" use="optional"/>
       </xs:complexType>
  +    
  +    <xs:complexType name="moduleType">
  +        <xs:annotation>
  +            <xs:documentation>
  +	Mirrors the moduleType defined by application_1_4.xsd and adds an
  +	optional alt-dd element defining a Geronimo specific deployment descriptor.
  +            </xs:documentation>
  +        </xs:annotation>
  +        <xs:sequence>
  +            <xs:choice>
  +	            <xs:element name="connector" type="geronimo:pathType"/>
  +                <xs:element name="ejb" type="geronimo:pathType"/>
  +                <xs:element name="java" type="geronimo:pathType"/>
  +                <xs:element name="web" type="geronimo:pathType"/>
  +            </xs:choice>
  +            <xs:element name="alt-dd" type="geronimo:pathType" minOccurs="0">
  +	            <xs:annotation>
  +	                <xs:documentation>
  +  Specifies an optional URI to the post-assembly version of the Geronimo
  +  specific deployment descriptor file for a particular J2EE module.
  +                    </xs:documentation>
  +                </xs:annotation>
  +            </xs:element>
  +        </xs:sequence>
  +    </xs:complexType>
  +    
  +    <xs:complexType name="pathType">
  +        <xs:annotation>
  +            <xs:documentation>
  +  Mirrors j2ee:pathType.
  +            </xs:documentation>
  +        </xs:annotation>
  +        <xs:simpleContent>
  +            <xs:restriction base="geronimo:string"/>
  +        </xs:simpleContent>
  +    </xs:complexType>
  +    
  +    <xs:complexType name="string">
  +        <xs:annotation>
  +            <xs:documentation>
  +   Mirrors j2ee:string.
  +            </xs:documentation>
  +        </xs:annotation>
  +        <xs:simpleContent>
  +            <xs:extension base="xs:token">
  +	            <xs:attribute name="id" type="xs:ID"/>
  +            </xs:extension>
  +        </xs:simpleContent>
  +    </xs:complexType>
  +    
   </xs:schema>
  
  
  
  1.13      +50 -17    incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
  
  Index: ConnectorModuleBuilder.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ConnectorModuleBuilder.java	7 Aug 2004 11:22:12 -0000	1.12
  +++ ConnectorModuleBuilder.java	9 Aug 2004 04:19:35 -0000	1.13
  @@ -232,9 +232,11 @@
                       ConnectorDocument connectorDoc = ConnectorDocument.Factory.parse(callback.getRaDD());
                       SchemaConversionUtils.validateDD(connectorDoc);
                       specConnnector = connectorDoc.getConnector();
  -                } catch (XmlException alsoIgnore) {
  -                    throw new DeploymentException(
  -                        "Could not parse META-INF/ra.xml");
  +                } catch (XmlException e) {
  +                    throw new DeploymentException("Unable to parse " +
  +                        (null == module.getAltSpecDD() ? 
  +                            "META-INF/ra.xml":
  +                                module.getAltSpecDD().toString()), e);
                   }
               }
               module.setSpecDD(specConnnector);
  @@ -252,7 +254,10 @@
                       vendorConnector = doc.getConnector();
                       module.setVendorDD(vendorConnector);
                   } catch (XmlException e) {
  -                    throw new DeploymentException("Unable to parse geronimo-ra.xml");
  +                    throw new DeploymentException("Unable to parse " +
  +                        (null == module.getAltVendorDD() ?
  +                            "geronimo-ra.xml":
  +                                module.getAltVendorDD().toString()), e);
                   }
               }
   
  @@ -824,25 +829,39 @@
           }
       }
   
  -    private interface InstallCallback {
  +    private static abstract class InstallCallback {
  +        
  +        protected final Module rarModule;
  +        
  +        private InstallCallback(Module rarModule) {
  +            this.rarModule = rarModule;
  +        }
           
  -        public void installInEARContext(EARContext earContext, URI moduleBase) throws DeploymentException, IOException;
  +        public abstract void installInEARContext(EARContext earContext, URI moduleBase) throws DeploymentException, IOException;
           
  -        public InputStream getRaDD() throws DeploymentException, IOException;
  +        public InputStream getRaDD() throws DeploymentException, IOException {
  +            if ( null == rarModule.getAltSpecDD() ) {
  +                return null;
  +            }
  +            return rarModule.getAltSpecDD().openStream();
  +        }
           
  -        public InputStream getGeronimoRaDD() throws DeploymentException, IOException;
  +        public InputStream getGeronimoRaDD() throws DeploymentException, IOException {
  +            if ( null == rarModule.getAltVendorDD() ) {
  +                return null;
  +            }
  +            return rarModule.getAltVendorDD().openStream();
  +        }
   
       }
       
  -    private static final class UnPackedInstallCallback implements InstallCallback {
  +    private static final class UnPackedInstallCallback extends InstallCallback {
           
           private final File rarFolder;
           
  -        private final Module rarModule;
  -        
           private UnPackedInstallCallback(Module rarModule, File rarFolder) {
  +            super(rarModule);
               this.rarFolder = rarFolder;
  -            this.rarModule = rarModule;
           }
           
           public void installInEARContext(EARContext earContext, URI moduleBase) throws DeploymentException, IOException {
  @@ -862,6 +881,10 @@
           }
           
           public InputStream getRaDD() throws DeploymentException, IOException {
  +            InputStream in = super.getRaDD();
  +            if (null != in) {
  +                return in;
  +            }
               File raFile = new File(rarFolder, "META-INF/ra.xml");
               if ( !raFile.exists() ) {
                   throw new DeploymentException("No  in module [" + rarModule.getName() + "]");
  @@ -870,6 +893,10 @@
           }
           
           public InputStream getGeronimoRaDD() throws DeploymentException, IOException {
  +            InputStream in = super.getGeronimoRaDD();
  +            if (null != in) {
  +                return in;
  +            }
               File geronimoRaFile = new File(rarFolder, "META-INF/geronimo-ra.xml");
               if ( geronimoRaFile.exists() ) {
                   return new FileInputStream(geronimoRaFile);
  @@ -879,14 +906,12 @@
           
       }
       
  -    private static final class PackedInstallCallback implements InstallCallback {
  +    private static final class PackedInstallCallback extends InstallCallback {
   
  -        private final Module rarModule;
  -        
           private final JarFile rarFile;
           
           private PackedInstallCallback(Module rarModule, JarFile rarFile) {
  -            this.rarModule = rarModule;
  +            super(rarModule);
               this.rarFile = rarFile;
           }
           
  @@ -903,6 +928,10 @@
           }
           
           public InputStream getRaDD() throws DeploymentException, IOException {
  +            InputStream in = super.getRaDD();
  +            if (null != in) {
  +                return in;
  +            }
               JarEntry entry = rarFile.getJarEntry("META-INF/ra.xml");
               if (entry == null) {
                   throw new DeploymentException("No META-INF/ra.xml in module [" + rarModule.getName() + "]");
  @@ -911,6 +940,10 @@
           }
           
           public InputStream getGeronimoRaDD() throws DeploymentException, IOException {
  +            InputStream in = super.getGeronimoRaDD();
  +            if (null != in) {
  +                return in;
  +            }
               JarEntry entry = rarFile.getJarEntry("META-INF/geronimo-ra.xml");
               if (entry != null) {
                   return rarFile.getInputStream(entry);
  
  
  
  1.6       +24 -2     incubator-geronimo/modules/j2ee/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/j2ee/maven.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- maven.xml	7 Aug 2004 11:22:13 -0000	1.5
  +++ maven.xml	9 Aug 2004 04:19:36 -0000	1.6
  @@ -105,7 +105,10 @@
           <j:set var="ear.unpacked.relative" value="full"/>
           <attainGoal name="setupBaseUnpackedEar"/>
           <copy todir="${basedir}/target/test-unpacked-ear/${ear.unpacked.relative}/META-INF">
  -            <fileset dir="${basedir}/src/test-unpacked-ear/META-INF"/>
  +            <fileset dir="${basedir}/src/test-unpacked-ear/META-INF">
  +                <include name="application.xml"/>
  +                <include name="geronimo-application.xml"/>
  +            </fileset>
           </copy>
           
           <j:set var="ear.unpacked.relative" value="naked"/>
  @@ -115,6 +118,25 @@
                   <include name="application.xml"/>
               </fileset>
           </copy>
  +        
  +        <j:set var="ear.unpacked.relative" value="alt-dd"/>
  +        <attainGoal name="setupBaseUnpackedEar"/>
  +        <copy todir="${basedir}/target/test-unpacked-ear/${ear.unpacked.relative}/META-INF">
  +            <fileset dir="${basedir}/src/test-unpacked-ear/META-INF">
  +                <include name="application-alt-dd.xml"/>
  +            </fileset>
  +            <mapper type="merge" to="application.xml"/>
  +        </copy>
  +        <copy todir="${basedir}/target/test-unpacked-ear/${ear.unpacked.relative}/META-INF">
  +            <fileset dir="${basedir}/src/test-unpacked-ear/META-INF">
  +                <include name="geronimo-application-alt-dd.xml"/>
  +            </fileset>
  +            <mapper type="merge" to="geronimo-application.xml"/>
  +        </copy>
  +        
  +        <ant:jar destfile="${basedir}/target/test-unpacked-ear/alt-dd.ear">
  +            <fileset dir="${basedir}/target/test-unpacked-ear/${ear.unpacked.relative}"/>
  +        </ant:jar>
       </goal>
       
       <goal name="setupBaseUnpackedEar">
  
  
  
  1.14      +68 -4     incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java
  
  Index: RAR_1_0ConfigBuilderTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- RAR_1_0ConfigBuilderTest.java	6 Aug 2004 22:44:36 -0000	1.13
  +++ RAR_1_0ConfigBuilderTest.java	9 Aug 2004 04:19:36 -0000	1.14
  @@ -34,11 +34,13 @@
   import java.util.Set;
   import java.util.jar.JarFile;
   import java.util.jar.JarOutputStream;
  +
   import javax.management.ObjectName;
   import javax.sql.DataSource;
   
   import junit.framework.TestCase;
   
  +import org.apache.geronimo.deployment.DeploymentException;
   import org.apache.geronimo.gbean.GBeanInfo;
   import org.apache.geronimo.gbean.jmx.GBeanMBean;
   import org.apache.geronimo.j2ee.deployment.EARContext;
  @@ -92,14 +94,76 @@
                   return rarFile;
               }
               public void install(ModuleBuilder moduleBuilder, EARContext earContext, Module module) throws Exception {
  -                // TODO gets rid of this cast when all the ModuleBuilder
  -                // will implement this method.
  -                ((ConnectorModuleBuilder) moduleBuilder).installModule(rarFile, earContext, module);
  +                moduleBuilder.installModule(rarFile, earContext, module);
               }
           };
           executeTestBuildModule(action);
       }
  +
  +    public void testBuildUnpackedAltSpecDDModule() throws Exception {
  +        InstallAction action = new InstallAction() {
  +            private File rarFile = new File("target/test-rar-10");
  +            public File getRARFile() {
  +                return rarFile;
  +            }
  +            public void install(ModuleBuilder moduleBuilder, EARContext earContext, Module module) throws Exception {
  +                // Resets the vendor DD, such that it will be reloaded.
  +                module.setVendorDD(null);
  +                // this file does not exist, one expects a DeploymentException.
  +                module.setAltSpecDD(new File("target/test-rar-10/dummy.xml").toURL());
  +                // this file exists
  +                module.setAltVendorDD(new File("target/test-rar-10/META-INF/geronimo-ra.xml").toURL());
  +                moduleBuilder.installModule(rarFile, earContext, module);
  +            }
  +        };
  +        try {
  +            executeTestBuildModule(action);
  +            fail("Spec alt-dd does not exist.");
  +        } catch (DeploymentException e) {
  +        }
  +    }
  +
  +    public void testBuildUnpackedAltVendorDDModule() throws Exception {
  +        InstallAction action = new InstallAction() {
  +            private File rarFile = new File("target/test-rar-10");
  +            public File getRARFile() {
  +                return rarFile;
  +            }
  +            public void install(ModuleBuilder moduleBuilder, EARContext earContext, Module module) throws Exception {
  +                // Resets the vendor DD, such that it will be reloaded.
  +                module.setVendorDD(null);
  +                // this file exists
  +                module.setAltSpecDD(new File("target/test-rar-10/META-INF/ra.xml").toURL());
  +                // this file does not exist, one expects a DeploymentException.
  +                module.setAltVendorDD(new File("target/test-rar-10/dummy.xml").toURL());
  +                moduleBuilder.installModule(rarFile, earContext, module);
  +            }
  +        };
  +        try {
  +            executeTestBuildModule(action);
  +            fail("Vendor alt-dd does not exist.");
  +        } catch (DeploymentException e) {
  +        }
  +    }
       
  +    public void testBuildUnpackedAltSpecVendorDDModule() throws Exception {
  +        InstallAction action = new InstallAction() {
  +            private File rarFile = new File("target/test-rar-10");
  +            public File getRARFile() {
  +                return rarFile;
  +            }
  +            public void install(ModuleBuilder moduleBuilder, EARContext earContext, Module module) throws Exception {
  +                // Resets the vendor DD, such that it will be reloaded.
  +                module.setVendorDD(null);
  +                // this file exists
  +                module.setAltSpecDD(new File("target/test-rar-10/META-INF/ra.xml").toURL());
  +                // this file exists
  +                module.setAltVendorDD(new File("target/test-rar-10/META-INF/geronimo-ra.xml").toURL());
  +                moduleBuilder.installModule(rarFile, earContext, module);
  +            }
  +        };
  +        executeTestBuildModule(action);
  +    }
       
       public void testBuildPackedModule() throws Exception {
           InstallAction action = new InstallAction() {
  
  
  

Mime
View raw message