tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r829448 - in /tomcat/trunk/java/org/apache/catalina: deploy/ErrorPage.java startup/LocalStrings.properties startup/WebXml.java
Date Sat, 24 Oct 2009 20:52:46 GMT
Author: markt
Date: Sat Oct 24 20:52:46 2009
New Revision: 829448

URL: http://svn.apache.org/viewvc?rev=829448&view=rev
Log:
Merge code for a few more elements

Modified:
    tomcat/trunk/java/org/apache/catalina/deploy/ErrorPage.java
    tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/startup/WebXml.java

Modified: tomcat/trunk/java/org/apache/catalina/deploy/ErrorPage.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/deploy/ErrorPage.java?rev=829448&r1=829447&r2=829448&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/deploy/ErrorPage.java (original)
+++ tomcat/trunk/java/org/apache/catalina/deploy/ErrorPage.java Sat Oct 24 20:52:46 2009
@@ -167,5 +167,12 @@
 
     }
 
+    public String getName() {
+        if (exceptionType == null) {
+            return Integer.toString(errorCode);
+        } else {
+            return exceptionType;
+        }
+    }
 
 }

Modified: tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties?rev=829448&r1=829447&r2=829448&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/LocalStrings.properties Sat Oct 24 20:52:46
2009
@@ -117,5 +117,8 @@
 webXml.mergeConflictContextParam=Context parameter [{0}] was defined in multiple fragments
with different values including fragment with name [{1}] located at [{2}]
 webXml.mergeConflictDisplayName=The display name was defined in multiple fragments with different
values including fragment with name [{0}] located at [{1}]
 webXml.mergeConflictEjbLocalRef=The EjbLocalRef [{0}] was defined in multiple fragments including
fragment with name [{1}] located at [{2}]
+webXml.mergeConflictEjbRef=The EjbRef [{0}] was defined in multiple fragments including fragment
with name [{1}] located at [{2}]
+webXml.mergeConflictEnvEntry=The Environment entry [{0}] was defined in multiple fragments
including fragment with name [{1}] located at [{2}]
+webXml.mergeConflictErrorPage=The Error Page for [{0}] was defined in multiple fragments
including fragment with name [{1}] located at [{2}]
 webXml.mergeConflictListener=Listener [{0}] was defined in multiple fragments including fragment
with name [{1}] located at [{2}]
 webXml.multipleOther=Multiple others entries in ordering

Modified: tomcat/trunk/java/org/apache/catalina/startup/WebXml.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/WebXml.java?rev=829448&r1=829447&r2=829448&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/WebXml.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/WebXml.java Sat Oct 24 20:52:46 2009
@@ -249,11 +249,11 @@
     }
     
     // error-page
-    private Set<ErrorPage> errorPages = new HashSet<ErrorPage>();
+    private Map<String,ErrorPage> errorPages = new HashMap<String,ErrorPage>();
     public void addErrorPage(ErrorPage errorPage) {
-        errorPages.add(errorPage);
+        errorPages.put(errorPage.getName(), errorPage);
     }
-    public Set<ErrorPage> getErrorPages() { return errorPages; }
+    public Map<String,ErrorPage> getErrorPages() { return errorPages; }
     
     // Digester will check there is only one jsp-config
     // jsp-config/taglib or taglib (2.3 and earlier)
@@ -317,9 +317,11 @@
     
     // ejb-ref
     // TODO: Should support multiple description elements with language
-    private Set<ContextEjb> ejbRefs = new HashSet<ContextEjb>();
-    public void addEjbRef(ContextEjb ejbRef) { ejbRefs.add(ejbRef); }
-    public Set<ContextEjb> getEjbRefs() { return ejbRefs; }
+    private Map<String,ContextEjb> ejbRefs = new HashMap<String,ContextEjb>();
+    public void addEjbRef(ContextEjb ejbRef) {
+        ejbRefs.put(ejbRef.getName(),ejbRef);
+    }
+    public Map<String,ContextEjb> getEjbRefs() { return ejbRefs; }
     
     // ejb-local-ref
     // TODO: Should support multiple description elements with language
@@ -454,13 +456,13 @@
         for (ContextLocalEjb ejbLocalRef : ejbLocalRefs.values()) {
             context.getNamingResources().addLocalEjb(ejbLocalRef);
         }
