geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: rev 47129 - in geronimo/trunk/modules: client-builder/src/java/org/apache/geronimo/client/builder connector/src/java/org/apache/geronimo/connector/deployment connector/src/test/org/apache/geronimo/connector/deployment deployment/src/java/org/apache/geronimo/deployment/util j2ee-schema/src/java/org/apache/geronimo/schema j2ee/src/java/org/apache/geronimo/j2ee/deployment j2ee/src/test/org/apache/geronimo/j2ee/deployment jetty/src/java/org/apache/geronimo/jetty/deployment
Date Thu, 23 Sep 2004 23:46:20 GMT
Author: dain
Date: Thu Sep 23 16:46:18 2004
New Revision: 47129

Added:
   geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/IOUtil.java
Modified:
   geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
   geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
   geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java
   geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/AppClientModule.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ConnectorModule.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EJBModule.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/Module.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ModuleBuilder.java
   geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/WebModule.java
   geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
   geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockConnectorConfigBuilder.java
   geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockEJBConfigBuilder.java
   geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockWARConfigBuilder.java
   geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
Log:
Cleaned up handling of specDDs so orignial dd is returned from 77 modules and web.xml is not
overwritten with an upgraded dd
Cleaned up generation of the base URI used for ref resolution


Modified: geronimo/trunk/modules/client-builder/src/java/org/apache/geronimo/client/builder/AppClientModuleBuilder.java
==============================================================================
--- 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 Sep 23 16:46:18 2004
@@ -43,6 +43,7 @@
 import org.apache.geronimo.deployment.service.GBeanHelper;
 import org.apache.geronimo.deployment.util.FileUtil;
 import org.apache.geronimo.deployment.util.JarUtil;
+import org.apache.geronimo.deployment.util.IOUtil;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoFactory;
 import org.apache.geronimo.gbean.jmx.GBeanMBean;
@@ -113,6 +114,16 @@
         }
     }
 
