svn commit: r1830303 - /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: r1830303 - /ofbiz/ofbiz-framework/trunk/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java

nmalin
Author: nmalin
Date: Fri Apr 27 07:26:58 2018
New Revision: 1830303

URL: http://svn.apache.org/viewvc?rev=1830303&view=rev
Log:
Fixed: ConfigXMLReader - Events are not executed in the order defined
(OFBIZ-10369)
The events contained in the controller configuration for first-visit, pre-post processor and before-after login are executed in arbitrary order rather than the defined order.
If we define an event configuration as follow:

    <after-login>
        <event name=keepCartUpdated type=java path=org.apache.ofbiz.order.shoppingcart.ShoppingCartEvents invoke=keepCartUpdated/>
        <event name=restoreAutoSaveList type=java path=org.apache.ofbiz.order.shoppinglist.ShoppingListEvents invoke=restoreAutoSaveList/>
        <event name=saveCartToAutoSaveList type=java path=org.apache.ofbiz.order.shoppinglist.ShoppingListEvents invoke=saveCartToAutoSaveList/>
    </after-login>

We wait that OFBIz run keepCartUpdated, restoreAutoSaveList and after saveCartToAutoSaveList event but the HashMap who organise them return arbitrary order and can return saveCartToAutoSaveList, keepCartUpdated and restoreAutoSaveList. Convert the HashMap to LinkedHashMap help to keep the loaded order.

Thanks to Vikas Mayur for solve this issue

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=1830303&r1=1830302&r2=1830303&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 Fri Apr 27 07:26:58 2018
@@ -25,6 +25,7 @@ import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -183,11 +184,11 @@ public class ConfigXMLReader {
         private String defaultRequest;
         private String statusCode;
         private List<URL> includes = new ArrayList<URL>();
-        private Map<String, Event> firstVisitEventList = new HashMap<String, Event>();
-        private Map<String, Event> preprocessorEventList = new HashMap<String, Event>();
-        private Map<String, Event> postprocessorEventList = new HashMap<String, Event>();
-        private Map<String, Event> afterLoginEventList = new HashMap<String, Event>();
-        private Map<String, Event> beforeLogoutEventList = new HashMap<String, Event>();
+        private Map<String, Event> firstVisitEventList = new LinkedHashMap<String, Event>();
+        private Map<String, Event> preprocessorEventList = new LinkedHashMap<String, Event>();
+        private Map<String, Event> postprocessorEventList = new LinkedHashMap<String, Event>();
+        private Map<String, Event> afterLoginEventList = new LinkedHashMap<String, Event>();
+        private Map<String, Event> beforeLogoutEventList = new LinkedHashMap<String, Event>();
         private Map<String, String> eventHandlerMap = new HashMap<String, String>();
         private Map<String, String> viewHandlerMap = new HashMap<String, String>();
         private Map<String, RequestMap> requestMapMap = new HashMap<String, RequestMap>();