geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r933100 - in /geronimo/server/trunk/plugins: j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/ j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ jetty8/geroni...
Date Mon, 12 Apr 2010 06:13:43 GMT
Author: xuhaihong
Date: Mon Apr 12 06:13:42 2010
New Revision: 933100

URL: http://svn.apache.org/viewvc?rev=933100&view=rev
Log:
1. Make sure we only reassemble the DD of the version after 2.5
2. Ignore the same param-name configurations checking in the same DD file (web-fragment.xml/web.xml)

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/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterInitParamMergeHandler.java
    geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ServletInitParamMergeHandler.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=933100&r1=933099&r2=933100&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
Mon Apr 12 06:13:42 2010
@@ -153,6 +153,14 @@ public abstract class AbstractWebModuleB
         }
     };
 
+    public static final EARContext.Key<Float> INITIAL_WEB_XML_SCHEMA_VERSION = new
EARContext.Key<Float>() {
+
+        @Override
+        public Float get(Map<EARContext.Key, Object> context) {
+            return (Float) context.get(this);
+        }
+    };
+
     private static final QName TAGLIB = new QName(SchemaConversionUtils.JAVAEE_NAMESPACE,
"taglib");
 
     private static final String LINE_SEP = System.getProperty("line.separator");
@@ -411,8 +419,9 @@ public abstract class AbstractWebModuleB
         getNamingBuilders().buildEnvironment(webApp, webModule.getVendorDD(), webModule.getEnvironment());
         getNamingBuilders().initContext(webApp, gerWebApp, webModule);
 
-      //Process web fragments and annotations
-        if (!webApp.getMetadataComplete()) {
+        identifySpecDDSchemaVersion(earContext, module);
+        //Process web fragments and annotations
+        if (INITIAL_WEB_XML_SCHEMA_VERSION.get(earContext.getGeneralData()) >= 2.5f &&
!webApp.getMetadataComplete()) {
             MergeHelper.processWebFragmentsAndAnnotations(earContext, webModule, bundle,
webApp);
         }
 
@@ -531,6 +540,54 @@ public abstract class AbstractWebModuleB
         return (WebAppDocument) xmlObject;
     }
 
+    /**
+     * Identify the spec DD schema version, and save it in the EARContext
+     * @param xmlObject
+     * @param earContext
+     */
+    private void identifySpecDDSchemaVersion(EARContext earContext, Module module) throws
DeploymentException {
+        String originalSpecDD = module.getOriginalSpecDD();
+        float schemaVersion = 0f;
+        if (originalSpecDD == null) {
+            schemaVersion = 3.0f;
+        } else {
+            XmlCursor cursor = null;
+            try {
+                cursor = XmlBeansUtil.parse(originalSpecDD).newCursor();
+                cursor.toStartDoc();
+                cursor.toFirstChild();
+                String nameSpaceURI = cursor.getName().getNamespaceURI();
+                if (nameSpaceURI != null && nameSpaceURI.length() > 0) {
+                    String version = cursor.getAttributeText(new QName("", "version"));
+                    if (version != null) {
+                        schemaVersion = Float.parseFloat(version);
+                    }
+                } else {
+                    XmlDocumentProperties xmlDocumentProperties = cursor.documentProperties();
+                    String publicId = xmlDocumentProperties.getDoctypePublicId();
+                    if ("-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN".equals(publicId))
{
+                        schemaVersion = 2.2f;
+                    } else if ("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN".equals(publicId))
{
+                        schemaVersion = 2.3f;
+                    }
+                }
+            } catch (Exception e) {
+                throw new DeploymentException(e);
+            } finally {
+                if (cursor != null) {
+                    try {
+                        cursor.dispose();
+                    } catch (Exception e) {
+                    }
+                }
+            }
+        }
+        if (schemaVersion == 0f) {
+            throw new DeploymentException("Unrecongnized schema version in web.xml file");
+        }
+        earContext.getGeneralData().put(INITIAL_WEB_XML_SCHEMA_VERSION, schemaVersion);
+    }
+
     protected ComponentPermissions buildSpecSecurityConfig(WebAppType webApp) {
         SpecSecurityBuilder builder = new SpecSecurityBuilder();
         return builder.buildSpecSecurityConfig(webApp);

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterInitParamMergeHandler.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/merge/webfragment/FilterInitParamMergeHandler.java?rev=933100&r1=933099&r2=933100&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterInitParamMergeHandler.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/FilterInitParamMergeHandler.java
Mon Apr 12 06:13:42 2010
@@ -53,11 +53,14 @@ public class FilterInitParamMergeHandler
                 case WEB_XML:
                     continue;
                 case WEB_FRAGMENT:
-                    if (!existedParamValue.getParamValue().getStringValue().equals(paramValue.getParamValue().getStringValue()))
{
-                        throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateKeyValueMessage("filter
" + filterName, "param-name", paramValue.getParamName().getStringValue(), "param-value",
-                                existedParamValue.getParamValue().getStringValue(), existedMergeItem.getBelongedURL(),
paramValue.getParamValue().getStringValue(), mergeContext.getCurrentJarUrl()));
+                    if (existedParamValue.getParamValue().getStringValue().equals(paramValue.getParamValue().getStringValue())
+                            || existedMergeItem.getBelongedURL().equals(mergeContext.getCurrentJarUrl()))
{
+                        break;
+                    } else {
+                        throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateKeyValueMessage("filter
" + filterName, "param-name", paramValue.getParamName().getStringValue(),
+                                "param-value", existedParamValue.getParamValue().getStringValue(),
existedMergeItem.getBelongedURL(), paramValue.getParamValue().getStringValue(), mergeContext
+                                        .getCurrentJarUrl()));
                     }