+    public XmlObject parseSpecDD(String specDD) throws DeploymentException {
+        try {
+            // check if we have an alt spec dd
+            ApplicationClientDocument applicationClientDoc = ApplicationClientDocument.Factory.parse(specDD);
+            return applicationClientDoc.getApplicationClient();
+        } catch (Exception e) {
+            throw new DeploymentException("Unable to parse specDD", e);
+        }
+    }
+
     public XmlObject getDeploymentPlan(URL module) throws XmlException {
         try {
             URL moduleBase;
@@ -202,12 +213,29 @@
     }
 
     public Module createModule(String name, JarFile moduleFile, XmlObject vendorDD) throws
DeploymentException {
-        return createModule(name, URI.create("/"), moduleFile, "app-client", vendorDD, null);
+        return createModule(name, moduleFile, vendorDD, "app-client", null);
     }
 
-    public Module createModule(String name, URI moduleURI, JarFile moduleFile, String targetPath,
XmlObject vendorDD, URL specDD) throws DeploymentException {
-        if (specDD == null) {
-            specDD = JarUtil.createJarURL(moduleFile, "META-INF/application-client.xml");
+    public Module createModule(String name, JarFile moduleFile, XmlObject vendorDD, String
targetPath, URL specDDUrl) throws DeploymentException {
+        URI moduleURI;
+        if (targetPath != null) {
+            moduleURI = URI.create(targetPath);
+            if (targetPath.endsWith("/")) {
+                throw new DeploymentException("targetPath must not end with a '/'");
+            }
+        } else {
+            targetPath = "app-client";
+            moduleURI = URI.create("");
+        }
+
+        if (specDDUrl == null) {
+            specDDUrl = JarUtil.createJarURL(moduleFile, "META-INF/application-client.xml");
+        }
+        String specDD;
+        try {
+            specDD = IOUtil.readAll(specDDUrl);
+        } catch (IOException e) {
+            throw new DeploymentException("Unable to read specDD: " + specDDUrl.toExternalForm());
         }
         ApplicationClientType appClient = (ApplicationClientType) parseSpecDD(specDD);
 

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
(original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/deployment/ConnectorModuleBuilder.java
Thu Sep 23 16:46:18 2004
@@ -52,6 +52,7 @@
 import org.apache.geronimo.deployment.DeploymentException;
 import org.apache.geronimo.deployment.service.GBeanHelper;
 import org.apache.geronimo.deployment.util.JarUtil;
+import org.apache.geronimo.deployment.util.IOUtil;
 import org.apache.geronimo.gbean.DynamicGAttributeInfo;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoFactory;
@@ -105,45 +106,35 @@
     private static final String BASE_WORK_MANAGER_NAME = "geronimo.server:type=WorkManager,name=";
 
     public XmlObject parseSpecDD(URL path) throws DeploymentException {
-        InputStream in = null;
+        String specDD;
+        try {
+            specDD = IOUtil.readAll(path);
+        } catch (IOException e) {
+            throw new DeploymentException("Unable to read specDD: " + path.toExternalForm());
+        }
+        return parseSpecDD(specDD);
+    }
+
+    public XmlObject parseSpecDD(String specDD) throws DeploymentException {
         try {
             // try 1.0
-            in = path.openStream();
-            ConnectorDocument10 connectorDoc = ConnectorDocument10.Factory.parse(in);
+            ConnectorDocument10 connectorDoc = ConnectorDocument10.Factory.parse(specDD);
             SchemaConversionUtils.validateDD(connectorDoc);
             return connectorDoc.getConnector();
         } catch (Exception ignore) {
             // ignore
-        } finally {
-            if (in != null) {
-                try {
-                    in.close();
-                } catch (IOException e) {
-                    // ignore
-                }
-            }
         }
 
         // that didn't work try 1.5
-        in = null;
         try {
-            in = path.openStream();
-            ConnectorDocument connectorDoc = ConnectorDocument.Factory.parse(in);
+            ConnectorDocument connectorDoc = ConnectorDocument.Factory.parse(specDD);
             SchemaConversionUtils.validateDD(connectorDoc);
             return connectorDoc.getConnector();
         } catch (Exception e) {
             // ignore
-        } finally {
-            if (in != null) {
-                try {
-                    in.close();
-                } catch (IOException e) {
-                    // ignore
-                }
-            }
         }
 
-        throw new DeploymentException("Unable to parse " + path);
+        throw new DeploymentException("Unable to parse specDD");
     }
 
     public XmlObject parseVendorDD(URL url) throws XmlException {
@@ -191,12 +182,31 @@
     }
 
     public Module createModule(String name, JarFile moduleFile, XmlObject vendorDD) throws
DeploymentException {
-        return createModule(name, URI.create("/"), moduleFile, "connector", vendorDD, null);
+        return createModule(name, moduleFile, vendorDD, "connector", null);
     }
 
-    public Module createModule(String name, URI moduleURI, JarFile moduleFile, String targetPath,
XmlObject vendorDD, URL specDD) throws DeploymentException {
-        if (specDD == null) {
-            specDD = JarUtil.createJarURL(moduleFile, "META-INF/ra.xml");
+    public Module createModule(String name, JarFile moduleFile, XmlObject vendorDD, String
targetPath, URL specDDUrl) throws DeploymentException {
+        URI moduleURI;
+        if (targetPath != null) {
+            moduleURI = URI.create(targetPath);
+            if (targetPath.endsWith("/")) {
+                throw new DeploymentException("targetPath must not end with a '/'");
+            }
+            targetPath += "/";
+        } else {
+            targetPath = "connector/";
+            moduleURI = URI.create("");
+        }
+
+
+        if (specDDUrl == null) {
+            specDDUrl = JarUtil.createJarURL(moduleFile, "META-INF/ra.xml");
+        }
+        String specDD;
+        try {
+            specDD = IOUtil.readAll(specDDUrl);
+        } catch (IOException e) {
+            throw new DeploymentException("Unable to read specDD: " + specDDUrl.toExternalForm());
         }
         XmlObject connector = parseSpecDD(specDD);
 
@@ -220,16 +230,12 @@
         GerConnectorDocument geronimoConnectorDoc = (GerConnectorDocument) vendorDD;
         GerConnectorType geronimoConnector = geronimoConnectorDoc.getConnector();
 
-        return new ConnectorModule(name, moduleURI, moduleFile, targetPath, connector, geronimoConnector);
+        return new ConnectorModule(name, moduleURI, moduleFile, targetPath, connector, geronimoConnector,
specDD);
     }
 
     public void installModule(JarFile earFile, EARContext earContext, Module module) throws
DeploymentException {
         try {
-            String targetPath = module.getTargetPath();
-            if (!targetPath.endsWith("/")) {
-                targetPath += "/";
-            }
-            URI targetURI = URI.create(targetPath);
+            URI targetURI = URI.create(module.getTargetPath());
 
             JarFile moduleFile = module.getModuleFile();
 
@@ -311,16 +317,7 @@
                 resourceAdapterModule.setReferencePatterns("J2EEApplication", Collections.singleton(earContext.getApplicationObjectName()));
             }
 
-            XmlObject specDD = module.getSpecDD();
-            if (specDD instanceof ConnectorType10) {
-                ConnectorDocument10 connectorDoc = ConnectorDocument10.Factory.newInstance();
-                connectorDoc.setConnector((ConnectorType10) specDD);
-                resourceAdapterModule.setAttribute("deploymentDescriptor", connectorDoc.toString());
-            } else {
-                ConnectorDocument connectorDoc = ConnectorDocument.Factory.newInstance();
-                connectorDoc.setConnector((ConnectorType) specDD);
-                resourceAdapterModule.setAttribute("deploymentDescriptor", connectorDoc.toString());
-            }
+            resourceAdapterModule.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
         } catch (Exception e) {
             throw new DeploymentException("Unable to initialize EJBModule GBean", e);
         }

Modified: geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java
==============================================================================
--- geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java
(original)
+++ geronimo/trunk/modules/connector/src/test/org/apache/geronimo/connector/deployment/RAR_1_0ConfigBuilderTest.java
Thu Sep 23 16:46:18 2004
@@ -233,7 +233,7 @@
         URI configId = moduleBuilder.getConfigId(plan);
         assertEquals(j2eeModuleName, configId.toString());
 
-        Module module = moduleBuilder.createModule(configId.toString(), URI.create("/"),
rarJarFile, "connector", plan, action.getSpecDD());
+        Module module = moduleBuilder.createModule(configId.toString(), rarJarFile, plan,
"connector", action.getSpecDD());
 
         File carFile = File.createTempFile("RARTest", ".car");
         try {

Added: geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/IOUtil.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/util/IOUtil.java
Thu Sep 23 16:46:18 2004
@@ -0,0 +1,86 @@
+/**
+ *
+ * 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.
+ */
+package org.apache.geronimo.deployment.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.Writer;
+import java.io.InputStreamReader;
+import java.net.URL;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class IOUtil {
+    public static void close(InputStream thing) {
+        if (thing != null) {
+            try {
+                thing.close();
+            } catch(Exception ignored) {
+            }
+        }
+    }
+
+    public static void close(OutputStream thing) {
+        if (thing != null) {
+            try {
+                thing.close();
+            } catch(Exception ignored) {
+            }
+        }
+    }
+
+    public static void close(Reader thing) {
+        if (thing != null) {
+            try {
+                thing.close();
+            } catch(Exception ignored) {
+            }
+        }
+    }
+
+    public static void close(Writer thing) {
+        if (thing != null) {
+            try {
+                thing.close();
+            } catch(Exception ignored) {
+            }
+        }
+    }
+
+    public static String readAll(Reader thing) throws IOException {
+        char[] buffer = new char[4000];
+        StringBuffer out = new StringBuffer();
+
+        for(int count = thing.read(buffer); count >= 0; count = thing.read(buffer)) {
+            out.append(buffer, 0, count);
+        }
+        return out.toString();
+    }
+
+    public static String readAll(URL url) throws IOException {
+        Reader reader = null;
+        try {
+            reader = new InputStreamReader(url.openStream());
+            return IOUtil.readAll(reader);
+        } finally {
+            IOUtil.close(reader);
+        }
+    }
+}

Modified: geronimo/trunk/modules/j2ee-schema/src/java/org/apache/geronimo/schema/SchemaConversionUtils.java
==============================================================================
--- 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 Sep 23 16:46:18 2004
@@ -53,6 +53,18 @@
         return parsed;
     }
 
+    public static XmlObject parse(String xml) throws XmlException {
+        ArrayList errors = new ArrayList();
+        XmlOptions options = new XmlOptions();
+        options.setLoadLineNumbers();
+        options.setErrorListener(errors);
+        XmlObject parsed = XmlObject.Factory.parse(xml, options);
+        if (errors.size() != 0) {
+            throw new XmlException(errors.toArray().toString());
+        }
+        return parsed;
+    }
+
     public static ApplicationDocument convertToApplicationSchema(XmlObject xmlObject) throws
XmlException {
         if (ApplicationDocument.type.equals(xmlObject.schemaType())) {
             validateDD(xmlObject);

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/AppClientModule.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/AppClientModule.java
(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/AppClientModule.java
Thu Sep 23 16:46:18 2004
@@ -26,7 +26,7 @@
  */
 public class AppClientModule extends Module {
     public AppClientModule(String name, URI moduleURI, JarFile moduleFile, String targetPath,
XmlObject specDD, XmlObject vendorDD) {
-        super(name, moduleURI, moduleFile, targetPath, specDD, vendorDD);
+        super(name, moduleURI, moduleFile, targetPath, specDD, vendorDD, null);
     }
 }
 

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ConnectorModule.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ConnectorModule.java
(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ConnectorModule.java
Thu Sep 23 16:46:18 2004
@@ -25,8 +25,8 @@
  * @version $Rev$ $Date$
  */
 public class ConnectorModule extends Module {
-    public ConnectorModule(String name, URI moduleURI, JarFile moduleFile, String targetPath,
XmlObject specDD, XmlObject vendorDD) {
-        super(name, moduleURI, moduleFile, targetPath, specDD, vendorDD);
+    public ConnectorModule(String name, URI moduleURI, JarFile moduleFile, String targetPath,
XmlObject specDD, XmlObject vendorDD, String originalSpecDD) {
+        super(name, moduleURI, moduleFile, targetPath, specDD, vendorDD, originalSpecDD);
     }
 }
 

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EARConfigBuilder.java
Thu Sep 23 16:46:18 2004
@@ -467,7 +467,7 @@
                         }
                     }
 
-                    Module module = builder.createModule(modulePath, URI.create(modulePath),
new NestedJarFile(earFile, modulePath), modulePath, vendorDD, altSpecDD);
+                    Module module = builder.createModule(modulePath, new NestedJarFile(earFile,
modulePath), vendorDD, modulePath, altSpecDD);
                     if (module instanceof WebModule) {
                         ((WebModule)module).setContextRoot(webContextRoot);
                     }

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EJBModule.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EJBModule.java
(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/EJBModule.java
Thu Sep 23 16:46:18 2004
@@ -25,8 +25,8 @@
  * @version $Rev$ $Date$
  */
 public class EJBModule extends Module {
-    public EJBModule(String name, URI moduleURI, JarFile moduleFile, String targetPath, XmlObject
specDD, XmlObject vendorDD) {
-        super(name, moduleURI, moduleFile, targetPath, specDD, vendorDD);
+    public EJBModule(String name, URI moduleURI, JarFile moduleFile, String targetPath, XmlObject
specDD, XmlObject vendorDD, String originalSpecDD) {
+        super(name, moduleURI, moduleFile, targetPath, specDD, vendorDD, originalSpecDD);
     }
 }
 

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/Module.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/Module.java	(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/Module.java	Thu
Sep 23 16:46:18 2004
@@ -31,14 +31,16 @@
     private final String targetPath;
     private final XmlObject specDD;
     private final XmlObject vendorDD;
+    private final String originalSpecDD;
 
-    public Module(String name, URI moduleURI, JarFile moduleFile, String targetPath, XmlObject
specDD, XmlObject vendorDD) {
+    public Module(String name, URI moduleURI, JarFile moduleFile, String targetPath, XmlObject
specDD, XmlObject vendorDD, String originalSpecDD) {
         this.name = name;
         this.moduleURI = moduleURI;
         this.moduleFile = moduleFile;
         this.targetPath = targetPath;
         this.specDD = specDD;
         this.vendorDD = vendorDD;
+        this.originalSpecDD = originalSpecDD;
     }
 
     public String getName() {
@@ -63,6 +65,10 @@
 
     public XmlObject getVendorDD() {
         return vendorDD;
+    }
+
+    public String getOriginalSpecDD() {
+        return originalSpecDD;
     }
 
     public int hashCode() {

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ModuleBuilder.java
(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/ModuleBuilder.java
Thu Sep 23 16:46:18 2004
@@ -39,7 +39,7 @@
 
     Module createModule(String name, JarFile moduleFile, XmlObject vendorDD) throws DeploymentException;
 
-    Module createModule(String name, URI moduleURI, JarFile moduleFile, String targetPath,
XmlObject vendorDD, URL specDD) throws DeploymentException;
+    Module createModule(String name, JarFile moduleFile, XmlObject vendorDD, String targetPath,
URL specDD) throws DeploymentException;
 
     URI getParentId(XmlObject plan) throws DeploymentException;
 

Modified: geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/WebModule.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/WebModule.java
(original)
+++ geronimo/trunk/modules/j2ee/src/java/org/apache/geronimo/j2ee/deployment/WebModule.java
Thu Sep 23 16:46:18 2004
@@ -27,8 +27,8 @@
 public class WebModule extends Module {
     private String contextRoot;
 
-    public WebModule(String name, URI moduleURI, JarFile moduleFile, String targetPath, XmlObject
specDD, XmlObject vendorDD) {
-        super(name, moduleURI, moduleFile, targetPath, specDD, vendorDD);
+    public WebModule(String name, URI moduleURI, JarFile moduleFile, String targetPath, XmlObject
specDD, XmlObject vendorDD, String originalSpecDD) {
+        super(name, moduleURI, moduleFile, targetPath, specDD, vendorDD, originalSpecDD);
     }
 
     public String getContextRoot() {

Modified: geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
(original)
+++ geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
Thu Sep 23 16:46:18 2004
@@ -53,11 +53,11 @@
         TestSetup setup14 = new TestSetup(inner) {
             protected void setUp() {
                 earFile = new File(basedir,  "target/test-ear14/test-ear.ear");
-                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar", URI.create("test-ejb-jar.jar"),
null, "test-ejb-jar.jar", null, null);
+                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar", URI.create("test-ejb-jar.jar"),
null, "test-ejb-jar.jar", null, null, null);
                 webConfigBuilder.contextRoot = "test";
-                webConfigBuilder.webModule = new WebModule("test-war.war", URI.create("test-war.war"),
null, "test-war.war", null, null);
+                webConfigBuilder.webModule = new WebModule("test-war.war", URI.create("test-war.war"),
null, "test-war.war", null, null, null);
                 webConfigBuilder.webModule.setContextRoot("test");
-                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar",
URI.create("test-rar.rar"), null, "test-rar.rar", null, null);
+                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar",
URI.create("test-rar.rar"), null, "test-rar.rar", null, null, null);
             }
 
             protected void tearDown() {
@@ -66,11 +66,11 @@
         TestSetup setupNaked14 = new TestSetup(inner) {
             protected void setUp() {
                 earFile = new File(basedir,  "target/test-ear14/test-naked-ear.ear");
-                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar", URI.create("test-ejb-jar.jar"),
null, "test-ejb-jar.jar", null, null);
+                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar", URI.create("test-ejb-jar.jar"),
null, "test-ejb-jar.jar", null, null, null);
                 webConfigBuilder.contextRoot = "test";
-                webConfigBuilder.webModule = new WebModule("test-war.war", URI.create("test-war.war"),
null, "test-war.war", null, null);
+                webConfigBuilder.webModule = new WebModule("test-war.war", URI.create("test-war.war"),
null, "test-war.war", null, null, null);
                 webConfigBuilder.webModule.setContextRoot("test");
-                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar",
URI.create("test-rar.rar"), null, "test-rar.rar", null, null);
+                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar",
URI.create("test-rar.rar"), null, "test-rar.rar", null, null, null);
             }
 
             protected void tearDown() {
@@ -79,11 +79,11 @@
         TestSetup setup13 = new TestSetup(inner) {
             protected void setUp() {
                 earFile = new File(basedir,  "target/test-ear13/test-ear.ear");
-                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar", URI.create("test-ejb-jar.jar"),
null, "test-ejb-jar.jar", null, null);
+                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar", URI.create("test-ejb-jar.jar"),
null, "test-ejb-jar.jar", null, null, null);
                 webConfigBuilder.contextRoot = "test";
-                webConfigBuilder.webModule = new WebModule("test-war.war", URI.create("test-war.war"),
null, "test-war.war", null, null);
+                webConfigBuilder.webModule = new WebModule("test-war.war", URI.create("test-war.war"),
null, "test-war.war", null, null, null);
                 webConfigBuilder.webModule.setContextRoot("test");
-                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar",
URI.create("test-rar.rar"), null, "test-rar.rar", null, null);
+                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar",
URI.create("test-rar.rar"), null, "test-rar.rar", null, null, null);
             }
 
             protected void tearDown() {
@@ -92,11 +92,11 @@
         TestSetup setupNaked13 = new TestSetup(inner) {
             protected void setUp() {
                 earFile = new File(basedir, "target/test-ear13/test-naked-ear.ear");
-                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar", URI.create("test-ejb-jar.jar"),
null, "test-ejb-jar.jar", null, null);
+                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar", URI.create("test-ejb-jar.jar"),
null, "test-ejb-jar.jar", null, null, null);
                 webConfigBuilder.contextRoot = "test";
-                webConfigBuilder.webModule = new WebModule("test-war.war", URI.create("test-war.war"),
null, "test-war.war", null, null);
+                webConfigBuilder.webModule = new WebModule("test-war.war", URI.create("test-war.war"),
null, "test-war.war", null, null, null);
                 webConfigBuilder.webModule.setContextRoot("test");
-                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar",
URI.create("test-rar.rar"), null, "test-rar.rar", null, null);
+                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar",
URI.create("test-rar.rar"), null, "test-rar.rar", null, null, null);
             }
 
             protected void tearDown() {
@@ -105,11 +105,11 @@
         TestSetup setupUnpacked = new TestSetup(inner) {
             protected void setUp() {
                 earFile = new File(basedir,  "target/test-unpacked-ear/full/");
-                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar/", URI.create("test-ejb-jar.jar/"),
null, "test-ejb-jar.jar/", null, null);
+                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar/", URI.create("test-ejb-jar.jar/"),
null, "test-ejb-jar.jar/", null, null, null);
                 webConfigBuilder.contextRoot = "test";
-                webConfigBuilder.webModule = new WebModule("test-war.war/", URI.create("test-war.war/"),
null, "test-war.war/", null, null);
+                webConfigBuilder.webModule = new WebModule("test-war.war/", URI.create("test-war.war/"),
null, "test-war.war/", null, null, null);
                 webConfigBuilder.webModule.setContextRoot("test");
-                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar",
URI.create("test-rar.rar"), null, "test-rar.rar", null, null);
+                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar",
URI.create("test-rar.rar"), null, "test-rar.rar", null, null, null);
             }
 
             protected void tearDown() {
@@ -118,11 +118,11 @@
         TestSetup setupUnpackedNaked = new TestSetup(inner) {
             protected void setUp() {
                 earFile = new File(basedir,  "target/test-unpacked-ear/naked/");
-                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar/", URI.create("test-ejb-jar.jar/"),
null, "test-ejb-jar.jar/", null, null);
+                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar/", URI.create("test-ejb-jar.jar/"),
null, "test-ejb-jar.jar/", null, null, null);
                 webConfigBuilder.contextRoot = "test";
-                webConfigBuilder.webModule = new WebModule("test-war.war/", URI.create("test-war.war/"),
null, "test-war.war", null, null);
+                webConfigBuilder.webModule = new WebModule("test-war.war/", URI.create("test-war.war/"),
null, "test-war.war", null, null, null);
                 webConfigBuilder.webModule.setContextRoot("test");
-                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar",
URI.create("test-rar.rar"), null, "test-rar.rar", null, null);
+                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar",
URI.create("test-rar.rar"), null, "test-rar.rar", null, null, null);
             }
 
             protected void tearDown() {
@@ -131,15 +131,15 @@
         TestSetup setupUnpackedAltDD = new TestSetup(inner) {
             protected void setUp() throws Exception {
                 earFile = new File(basedir,  "target/test-unpacked-ear/alt-dd/");
-                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar/", URI.create("test-ejb-jar.jar/"),
null, "test-ejb-jar.jar/", null, null);
+                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar/", URI.create("test-ejb-jar.jar/"),
null, "test-ejb-jar.jar/", null, null, null);
 //                ejbConfigBuilder.ejbModule.setAltSpecDD(new File(earFile, "alt-ejb-jar.xml").toURL());
 //                ejbConfigBuilder.ejbModule.setAltVendorDD(new File(earFile, "alt-ger-ejb-jar.xml").toURL());
                 webConfigBuilder.contextRoot = "test";
-                webConfigBuilder.webModule = new WebModule("test-war.war/", URI.create("test-war.war/"),
null, "test-war.war/", null, null);
+                webConfigBuilder.webModule = new WebModule("test-war.war/", URI.create("test-war.war/"),
null, "test-war.war/", null, null, null);
                 webConfigBuilder.webModule.setContextRoot("test");
 //                webConfigBuilder.webModule.setAltSpecDD(new File(earFile, "alt-web.xml").toURL());
 //                webConfigBuilder.webModule.setAltVendorDD(new File(earFile, "alt-ger-war.xml").toURL());
-                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar",
URI.create("test-rar.rar"), null, "test-rar.rar", null, null);
+                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar",
URI.create("test-rar.rar"), null, "test-rar.rar", null, null, null);
 //                connectorConfigBuilder.connectorModule.setAltSpecDD(new File(earFile, "alt-ra.xml").toURL());
 //                connectorConfigBuilder.connectorModule.setAltVendorDD(new File(earFile,
"alt-ger-ra.xml").toURL());
             }
@@ -150,16 +150,16 @@
         TestSetup setupPackedAltDD = new TestSetup(inner) {
             protected void setUp() throws Exception {
                 earFile = new File(basedir,  "target/test-unpacked-ear/alt-dd.ear");
-                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar/", URI.create("test-ejb-jar.jar/"),
null, "test-ejb-jar.jar/", null, null);
+                ejbConfigBuilder.ejbModule = new EJBModule("test-ejb-jar.jar/", URI.create("test-ejb-jar.jar/"),
null, "test-ejb-jar.jar/", null, null, null);
 //                String baseURI = "jar:" + earFile.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.war/", URI.create("test-war.war/"),
null, "test-war.war/", null, null);
+                webConfigBuilder.webModule = new WebModule("test-war.war/", URI.create("test-war.war/"),
null, "test-war.war/", null, null, null);
                 webConfigBuilder.webModule.setContextRoot("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"), null, "test-rar.rar", null, null);
+                connectorConfigBuilder.connectorModule = new ConnectorModule("test-rar.rar",
URI.create("test-rar.rar"), null, "test-rar.rar", null, null, null);
 //                connectorConfigBuilder.connectorModule.setAltSpecDD(new URL(baseURI + "alt-ra.xml"));
 //                connectorConfigBuilder.connectorModule.setAltVendorDD(new URL(baseURI +
"alt-ger-ra.xml"));
             }

