geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r904725 - in /geronimo/server/trunk/plugins: j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/ jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/ tomcat/geronimo-tomcat7-build...
Date Sat, 30 Jan 2010 03:33:13 GMT
Author: gawor
Date: Sat Jan 30 03:33:11 2010
New Revision: 904725

URL: http://svn.apache.org/viewvc?rev=904725&view=rev
Log:
make sure the deploymentDescriptor attribute has the right root element

Modified:
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java?rev=904725&r1=904724&r2=904725&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
Sat Jan 30 03:33:11 2010
@@ -82,6 +82,7 @@
 import org.apache.xmlbeans.XmlDocumentProperties;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
 import org.osgi.framework.Bundle;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -393,6 +394,19 @@
         return resolutionUri;
     }
 
+    protected String getSpecDDAsString(WebModule module) {
+        StringWriter writer = new StringWriter();    
+        XmlOptions options = new XmlOptions();
+        QName webQName = new QName("http://java.sun.com/xml/ns/javaee", "web-app");
+        options.setSaveSyntheticDocumentElement(webQName);
+        try {
+            module.getSpecDD().save(writer, options);
+        } catch (IOException e) {
+            // ignore
+        }
+        return writer.toString();
+    }
+    
     protected WebAppDocument convertToServletSchema(XmlObject xmlObject) throws XmlException
{
 
         String schemaLocationURL = "http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java?rev=904725&r1=904724&r2=904725&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
Sat Jan 30 03:33:11 2010
@@ -571,7 +571,7 @@
             //not truly metadata complete until MBEs have run
             if (!webApp.getMetadataComplete()) {
                 webApp.setMetadataComplete(true);
-                module.setOriginalSpecDD(module.getSpecDD().toString());
+                module.setOriginalSpecDD(getSpecDDAsString(webModule));
             }
             webModuleData.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
 

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=904725&r1=904724&r2=904725&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
Sat Jan 30 03:33:11 2010
@@ -87,7 +87,6 @@
 import org.apache.geronimo.xbeans.javaee.ServletType;
 import org.apache.geronimo.xbeans.javaee.WebAppDocument;
 import org.apache.geronimo.xbeans.javaee.WebAppType;
-import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.osgi.framework.Bundle;
@@ -103,7 +102,6 @@
     static final String ROLE_MAPPER_DATA_NAME = "roleMapperDataName";
 
     private static final String TOMCAT_NAMESPACE = TomcatWebAppDocument.type.getDocumentElementName().getNamespaceURI();
-    private static final String IS_JAVAEE = "IS_JAVAEE";
     private static final Map<String, String> NAMESPACE_UPDATES = new HashMap<String,
String>();
     static {
         NAMESPACE_UPDATES.put("http://geronimo.apache.org/xml/ns/web", "http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1");
@@ -160,18 +158,15 @@
         
         String specDD = null;
         WebAppType webApp = null;
-        Boolean isJavaee;
         
         URL specDDUrl = bundle.getEntry("WEB-INF/web.xml");
         if (specDDUrl == null) {
             webApp = WebAppType.Factory.newInstance();
-            isJavaee = true;
         } else {
             try {
                 specDD = JarUtils.readAll(specDDUrl);
 
                 XmlObject parsed = XmlBeansUtil.parse(specDD);
-                isJavaee = "http://java.sun.com/xml/ns/javaee".equals(getRootNamespace(parsed));
                 
                 WebAppDocument webAppDoc = convertToServletSchema(parsed);
                 webApp = webAppDoc.getWebApp();
@@ -215,7 +210,6 @@
         for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
             mbe.createModule(module, bundle, naming, idBuilder);
         }
-        module.getSharedContext().put(IS_JAVAEE, isJavaee);
         return module;
     }
     
@@ -227,7 +221,6 @@
         // parse the spec dd
         String specDD = null;
         WebAppType webApp = null;
-        Boolean isJavaee;
         try {
             if (specDDUrl == null) {
                 specDDUrl = JarUtils.createJarURL(moduleFile, "WEB-INF/web.xml");
@@ -239,8 +232,6 @@
 
             // we found web.xml, if it won't parse that's an error.
             XmlObject parsed = XmlBeansUtil.parse(specDD);
-            //Dont save updated xml if it isn't javaee
-            isJavaee = "http://java.sun.com/xml/ns/javaee".equals(getRootNamespace(parsed));
 
             WebAppDocument webAppDoc = convertToServletSchema(parsed);
             webApp = webAppDoc.getWebApp();
@@ -255,7 +246,6 @@
                 //not for us
                 return null;
             }
-            isJavaee = true;
             //else ignore as jee5 allows optional spec dd for .war's
         }
 
@@ -297,21 +287,9 @@
         for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
             mbe.createModule(module, plan, moduleFile, targetPath, specDDUrl, environment,
contextRoot, earName, naming, idBuilder);
         }
-        module.getSharedContext().put(IS_JAVAEE, isJavaee);
         return module;
     }
 
-    private static String getRootNamespace(XmlObject object) {
-        XmlCursor cursor = object.newCursor();
-        try {
-            cursor.toStartDoc();
-            cursor.toFirstChild();
-            return cursor.getName().getNamespaceURI();
-        } finally {
-            cursor.dispose();
-        }
-    }
-    
     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()) {
@@ -565,7 +543,7 @@
             //not truly metadata complete until MBEs have run
             if (!webApp.getMetadataComplete()) {
                 webApp.setMetadataComplete(true);
-                module.setOriginalSpecDD(module.getSpecDD().toString());
+                module.setOriginalSpecDD(getSpecDDAsString(webModule));
             }
             webModuleData.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
             



Mime
View raw message