geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r550551 - in /geronimo/server/trunk/modules: geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/ geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/ geronimo-tomcat6-builder/src/main/java/or...
Date Mon, 25 Jun 2007 17:02:01 GMT
Author: djencks
Date: Mon Jun 25 10:02:00 2007
New Revision: 550551

URL: http://svn.apache.org/viewvc?view=rev&rev=550551
Log:
GERONIMO-1470 make it clearer that our context root settings override those in application.xml

Modified:
    geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/PlanParsingTest.java
    geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
    geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java

Modified: geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java?view=diff&rev=550551&r1=550550&r2=550551
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
Mon Jun 25 10:02:00 2007
@@ -35,7 +35,6 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.jar.JarFile;
 
 import javax.management.ObjectName;
@@ -64,7 +63,6 @@
 import org.apache.geronimo.j2ee.deployment.WebModule;
 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
 import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedWebApp;
-import org.apache.geronimo.j2ee.deployment.annotation.SecurityAnnotationHelper;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.jetty6.Host;
 import org.apache.geronimo.jetty6.JettyDefaultServletHolder;
@@ -82,8 +80,6 @@
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
 import org.apache.geronimo.naming.deployment.GBeanResourceEnvironmentBuilder;
 import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
-import org.apache.geronimo.security.deploy.SubjectInfo;
-import org.apache.geronimo.security.deployment.SecurityConfiguration;
 import org.apache.geronimo.security.jacc.ComponentPermissions;
 import org.apache.geronimo.web.deployment.GenericToSpecificPlanConverter;
 import org.apache.geronimo.web25.deployment.AbstractWebModuleBuilder;
@@ -223,15 +219,8 @@
         }
 
         // parse vendor dd
-        AtomicBoolean isDefault = new AtomicBoolean(false);
-        JettyWebAppType jettyWebApp = getJettyWebApp(plan, moduleFile, standAlone, targetPath,
webApp, isDefault);
-        if (jettyWebApp.isSetContextRoot() && !isDefault.get()) {
-            contextRoot = jettyWebApp.getContextRoot();
-        } else if (contextRoot == null || contextRoot.trim().equals("")) {
-            contextRoot = determineDefaultContextRoot(webApp, standAlone, moduleFile, targetPath);
-        }
-
-        contextRoot = contextRoot.trim();
+        JettyWebAppType jettyWebApp = getJettyWebApp(plan, moduleFile, standAlone, targetPath,
webApp);
+        contextRoot = getContextRoot(jettyWebApp, contextRoot, webApp, standAlone, moduleFile,
targetPath);
 
         EnvironmentType environmentType = jettyWebApp.getEnvironment();
         Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
@@ -267,7 +256,18 @@
         return module;
     }
 
-    JettyWebAppType getJettyWebApp(Object plan, JarFile moduleFile, boolean standAlone, String
targetPath, WebAppType webApp, AtomicBoolean isDefault) throws DeploymentException {
+    String getContextRoot(JettyWebAppType jettyWebApp, String contextRoot, WebAppType webApp,
boolean standAlone, JarFile moduleFile, String targetPath) {
+        if (jettyWebApp.isSetContextRoot()) {
+            contextRoot = jettyWebApp.getContextRoot();
+        } else if (contextRoot == null || contextRoot.trim().equals("")) {
+            contextRoot = determineDefaultContextRoot(webApp, standAlone, moduleFile, targetPath);
+        }
+
+        contextRoot = contextRoot.trim();
+        return contextRoot;
+    }
+
+    JettyWebAppType getJettyWebApp(Object plan, JarFile moduleFile, boolean standAlone, String
targetPath, WebAppType webApp) throws DeploymentException {
         XmlObject rawPlan = null;
         try {
             // load the geronimo-web.xml from either the supplied plan or from the earFile
@@ -302,9 +302,7 @@
                 jettyWebApp = (JettyWebAppType) webPlan.changeType(JettyWebAppType.type);
                 XmlBeansUtil.validateDD(jettyWebApp);
             } else {
-                isDefault.set(true);
-                String defaultContextRoot = determineDefaultContextRoot(webApp, standAlone,
moduleFile, targetPath);
-                jettyWebApp = createDefaultPlan(defaultContextRoot);
+                jettyWebApp = createDefaultPlan();
             }
             return jettyWebApp;
         } catch (XmlException e) {
@@ -312,10 +310,8 @@
         }
     }
 