Modified: geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockConnectorConfigBuilder.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockConnectorConfigBuilder.java
(original)
+++ geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockConnectorConfigBuilder.java
Thu Sep 23 16:46:18 2004
@@ -53,11 +53,11 @@
     }
 
     public Module createModule(String name, JarFile moduleFile, XmlObject vendorDD) throws
DeploymentException {
-        return createModule(name, URI.create("/"), moduleFile, "connector", vendorDD, null);
+        return createModule(name, moduleFile, vendorDD, "connector", null);
     }
 
-    public Module createModule(String name, URI moduleURI, JarFile moduleFile, String targetPath,
XmlObject vendorDD, URL specDD) throws DeploymentException {
-        return new ConnectorModule(name, moduleURI, moduleFile, targetPath, null, vendorDD);
+    public Module createModule(String name, JarFile moduleFile, XmlObject vendorDD, String
targetPath, URL specDD) throws DeploymentException {
+        return new ConnectorModule(name, URI.create(targetPath), moduleFile, targetPath,
null, vendorDD, null);
     }
 
     public void installModule(JarFile earFile, EARContext earContext, Module connectorModule)
{

Modified: geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockEJBConfigBuilder.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockEJBConfigBuilder.java
(original)
+++ geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockEJBConfigBuilder.java
Thu Sep 23 16:46:18 2004
@@ -53,11 +53,11 @@
     }
 
     public Module createModule(String name, JarFile moduleFile, XmlObject vendorDD) throws
DeploymentException {
-        return createModule(name, URI.create("/"), moduleFile, "connector", vendorDD, null);
+        return createModule(name, moduleFile, vendorDD, "connector", null);
     }
 
-    public Module createModule(String name, URI moduleURI, JarFile moduleFile, String targetPath,
XmlObject vendorDD, URL specDD) throws DeploymentException {
-        return new EJBModule(name, moduleURI, moduleFile, targetPath, null, vendorDD);
+    public Module createModule(String name, JarFile moduleFile, XmlObject vendorDD, String
targetPath, URL specDD) throws DeploymentException {
+        return new EJBModule(name, URI.create(targetPath), moduleFile, targetPath, null,
vendorDD, null);
     }
 
     public void installModule(JarFile earFile, EARContext earContext, Module ejbModule) {

Modified: geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockWARConfigBuilder.java
==============================================================================
--- geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockWARConfigBuilder.java
(original)
+++ geronimo/trunk/modules/j2ee/src/test/org/apache/geronimo/j2ee/deployment/MockWARConfigBuilder.java
Thu Sep 23 16:46:18 2004
@@ -54,11 +54,11 @@
     }
 
     public Module createModule(String name, JarFile moduleFile, XmlObject vendorDD) throws
DeploymentException {
-        return createModule(name, URI.create("/"), moduleFile, "connector", vendorDD, null);
+        return createModule(name, moduleFile, vendorDD, "connector", null);
     }
 
-    public Module createModule(String name, URI moduleURI, JarFile moduleFile, String targetPath,
XmlObject vendorDD, URL specDD) throws DeploymentException {
-        return new WebModule(name, moduleURI, moduleFile, targetPath, null, vendorDD);
+    public Module createModule(String name, JarFile moduleFile, XmlObject vendorDD, String
targetPath, URL specDD) throws DeploymentException {
+        return new WebModule(name, URI.create(targetPath), moduleFile, targetPath, null,
vendorDD, null);
     }
 
     public void installModule(JarFile earFile, EARContext earContext, Module webModule) throws
DeploymentException {

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
Thu Sep 23 16:46:18 2004
@@ -19,6 +19,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.ByteArrayInputStream;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -41,6 +42,7 @@
 import org.apache.geronimo.common.xml.XmlBeansUtil;
 import org.apache.geronimo.deployment.DeploymentException;
 import org.apache.geronimo.deployment.service.GBeanHelper;
+import org.apache.geronimo.deployment.util.IOUtil;
 import org.apache.geronimo.deployment.util.JarUtil;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoFactory;
@@ -95,14 +97,26 @@
     public XmlObject parseSpecDD(URL path) throws DeploymentException {
         try {
             // check if we have an alt spec dd
-            XmlObject dd = SchemaConversionUtils.parse(path.openStream());
-            WebAppDocument webAppDoc = SchemaConversionUtils.convertToServletSchema(dd);
-            return webAppDoc.getWebApp();
+            return parseSpecDD(SchemaConversionUtils.parse(path.openStream()));
         } catch (Exception e) {
             throw new DeploymentException("Unable to parse " + path, e);
         }
     }
 
+    public XmlObject parseSpecDD(String specDD) throws DeploymentException {
+        try {
+            // check if we have an alt spec dd
+            return parseSpecDD(SchemaConversionUtils.parse(specDD));
+        } catch (Exception e) {
+            throw new DeploymentException("Unable to parse spec dd", e);
+        }
+    }
+
+    private XmlObject parseSpecDD(XmlObject dd) throws XmlException {
+        WebAppDocument webAppDoc = SchemaConversionUtils.convertToServletSchema(dd);
+        return webAppDoc.getWebApp();
+    }
+
     public XmlObject parseVendorDD(URL vendorURL) throws XmlException {
         return XmlBeansUtil.getXmlObject(vendorURL, JettyWebAppDocument.type);
     }
@@ -195,12 +209,31 @@
     }
 
     public Module createModule(String name, JarFile moduleFile, XmlObject vendorDD) throws
DeploymentException {
-        return createModule(name, URI.create(""), moduleFile, "war/", vendorDD, null);
+        return createModule(name, moduleFile, vendorDD, "war", null);
     }
 
-    public Module createModule(String name, URI moduleURI, JarFile moduleFile, String targetPath,
XmlObject vendorDD, URL specDD) throws DeploymentException {
-        if (specDD == null) {
-            specDD = JarUtil.createJarURL(moduleFile, "WEB-INF/web.xml");
+    public Module createModule(String name, JarFile moduleFile, XmlObject vendorDD, String
targetPath, URL specDDUrl) throws DeploymentException {
+        URI moduleURI;
+        if (targetPath != null) {
+            moduleURI = URI.create(targetPath);
+            if (targetPath.endsWith("/")) {
+                throw new DeploymentException("targetPath must not end with a '/'");
+            }
+            targetPath += "/";
+        } else {
+            targetPath = "war/";
+            moduleURI = URI.create("");
+        }
+
+        // load the spec dd
+        if (specDDUrl == null) {
+            specDDUrl = JarUtil.createJarURL(moduleFile, "WEB-INF/web.xml");
+        }
+        String specDD;
+        try {
+            specDD = IOUtil.readAll(specDDUrl);
+        } catch (IOException e) {
+            throw new DeploymentException("Unable to read specDD: " + specDDUrl.toExternalForm());
         }
         WebAppType webApp = (WebAppType) parseSpecDD(specDD);
 
@@ -224,18 +257,14 @@
         JettyWebAppDocument jettyWebAppDoc = (JettyWebAppDocument) vendorDD;
         JettyWebAppType jettyWebApp = jettyWebAppDoc.getWebApp();
 
-        WebModule module = new WebModule(name, moduleURI, moduleFile, targetPath, webApp,
jettyWebApp);
+        WebModule module = new WebModule(name, moduleURI, moduleFile, targetPath, webApp,
jettyWebApp, specDD);
         module.setContextRoot(jettyWebApp.getContextRoot());
         return module;
     }
 
     public void installModule(JarFile earFile, EARContext earContext, Module module) throws
DeploymentException {
         try {
-            String targetPath = module.getTargetPath();
-            if (!targetPath.endsWith("/")) {
-                targetPath += "/";
-            }
-            URI targetURI = URI.create(targetPath);
+            URI targetURI = URI.create(module.getTargetPath());
 
             // add the warfile's content to the configuration
             JarFile warFile = module.getModuleFile();
@@ -245,9 +274,7 @@
                 URI target = targetURI.resolve(entry.getName());
                 if (entry.getName().equals("WEB-INF/web.xml")) {
                     // TODO gets rid of these tests when Jetty will use the serialized Geronimo
DD.
-                    WebAppDocument webAppDoc = WebAppDocument.Factory.newInstance();
-                    webAppDoc.setWebApp((WebAppType) module.getSpecDD());
-                    earContext.addFile(target, webAppDoc.newInputStream());
+                    earContext.addFile(target, new ByteArrayInputStream(module.getOriginalSpecDD().getBytes()));
                 } else {
                     InputStream in = warFile.getInputStream(entry);
                     try {

Mime
View raw message