Skip to content
Permalink
Browse files

Improved: Rewrite ‘loadHandlerMap’

(OFBIZ-10453)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1862323 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed Jun 29, 2019
1 parent 6e3490d commit 760ab05112f69b3a203c01f245ba87fa90cfed91
@@ -192,8 +192,8 @@ private static Element loadDocument(URL location) throws WebAppConfigurationExce
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 @@ private void loadGeneralConfig(Element rootElement) {
}

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) {

0 comments on commit 760ab05

Please sign in to comment.
You can’t perform that action at this time.