Skip to content

Commit a71766e

Browse files
committed
Improved: Rewrite ‘loadHandlerMap’
(OFBIZ-10453) This retrieves the attribute "class" instead of "className" which was mistakenly used in revision 1862323. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1862343 13f79535-47bb-0310-9956-ffa450edef68
1 parent c51b069 commit a71766e

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java

+8-13
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.Map;
3232
import java.util.Set;
3333
import java.util.function.Function;
34+
import java.util.stream.Collectors;
3435

3536
import javax.servlet.ServletContext;
3637

@@ -192,8 +193,8 @@ public static class ControllerConfig {
192193
private final Map<String, Event> postprocessorEventList = new LinkedHashMap<>();
193194
private final Map<String, Event> afterLoginEventList = new LinkedHashMap<>();
194195
private final Map<String, Event> beforeLogoutEventList = new LinkedHashMap<>();
195-
private Map<String, String> eventHandlerMap = new HashMap<>();
196-
private Map<String, String> viewHandlerMap = new HashMap<>();
196+
private final Map<String, String> eventHandlerMap = new HashMap<>();
197+
private final Map<String, String> viewHandlerMap = new HashMap<>();
197198
private MultivaluedMapContext<String, RequestMap> requestMapMap = new MultivaluedMapContext<>();
198199
private Map<String, ViewMap> viewMapMap = new HashMap<>();
199200

@@ -359,17 +360,11 @@ private void loadGeneralConfig(Element rootElement) {
359360
}
360361

361362
private void loadHandlerMap(Element rootElement) {
362-
for (Element handlerElement : UtilXml.childElementList(rootElement, "handler")) {
363-
String name = handlerElement.getAttribute("name");
364-
String type = handlerElement.getAttribute("type");
365-
String className = handlerElement.getAttribute("class");
366-
367-
if ("view".equals(type)) {
368-
this.viewHandlerMap.put(name, className);
369-
} else {
370-
this.eventHandlerMap.put(name, className);
371-
}
372-
}
363+
Map<Boolean, Map<String, String>> handlers = UtilXml.childElementList(rootElement, "handler").stream()
364+
.collect(Collectors.partitioningBy(el -> "view".equals(el.getAttribute("type")),
365+
Collectors.toMap(el -> el.getAttribute("name"), el -> el.getAttribute("class"))));
366+
viewHandlerMap.putAll(handlers.get(true));
367+
eventHandlerMap.putAll(handlers.get(false));
373368
}
374369

375370
protected void loadIncludes(Element rootElement) {

0 commit comments

Comments
 (0)