-    private JettyWebAppType createDefaultPlan(String contextRoot) {
-        JettyWebAppType jettyWebApp = JettyWebAppType.Factory.newInstance();
-        jettyWebApp.setContextRoot(contextRoot);
-        return jettyWebApp;
+    private JettyWebAppType createDefaultPlan() {
+        return JettyWebAppType.Factory.newInstance();
     }
 
     public void initContext(EARContext earContext, Module module, ClassLoader cl) throws
DeploymentException {
@@ -351,8 +347,6 @@
             // configure hosts and virtual-hosts
             configureHosts(earContext, jettyWebApp, webModuleData);
 
-            //classpath may have been augmented with enhanced classes
-//            webModuleData.setAttribute("webClassPath", webModule.getWebClasspath());
 
             String contextPath = webModule.getContextRoot();
             if (contextPath == null) {

Modified: geronimo/server/trunk/modules/geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/PlanParsingTest.java?view=diff&rev=550551&r1=550550&r2=550551
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/PlanParsingTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6-builder/src/test/java/org/apache/geronimo/jetty6/deployment/PlanParsingTest.java
Mon Jun 25 10:02:00 2007
@@ -17,6 +17,7 @@
 package org.apache.geronimo.jetty6.deployment;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -24,15 +25,16 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.jar.JarFile;
 
-import org.apache.geronimo.deployment.util.UnpackedJarFile;
 import org.apache.geronimo.deployment.service.GBeanBuilder;
+import org.apache.geronimo.deployment.util.DeploymentUtil;
+import org.apache.geronimo.deployment.util.UnpackedJarFile;
 import org.apache.geronimo.deployment.xbeans.ArtifactType;
 import org.apache.geronimo.deployment.xbeans.EnvironmentType;
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
 import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.gbean.AbstractNameQuery;
-import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
 import org.apache.geronimo.j2ee.deployment.NamingBuilderCollection;
+import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.Jsr77Naming;
 import org.apache.geronimo.kernel.Naming;
@@ -50,6 +52,7 @@
 import org.apache.geronimo.xbeans.javaee.WebAppType;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlException;
 
 /**
  */
@@ -92,7 +95,7 @@
     public void testContents() throws Exception {
         URL resourcePlan = classLoader.getResource("plans/plan1.xml");
         assertTrue(resourcePlan != null);
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null, isDefault);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null);
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
 //        assertEquals(4, jettyWebApp.getSecurity().getRoleMappings().getRoleArray().length);
     }
@@ -100,7 +103,7 @@
     public void testMoveSecurity1() throws Exception {
         URL resourcePlan = classLoader.getResource("plans/plan1A.xml");
         assertTrue(resourcePlan != null);
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null, isDefault);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null);
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
 //        assertEquals(4, jettyWebApp.getSecurity().getRoleMappings().getRoleArray().length);
     }
@@ -108,7 +111,7 @@
     public void testMoveSecurity2() throws Exception {
         URL resourcePlan = classLoader.getResource("plans/plan1B.xml");
         assertTrue(resourcePlan != null);
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null, isDefault);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null);
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
 //        assertEquals(4, jettyWebApp.getSecurity().getRoleMappings().getRoleArray().length);
     }
@@ -116,7 +119,7 @@
     public void testMoveSecurity3() throws Exception {
         URL resourcePlan = classLoader.getResource("plans/plan1C.xml");
         assertTrue(resourcePlan != null);
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null, isDefault);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null);
 //        assertEquals(4, jettyWebApp.getSecurity().getRoleMappings().getRoleArray().length);
 //        log.debug(jettyWebApp.xmlText());
     }
@@ -124,7 +127,7 @@
     public void testOldFormat() throws Exception {
         URL resourcePlan = classLoader.getResource("plans/plan2.xml");
         assertTrue(resourcePlan != null);
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null, isDefault);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(new File(resourcePlan.getFile()),
null, true, null, null);
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
 //        assertEquals(4, jettyWebApp.getSecurity().getRoleMappings().getRoleArray().length);
     }
@@ -133,7 +136,7 @@
         URL war = classLoader.getResource("deployables/war5");
         assertTrue(war != null);
         UnpackedJarFile moduleFile = new UnpackedJarFile(new File(war.getFile()));
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(null, moduleFile, true, null,
null, isDefault);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(null, moduleFile, true, null,
null);
         moduleFile.close();
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
     }
