svn commit: r1862323 - /ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1862323 - /ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java

mthl
Author: mthl
Date: Sat Jun 29 18:10:36 2019
New Revision: 1862323

URL: http://svn.apache.org/viewvc?rev=1862323&view=rev
Log:
Improved: Rewrite ‘loadHandlerMap’
(OFBIZ-10453)

Modified:
    ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java

Modified: ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java?rev=1862323&r1=1862322&r2=1862323&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java Sat Jun 29 18:10:36 2019
@@ -192,8 +192,8 @@ public class ConfigXMLReader {
         private final Map<String, Event> postprocessorEventList = new LinkedHashMap<>();
         private final Map<String, Event> afterLoginEventList = new LinkedHashMap<>();
         private final Map<String, Event> beforeLogoutEventList = new LinkedHashMap<>();
-        private Map<String, String> eventHandlerMap = new HashMap<>();
-        private Map<String, String> viewHandlerMap = new HashMap<>();
+        private final Map<String, String> eventHandlerMap = new HashMap<>();
+        private final Map<String, String> viewHandlerMap = new HashMap<>();
         private MultivaluedMapContext<String, RequestMap> requestMapMap = new MultivaluedMapContext<>();
         private Map<String, ViewMap> viewMapMap = new HashMap<>();
 
@@ -359,17 +359,11 @@ public class ConfigXMLReader {
         }
 
         private void loadHandlerMap(Element rootElement) {
-            for (Element handlerElement : UtilXml.childElementList(rootElement, "handler")) {
-                String name = handlerElement.getAttribute("name");
-                String type = handlerElement.getAttribute("type");
-                String className = handlerElement.getAttribute("class");
-
-                if ("view".equals(type)) {
-                    this.viewHandlerMap.put(name, className);
-                } else {
-                    this.eventHandlerMap.put(name, className);
-                }
-            }
+            Map<Boolean, Map<String, String>> handlers = UtilXml.childElementList(rootElement, "handler").stream()
+                    .collect(Collectors.partitioningBy(el -> "view".equals(el.getAttribute("type")),
+                            Collectors.toMap(el -> el.getAttribute("name"), el -> el.getAttribute("className"))));
+            viewHandlerMap.putAll(handlers.get(true));
+            eventHandlerMap.putAll(handlers.get(false));
         }
 
         protected void loadIncludes(Element rootElement) {