-        for (ContextEjb ejbRef : ejbRefs) {
+        for (ContextEjb ejbRef : ejbRefs.values()) {
             context.getNamingResources().addEjb(ejbRef);
         }
         for (ContextEnvironment environment : envEntries.values()) {
             context.getNamingResources().addEnvironment(environment);
         }
-        for (ErrorPage errorPage : errorPages) {
+        for (ErrorPage errorPage : errorPages.values()) {
             context.addErrorPage(errorPage);
         }
         for (FilterDef filter : filters.values()) {
@@ -574,6 +576,8 @@
         // Merge rules vary from element to element. See SRV.8.2.3
 
         WebXml temp = new WebXml();
+        Map<String,Boolean> mergeInjectionFlags =
+            new HashMap<String, Boolean>();
 
         for (WebXml fragment : fragments) {
             for (String contextParam : fragment.getContextParams().keySet()) {
@@ -625,9 +629,7 @@
                 }
             }
         }
-        
-        Map<String,Boolean> mergeInjectionFlags =
-            new HashMap<String, Boolean>();
+
         for (WebXml fragment : fragments) {
             for (ContextLocalEjb ejbLocalRef :
                     fragment.getEjbLocalRefs().values()) {
@@ -665,6 +667,109 @@
             }
         }
         ejbLocalRefs.putAll(temp.getEjbLocalRefs());
+        mergeInjectionFlags.clear();
+
+        for (WebXml fragment : fragments) {
+            for (ContextEjb ejbRef : fragment.getEjbRefs().values()) {
+                String name = ejbRef.getName();
+                boolean mergeInjectionFlag = false;
+                if (ejbRefs.containsKey(name)) {
+                    if (mergeInjectionFlags.containsKey(name)) {
+                        mergeInjectionFlag =
+                            mergeInjectionFlags.get(name).booleanValue(); 
+                    } else {
+                        if (ejbRefs.get(
+                                name).getInjectionTargets().size() == 0) {
+                            mergeInjectionFlag = true;
+                        }
+                        mergeInjectionFlags.put(name,
+                                Boolean.valueOf(mergeInjectionFlag));
+                    }
+                    if (mergeInjectionFlag) {
+                        ejbRefs.get(name).getInjectionTargets().addAll(
+                                ejbRef.getInjectionTargets());
+                    }
+                } else {
+                    // Not defined in main web.xml
+                    if (temp.getEjbRefs().containsKey(name)) {
+                        log.error(sm.getString(
+                                "webXml.mergeConflictEjbRef",
+                                name,
+                                fragment.getName(),
+                                fragment.getURL()));
+                        return false;
+                    } else {
+                        temp.getEjbRefs().put(name, ejbRef);
+                    }
+                }
+            }
+        }
+        ejbRefs.putAll(temp.getEjbRefs());
+        mergeInjectionFlags.clear();
+
+        for (WebXml fragment : fragments) {
+            for (ContextEnvironment envEntry :
+                    fragment.getEnvEntries().values()) {
+                String name = envEntry.getName();
+                boolean mergeInjectionFlag = false;
+                if (envEntries.containsKey(name)) {
+                    if (mergeInjectionFlags.containsKey(name)) {
+                        mergeInjectionFlag =
+                            mergeInjectionFlags.get(name).booleanValue(); 
+                    } else {
+                        if (envEntries.get(
+                                name).getInjectionTargets().size() == 0) {
+                            mergeInjectionFlag = true;
+                        }
+                        mergeInjectionFlags.put(name,
+                                Boolean.valueOf(mergeInjectionFlag));
+                    }
+                    if (mergeInjectionFlag) {
+                        envEntries.get(name).getInjectionTargets().addAll(
+                                envEntry.getInjectionTargets());
+                    }
+                } else {
+                    // Not defined in main web.xml
+                    if (temp.getEnvEntries().containsKey(name)) {
+                        log.error(sm.getString(
+                                "webXml.mergeConflictEnvEntry",
+                                name,
+                                fragment.getName(),
+                                fragment.getURL()));
+                        return false;
+                    } else {
+                        temp.getEnvEntries().put(name, envEntry);
+                    }
+                }
+            }
+        }
+        envEntries.putAll(temp.getEnvEntries());
+        mergeInjectionFlags.clear();
+
+        for (WebXml fragment : fragments) {
+            for (String errorPageKey : fragment.getErrorPages().keySet()) {
+                if (!errorPages.containsKey(errorPageKey)) {
+                    // Not defined in main web.xml
+                    ErrorPage errorPage =
+                        fragment.getErrorPages().get(errorPageKey);
+                    if (temp.getErrorPages().containsKey(errorPageKey)) {
+                        if (!errorPage.getLocation().equals(
+                                temp.getErrorPages().get(
+                                        errorPageKey).getLocation())) {
+                            log.error(sm.getString(
+                                    "webXml.mergeConflictErrorPage",
+                                    errorPageKey,
+                                    fragment.getName(),
+                                    fragment.getURL()));
+                            return false;
+                        }
+                    } else {
+                        temp.addErrorPage(errorPage);
+                    }
+                }
+            }
+        }
+        errorPages.putAll(temp.getErrorPages());
 
         // TODO SERVLET3 - Merge remaining elements
 



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message