@@ -142,7 +145,7 @@
         URL war = classLoader.getResource("deployables/war6.war");
         assertTrue(war != null);
         JarFile moduleFile = new JarFile(new File(war.getFile()));
-        JettyWebAppType jettyWebApp = builder.getJettyWebApp(null, moduleFile, true, null,
null, isDefault);
+        JettyWebAppType jettyWebApp = builder.getJettyWebApp(null, moduleFile, true, null,
null);
         moduleFile.close();
         assertEquals(1, jettyWebApp.getResourceRefArray().length);
     }
@@ -186,7 +189,7 @@
         assertTrue(war != null);
         JarFile dummyFile = new JarFile(new File(war.getFile()));
 
-        webApp = builder.getJettyWebApp(webApp, dummyFile, true, null, null, isDefault);
+        webApp = builder.getJettyWebApp(webApp, dummyFile, true, null, null);
 
         assertEquals("myContextRoot", webApp.getContextRoot());
 
@@ -197,9 +200,11 @@
         URL war = classLoader.getResource("deployables/war2.war");
         assertTrue(war != null);
         JarFile dummyFile = new JarFile(new File(war.getFile()));
-        JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, true, null,
null, isDefault);
+        JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, true, null,
null);
+        WebAppType webApp = getWebApp(dummyFile);
+        String contextRoot = builder.getContextRoot(GerWebAppType, null, webApp, true, dummyFile,
null);
 
-        assertEquals("/war2", GerWebAppType.getContextRoot());
+        assertEquals("/war2", contextRoot);
 
     }
 
@@ -208,9 +213,10 @@
         URL war = classLoader.getResource("deployables/war2.war");
         assertTrue(war != null);
         JarFile dummyFile = new JarFile(new File(war.getFile()));
-        JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, false, "myTargetPath",
null, isDefault);
-
-        assertEquals("myTargetPath", GerWebAppType.getContextRoot());
+        JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, false, "myTargetPath",
null);
+        WebAppType webApp = getWebApp(dummyFile);
+        String contextRoot = builder.getContextRoot(GerWebAppType, null, webApp, false, dummyFile,
"myTargetPath");
+        assertEquals("myTargetPath", contextRoot);
 
     }
 
@@ -223,10 +229,19 @@
         URL war = classLoader.getResource("deployables/war2.war");
         assertTrue(war != null);
         JarFile dummyFile = new JarFile(new File(war.getFile()));
-        JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, false, "myTargetPath",
webAppType, isDefault);
+        JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, false, "myTargetPath",
webAppType);
+//        WebAppType webApp = getWebApp(dummyFile);
+        String contextRoot = builder.getContextRoot(GerWebAppType, null, webAppType, false,
dummyFile, "myTargetPath");
+
+        assertEquals("myId", contextRoot);
 
-        assertEquals("myId", GerWebAppType.getContextRoot());
+    }
 
+    private WebAppType getWebApp(JarFile dummyFile) throws IOException, XmlException {
+        URL specDDUrl = DeploymentUtil.createJarURL(dummyFile, "WEB-INF/web.xml");
+        XmlObject parsed = XmlBeansUtil.parse(specDDUrl, getClass().getClassLoader());
+        WebAppDocument webAppDoc = (WebAppDocument) parsed.changeType(WebAppDocument.type);
+        return webAppDoc.getWebApp();
     }
 
     public void testParseSpecDD() {

Modified: geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?view=diff&rev=550551&r1=550550&r2=550551
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
Mon Jun 25 10:02:00 2007
@@ -27,7 +27,6 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.jar.JarFile;
 
 import javax.servlet.Servlet;
@@ -171,20 +170,9 @@
             webApp = WebAppType.Factory.newInstance();
 
         // parse vendor dd
-        AtomicBoolean usedDefault = new AtomicBoolean(false);
-        TomcatWebAppType tomcatWebApp = getTomcatWebApp(plan, moduleFile, standAlone, targetPath,
webApp, usedDefault);
+        TomcatWebAppType tomcatWebApp = getTomcatWebApp(plan, moduleFile, standAlone, targetPath,
webApp);
+        contextRoot = getContextRoot(tomcatWebApp, contextRoot, webApp, standAlone, moduleFile,
targetPath);
 
-        //If we have a context root, override everything
-        if (tomcatWebApp.isSetContextRoot() && !usedDefault.get()) {
-            contextRoot = tomcatWebApp.getContextRoot();
-        } else {
-            //Otherwise if no contextRoot was passed in from the ear, then make up a default
-            if (contextRoot == null || contextRoot.trim().equals("")) {
-                contextRoot = determineDefaultContextRoot(webApp, standAlone, moduleFile,
targetPath);
-            }
-        }
-
-        contextRoot = contextRoot.trim();
 
         EnvironmentType environmentType = tomcatWebApp.getEnvironment();
         Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
@@ -229,8 +217,24 @@
         return module;
     }
 