-                    break;
                 case ANNOTATION:
                     //Spec 8.1.n.iii Init params for servlets and filters defined via annotations,
will be
                     //overridden in the descriptor if the name of the init param exactly
matches
@@ -70,7 +73,6 @@ public class FilterInitParamMergeHandler
                 }
             }
         }
-
     }
 
     @Override

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ServletInitParamMergeHandler.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/merge/webfragment/ServletInitParamMergeHandler.java?rev=933100&r1=933099&r2=933100&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ServletInitParamMergeHandler.java
(original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/merge/webfragment/ServletInitParamMergeHandler.java
Mon Apr 12 06:13:42 2010
@@ -53,11 +53,14 @@ public class ServletInitParamMergeHandle
                 case WEB_XML:
                     continue;
                 case WEB_FRAGMENT:
-                    if (!existedParamValue.getParamValue().getStringValue().equals(paramValue.getParamValue().getStringValue()))
{
-                        throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateKeyValueMessage("servlet
" + servletName, "param-name", paramValue.getParamName().getStringValue(), "param-value",
-                                existedParamValue.getParamValue().getStringValue(), existedMergeItem.getBelongedURL(),
paramValue.getParamValue().getStringValue(), mergeContext.getCurrentJarUrl()));
+                    if (existedParamValue.getParamValue().getStringValue().equals(paramValue.getParamValue().getStringValue())
+                            || existedMergeItem.getBelongedURL().equals(mergeContext.getCurrentJarUrl()))
{
+                        break;
+                    } else {
+                        throw new DeploymentException(WebDeploymentMessageUtils.createDuplicateKeyValueMessage("servlet
" + servletName, "param-name", paramValue.getParamName().getStringValue(),
+                                "param-value", existedParamValue.getParamValue().getStringValue(),
existedMergeItem.getBelongedURL(), paramValue.getParamValue().getStringValue(), mergeContext
+                                        .getCurrentJarUrl()));
                     }
-                    break;
                 case ANNOTATION:
                     //Spec 8.1.n.iii Init params for servlets and filters defined via annotations,
will be
                     //overridden in the descriptor if the name of the init param exactly
matches
@@ -70,7 +73,6 @@ public class ServletInitParamMergeHandle
                 }
             }
         }
-
     }
 
     @Override

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=933100&r1=933099&r2=933100&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
Mon Apr 12 06:13:42 2010
@@ -636,9 +636,11 @@ public class JettyModuleBuilder extends 
             //not truly metadata complete until MBEs have run
             if (!webApp.getMetadataComplete()) {
                 webApp.setMetadataComplete(true);
-                String specDeploymentPlan = getSpecDDAsString(webModule);
-                module.setOriginalSpecDD(specDeploymentPlan);
-                earContext.addFile(new URI("./WEB-INF/web.xml"), specDeploymentPlan);
+                if (INITIAL_WEB_XML_SCHEMA_VERSION.get(earContext.getGeneralData()) >=
2.5f) {
+                    String specDeploymentPlan = getSpecDDAsString(webModule);
+                    module.setOriginalSpecDD(specDeploymentPlan);
+                    earContext.addFile(new URI("./WEB-INF/web.xml"), specDeploymentPlan);
+                }
             }
             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=933100&r1=933099&r2=933100&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
Mon Apr 12 06:13:42 2010
@@ -558,9 +558,11 @@ public class TomcatModuleBuilder extends
             //not truly metadata complete until MBEs have run
             if (!webApp.getMetadataComplete()) {
                 webApp.setMetadataComplete(true);
-                String specDeploymentPlan = getSpecDDAsString(webModule);
-                module.setOriginalSpecDD(specDeploymentPlan);
-                earContext.addFile(new URI("./WEB-INF/web.xml"), specDeploymentPlan);
+                if (INITIAL_WEB_XML_SCHEMA_VERSION.get(earContext.getGeneralData()) >=
2.5f) {
+                    String specDeploymentPlan = getSpecDDAsString(webModule);
+                    module.setOriginalSpecDD(specDeploymentPlan);
+                    earContext.addFile(new URI("./WEB-INF/web.xml"), specDeploymentPlan);
+                }
             }
             webModuleData.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
 



Mime
View raw message