+    private String getContextRoot(TomcatWebAppType tomcatWebApp, String contextRoot, WebAppType
webApp, boolean standAlone, JarFile moduleFile, String targetPath) {
+        //If we have a context root, override everything
+        if (tomcatWebApp.isSetContextRoot()) {
+            contextRoot = tomcatWebApp.getContextRoot();
+        } else if (contextRoot == null || contextRoot.trim().equals("")) {
+            //Otherwise if no contextRoot was passed in from the ear, then make up a default
+            contextRoot = determineDefaultContextRoot(webApp, standAlone, moduleFile, targetPath);
+        }
+        contextRoot = contextRoot.trim();
+        if (!contextRoot.startsWith("/")) {
+            //I'm not sure if we should always fix up peculiar context roots.
+            contextRoot = "/" + contextRoot;
+        }
+        return contextRoot;
+    }
+
 
-    TomcatWebAppType getTomcatWebApp(Object plan, JarFile moduleFile, boolean standAlone,
String targetPath, WebAppType webApp, AtomicBoolean usedDefault) throws DeploymentException
{
+    TomcatWebAppType getTomcatWebApp(Object plan, JarFile moduleFile, boolean standAlone,
String targetPath, WebAppType webApp) throws DeploymentException {
         XmlObject rawPlan = null;
         try {
             // load the geronimo-web.xml from either the supplied plan or from the earFile
@@ -265,9 +269,7 @@
                 tomcatWebApp = (TomcatWebAppType) webPlan.changeType(TomcatWebAppType.type);
                 XmlBeansUtil.validateDD(tomcatWebApp);
             } else {
-                String defaultContextRoot = determineDefaultContextRoot(webApp, standAlone,
moduleFile, targetPath);
-                tomcatWebApp = createDefaultPlan(defaultContextRoot);
-                usedDefault.set(true);
+                tomcatWebApp = createDefaultPlan();
             }
             return tomcatWebApp;
         } catch (XmlException e) {
@@ -275,14 +277,8 @@
         }
     }
 
-    private TomcatWebAppType createDefaultPlan(String path) {
-        TomcatWebAppType tomcatWebApp = TomcatWebAppType.Factory.newInstance();
-        if (path != null && !path.startsWith("/")) {
-            tomcatWebApp.setContextRoot("/" + path);
-        } else {
-            tomcatWebApp.setContextRoot(path);
-        }
-        return tomcatWebApp;
+    private TomcatWebAppType createDefaultPlan() {
+        return TomcatWebAppType.Factory.newInstance();
     }
 
 

Modified: geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java?view=diff&rev=550551&r1=550550&r2=550551
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/java/org/apache/geronimo/tomcat/deployment/PlanParsingTest.java
Mon Jun 25 10:02:00 2007
@@ -19,7 +19,6 @@
 import java.io.File;
 import java.net.URL;
 import java.util.Collections;
-import java.util.concurrent.atomic.AtomicBoolean;
 
 import junit.framework.TestCase;
 import org.apache.geronimo.deployment.xbeans.ArtifactType;
@@ -62,7 +61,7 @@
         URL resourceURL = classLoader.getResource("plans/plan1.xml");
         File resourcePlan = new File(resourceURL.getFile());
         assertTrue(resourcePlan.exists());
-        TomcatWebAppType tomcatWebApp = builder.getTomcatWebApp(resourcePlan, null, true,
null, null, new AtomicBoolean(false));
+        TomcatWebAppType tomcatWebApp = builder.getTomcatWebApp(resourcePlan, null, true,
null, null);
         assertEquals(1, tomcatWebApp.getResourceRefArray().length);
     }
 



Mime
View raw message