svn commit: r682067 [1/2] - in /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp: control/ event/ ftl/ region/ stats/ taglib/ view/

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

svn commit: r682067 [1/2] - in /ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp: control/ event/ ftl/ region/ stats/ taglib/ view/

doogie-3
Author: doogie
Date: Sat Aug  2 14:56:42 2008
New Revision: 682067

URL: http://svn.apache.org/viewvc?rev=682067&view=rev
Log:
Another large set of generics/java15 markup/feature usage.

Modified:
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestManager.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/AbstractJSONEventHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/DojoJSONServiceEventHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/EventFactory.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/JSONJavaEventHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/JSONServiceEventHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/JavaEventHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceStreamHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/WfsEventHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewHandler.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizCacheStorage.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/RenderWrappedTextTransform.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/region/Region.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/region/RegionManager.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/region/RegionStack.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/AbstractParameterTag.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/I18nMessageTag.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/IterateNextTag.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/IteratorTag.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ObjectTag.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ServiceTag.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ViewFactory.java
    ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/WfsViewHandler.java

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java?rev=682067&r1=682066&r2=682067&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ConfigXMLReader.java Sat Aug  2 14:56:42 2008
@@ -35,6 +35,7 @@
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.FileUtil;
 import org.ofbiz.base.util.GeneralException;
+import static org.ofbiz.base.util.UtilGenerics.checkMap;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.UtilXml;
@@ -48,15 +49,15 @@
 public class ConfigXMLReader {
 
     public static final String module = ConfigXMLReader.class.getName();
-    public static UtilCache controllerCache = new UtilCache("webapp.ControllerConfig");
-    public static UtilCache<String, List<ControllerConfig>> controllerSearchResultsCache = new UtilCache("webapp.ControllerSearchResults");
+    public static UtilCache<URL, ControllerConfig> controllerCache = new UtilCache<URL, ControllerConfig>("webapp.ControllerConfig");
+    public static UtilCache<String, List<ControllerConfig>> controllerSearchResultsCache = new UtilCache<String, List<ControllerConfig>>("webapp.ControllerSearchResults");
 
     public static ControllerConfig getControllerConfig(URL url) {
-        ControllerConfig controllerConfig = (ControllerConfig) controllerCache.get(url);
+        ControllerConfig controllerConfig = controllerCache.get(url);
         if (controllerConfig == null) { // don't want to block here
             synchronized (ConfigXMLReader.class) {
                 // must check if null again as one of the blocked threads can still enter
-                controllerConfig = (ControllerConfig) controllerCache.get(url);
+                controllerConfig = controllerCache.get(url);
                 if (controllerConfig == null) {
                     controllerConfig = new ControllerConfig(url);
                     controllerCache.put(url, controllerConfig);
@@ -69,8 +70,8 @@
     public static class ControllerConfig {
         public URL url;
         
-        public Map configMap = FastMap.newInstance();
-        public Map handlerMap = FastMap.newInstance();
+        public Map<String, Object> configMap = FastMap.newInstance();
+        public Map<String, Map<String, String>> handlerMap = FastMap.newInstance();
         public Map<String, Map<String, Object>> requestMap = FastMap.newInstance();
         public Map<String, Map<String, String>> viewMap = FastMap.newInstance();
         public String defaultRequest = null;
@@ -257,14 +258,11 @@
 
         if (root == null) return map;
 
-        List<? extends Element> includeElementList = UtilXml.childElementList(root, INCLUDE);
-        Iterator<? extends Element> includeElementIter = includeElementList.iterator();
-        while (includeElementIter.hasNext()) {
-            Element includeElement = (Element) includeElementIter.next();
+        for (Element includeElement: UtilXml.childElementList(root, INCLUDE)) {
             String includeLocation = includeElement.getAttribute(INCLUDE_LOCATION);
             if ((includeLocation != null) && (includeLocation.length() > 0)) {
                 try {
-                    Map subMap = loadRequestMap(null, FlexibleLocation.resolveLocation(includeLocation));
+                    Map<String, Map<String, Object>> subMap = loadRequestMap(null, FlexibleLocation.resolveLocation(includeLocation));
                     map.putAll(subMap);
                 } catch (MalformedURLException mue) {
                     Debug.logError(mue, "Error processing include at [" + includeLocation + "]:" + mue.toString(), module);
@@ -272,10 +270,7 @@
             }
         }
 
-        List<? extends Element> requestMapElementList = UtilXml.childElementList(root, REQUEST_MAPPING);
-        Iterator<? extends Element> requestMapElementIter = requestMapElementList.iterator();
-        while (requestMapElementIter.hasNext()) {
-            Element requestMapElement = (Element) requestMapElementIter.next();
+        for (Element requestMapElement: UtilXml.childElementList(root, REQUEST_MAPPING)) {
             
             // Create a URI-MAP for each element found.
             Map<String, Object> uriMap = FastMap.newInstance();
@@ -339,10 +334,7 @@
             Map<String, String> responseMap = FastMap.newInstance();
             uriMap.put(RESPONSE_MAP, responseMap);
             
-            List<? extends Element> responseElementList = UtilXml.childElementList(requestMapElement, RESPONSE);
-            Iterator<? extends Element> responseElementIter = responseElementList.iterator();
-            while (responseElementIter.hasNext()) {
-                Element responseElement = (Element) responseElementIter.next();
+            for (Element responseElement: UtilXml.childElementList(requestMapElement, RESPONSE)) {
                 String name = responseElement.getAttribute(RESPONSE_NAME);
                 String type = responseElement.getAttribute(RESPONSE_TYPE);
                 String value = responseElement.getAttribute(RESPONSE_VALUE);
@@ -405,14 +397,11 @@
             return map;
         }
 
-        List<? extends Element> includeElementList = UtilXml.childElementList(root, INCLUDE);
-        Iterator<? extends Element> includeElementIter = includeElementList.iterator();
-        while (includeElementIter.hasNext()) {
-            Element includeElement = (Element) includeElementIter.next();
+        for (Element includeElement: UtilXml.childElementList(root, INCLUDE)) {
             String includeLocation = includeElement.getAttribute(INCLUDE_LOCATION);
             if ((includeLocation != null) && (includeLocation.length() > 0)) {
                 try {
-                    Map subMap = loadViewMap(null, FlexibleLocation.resolveLocation(includeLocation));
+                    Map<String, Map<String, String>> subMap = loadViewMap(null, FlexibleLocation.resolveLocation(includeLocation));
                     map.putAll(subMap);
                 } catch (MalformedURLException mue) {
                     Debug.logError(mue, "Error processing include at [" + includeLocation + "]:" + mue.toString(), module);
@@ -420,10 +409,7 @@
             }
         }
 
-        List<? extends Element> viewMapElementList = UtilXml.childElementList(root, VIEW_MAPPING);
-        Iterator<? extends Element> viewMapElementIter = viewMapElementList.iterator();
-        while (viewMapElementIter.hasNext()) {
-            Element viewMapElement = (Element) viewMapElementIter.next();
+        for (Element viewMapElement: UtilXml.childElementList(root, VIEW_MAPPING)) {
             // Create a URI-MAP for each element found.
             Map<String, String> uriMap = FastMap.newInstance();
 
@@ -482,15 +468,15 @@
     }
 
     /** Gets a FastMap of site configuration variables. */
-    public static Map getConfigMap(URL xml) {
+    public static Map<String, Object> getConfigMap(URL xml) {
         ControllerConfig controllerConfig = getControllerConfig(xml);
         return controllerConfig != null ? controllerConfig.configMap : null;
     }
 
     /** Gets a FastMap of site configuration variables. */
-    public static Map loadConfigMap(Element root, URL xml) {
+    public static Map<String, Object> loadConfigMap(Element root, URL xml) {
         long startTime = System.currentTimeMillis();
-        FastMap map = FastMap.newInstance();
+        FastMap<String, Object> map = FastMap.newInstance();
         if (root == null) {
             root = loadDocument(xml);
         }
@@ -499,14 +485,11 @@
             return map;
         }
 
-        List includeElementList = UtilXml.childElementList(root, INCLUDE);
-        Iterator includeElementIter = includeElementList.iterator();
-        while (includeElementIter.hasNext()) {
-            Element includeElement = (Element) includeElementIter.next();
+        for (Element includeElement: UtilXml.childElementList(root, INCLUDE)) {
             String includeLocation = includeElement.getAttribute(INCLUDE_LOCATION);
             if ((includeLocation != null) && (includeLocation.length() > 0)) {
                 try {
-                    Map subMap = loadConfigMap(null, FlexibleLocation.resolveLocation(includeLocation));
+                    Map<String, Object> subMap = loadConfigMap(null, FlexibleLocation.resolveLocation(includeLocation));
                     map.putAll(subMap);
                 } catch (MalformedURLException mue) {
                     Debug.logError(mue, "Error processing include at [" + includeLocation + "]:" + mue.toString(), module);
@@ -529,12 +512,9 @@
         // first visit event
         Element firstvisitElement = UtilXml.firstChildElement(root, FIRSTVISIT);
         if (firstvisitElement != null) {
-            List eventList = FastList.newInstance();
-            List eventElementList = UtilXml.childElementList(firstvisitElement, EVENT);
-            Iterator eventElementIter = eventElementList.iterator();
-            while (eventElementIter.hasNext()) {
-                Element eventElement = (Element) eventElementIter.next();
-                FastMap eventMap = FastMap.newInstance();
+            List<Map<String, String>> eventList = FastList.newInstance();
+            for (Element eventElement: UtilXml.childElementList(firstvisitElement, EVENT)) {
+                Map<String, String> eventMap = FastMap.newInstance();
                 eventMap.put(EVENT_TYPE, eventElement.getAttribute(EVENT_TYPE));
                 eventMap.put(EVENT_PATH, eventElement.getAttribute(EVENT_PATH));
                 eventMap.put(EVENT_METHOD, eventElement.getAttribute(EVENT_METHOD));
@@ -549,12 +529,9 @@
         // preprocessor events
         Element preprocessorElement = UtilXml.firstChildElement(root, PREPROCESSOR);
         if (preprocessorElement != null) {
-            List eventList = FastList.newInstance();
-            List eventElementList = UtilXml.childElementList(preprocessorElement, EVENT);
-            Iterator eventElementIter = eventElementList.iterator();
-            while (eventElementIter.hasNext()) {
-                Element eventElement = (Element) eventElementIter.next();
-                FastMap eventMap = FastMap.newInstance();
+            List<Map<String, String>> eventList = FastList.newInstance();
+            for (Element eventElement: UtilXml.childElementList(preprocessorElement, EVENT)) {
+                Map<String, String> eventMap = FastMap.newInstance();
                 eventMap.put(EVENT_TYPE, eventElement.getAttribute(EVENT_TYPE));
                 eventMap.put(EVENT_PATH, eventElement.getAttribute(EVENT_PATH));
                 eventMap.put(EVENT_METHOD, eventElement.getAttribute(EVENT_METHOD));
@@ -569,12 +546,9 @@
         // postprocessor events
         Element postprocessorElement = UtilXml.firstChildElement(root, POSTPROCESSOR);
         if (postprocessorElement != null) {
-            List eventList = FastList.newInstance();
-            List eventElementList = UtilXml.childElementList(postprocessorElement, EVENT);
-            Iterator eventElementIter = eventElementList.iterator();
-            while (eventElementIter.hasNext()) {
-                Element eventElement = (Element) eventElementIter.next();
-                FastMap eventMap = FastMap.newInstance();
+            List<Map<String, String>> eventList = FastList.newInstance();
+            for (Element eventElement: UtilXml.childElementList(postprocessorElement, EVENT)) {
+                Map<String, String> eventMap = FastMap.newInstance();
                 eventMap.put(EVENT_TYPE, eventElement.getAttribute(EVENT_TYPE));
                 eventMap.put(EVENT_PATH, eventElement.getAttribute(EVENT_PATH));
                 eventMap.put(EVENT_METHOD, eventElement.getAttribute(EVENT_METHOD));
@@ -589,12 +563,9 @@
         // after-login events
         Element afterLoginElement = UtilXml.firstChildElement(root, "after-login");
         if (afterLoginElement != null) {
-            List eventList = FastList.newInstance();
-            List eventElementList = UtilXml.childElementList(afterLoginElement, EVENT);
-            Iterator eventElementIter = eventElementList.iterator();
-            while (eventElementIter.hasNext()) {
-                Element eventElement = (Element) eventElementIter.next();
-                FastMap eventMap = FastMap.newInstance();
+            List<Map<String, String>> eventList = FastList.newInstance();
+            for (Element eventElement: UtilXml.childElementList(afterLoginElement, EVENT)) {
+                Map<String, String> eventMap = FastMap.newInstance();
                 eventMap.put(EVENT_TYPE, eventElement.getAttribute(EVENT_TYPE));
                 eventMap.put(EVENT_PATH, eventElement.getAttribute(EVENT_PATH));
                 eventMap.put(EVENT_METHOD, eventElement.getAttribute(EVENT_METHOD));
@@ -609,12 +580,10 @@
         // before-logout events
         Element beforeLogoutElement = UtilXml.firstChildElement(root, "before-logout");
         if (beforeLogoutElement != null) {
-            List eventList = FastList.newInstance();
-            List eventElementList = UtilXml.childElementList(beforeLogoutElement, EVENT);
-            Iterator eventElementIter = eventElementList.iterator();
-            while (eventElementIter.hasNext()) {
-                Element eventElement = (Element) eventElementIter.next();
-                FastMap eventMap = FastMap.newInstance();
+            List<Map<String, String>> eventList = FastList.newInstance();
+            List<? extends Element> eventElementList = UtilXml.childElementList(beforeLogoutElement, EVENT);
+            for (Element eventElement: UtilXml.childElementList(beforeLogoutElement, EVENT)) {
+                Map<String, String> eventMap = FastMap.newInstance();
                 eventMap.put(EVENT_TYPE, eventElement.getAttribute(EVENT_TYPE));
                 eventMap.put(EVENT_PATH, eventElement.getAttribute(EVENT_PATH));
                 eventMap.put(EVENT_METHOD, eventElement.getAttribute(EVENT_METHOD));
@@ -671,10 +640,7 @@
         // holder for the default-request
         String defaultRequest = null;
 
-        List includeElementList = UtilXml.childElementList(root, INCLUDE);
-        Iterator includeElementIter = includeElementList.iterator();
-        while (includeElementIter.hasNext()) {
-            Element includeElement = (Element) includeElementIter.next();
+        for (Element includeElement: UtilXml.childElementList(root, INCLUDE)) {
             String includeLocation = includeElement.getAttribute(INCLUDE_LOCATION);
             if ((includeLocation != null) && (includeLocation.length() > 0)) {
                 try {
@@ -693,14 +659,14 @@
     }
 
     /** Gets a FastMap of handler mappings. */
-    public static Map getHandlerMap(URL xml) {
+    public static Map<String, Map<String, String>> getHandlerMap(URL xml) {
         ControllerConfig controllerConfig = getControllerConfig(xml);
         return controllerConfig != null ? controllerConfig.handlerMap : null;
     }
 
-    public static Map loadHandlerMap(Element root, URL xml) {
+    public static Map<String, Map<String, String>> loadHandlerMap(Element root, URL xml) {
         long startTime = System.currentTimeMillis();
-        FastMap map = FastMap.newInstance();
+        Map<String, Map<String, String>> map = FastMap.newInstance();
         if (root == null) {
             root = loadDocument(xml);
         }
@@ -708,17 +674,14 @@
             return map;
         }
 
-        List includeElementList = UtilXml.childElementList(root, INCLUDE);
-        Iterator includeElementIter = includeElementList.iterator();
-        while (includeElementIter.hasNext()) {
-            Element includeElement = (Element) includeElementIter.next();
+        for (Element includeElement: UtilXml.childElementList(root, INCLUDE)) {
             String includeLocation = includeElement.getAttribute(INCLUDE_LOCATION);
             if ((includeLocation != null) && (includeLocation.length() > 0)) {
                 try {
-                    Map subMap = loadHandlerMap(null, FlexibleLocation.resolveLocation(includeLocation));
+                    Map<String, Map<String, String>> subMap = loadHandlerMap(null, FlexibleLocation.resolveLocation(includeLocation));
 
-                    Map newViewHandlerMap = (Map) subMap.get("view");
-                    Map viewHandlerMap = (Map) map.get("view");
+                    Map<String, String> newViewHandlerMap = checkMap(subMap.get("view"), String.class, String.class);
+                    Map<String, String> viewHandlerMap = checkMap(map.get("view"), String.class, String.class);
                     if (viewHandlerMap == null) {
                         map.put("view", newViewHandlerMap);
                     } else {
@@ -727,8 +690,8 @@
                         }
                     }
 
-                    Map newEventHandlerMap = (Map) subMap.get("event");
-                    Map eventHandlerMap = (Map) map.get("event");
+                    Map<String, String> newEventHandlerMap = checkMap(subMap.get("event"), String.class, String.class);
+                    Map<String, String> eventHandlerMap = checkMap(map.get("event"), String.class, String.class);
                     if (eventHandlerMap == null) {
                         map.put("event", newEventHandlerMap);
                     } else {
@@ -742,13 +705,10 @@
             }
         }
 
-        Map eventMap = FastMap.newInstance();
-        Map viewMap = FastMap.newInstance();
+        Map<String, String> eventMap = FastMap.newInstance();
+        Map<String, String> viewMap = FastMap.newInstance();
 
-        List handlerElementList = UtilXml.childElementList(root, HANDLER);
-        Iterator handlerElementIter = handlerElementList.iterator();
-        while (handlerElementIter.hasNext()) {
-            Element handlerElement = (Element) handlerElementIter.next();
+        for (Element handlerElement: UtilXml.childElementList(root, HANDLER)) {
             String hName = checkEmpty(handlerElement.getAttribute(HANDLER_NAME));
             String hClass = checkEmpty(handlerElement.getAttribute(HANDLER_CLASS));
             String hType = checkEmpty(handlerElement.getAttribute(HANDLER_TYPE));
@@ -759,7 +719,7 @@
             }
         }
 
-        Map viewHandlerMap = (Map) map.get("view");
+        Map<String, String> viewHandlerMap = checkMap(map.get("view"), String.class, String.class);
         if (viewHandlerMap == null) {
             map.put("view", viewMap);
         } else {
@@ -767,7 +727,7 @@
                 viewHandlerMap.putAll(viewMap);
             }
         }
-        Map eventHandlerMap = (Map) map.get("event");
+        Map<String, String> eventHandlerMap = checkMap(map.get("event"), String.class, String.class);
         if (eventHandlerMap == null) {
             map.put("event", eventMap);
         } else {
@@ -779,28 +739,22 @@
         /* Debugging */
         if (Debug.verboseOn()) {
             Debug.logVerbose("-------- Handler Mappings --------", module);
-            Map debugMap = (Map) map.get("event");
+            Map<String, String> debugMap = checkMap(map.get("event"), String.class, String.class);
 
             if (debugMap != null && debugMap.size() > 0) {
                 Debug.logVerbose("-------------- EVENT -------------", module);
-                Set debugSet = debugMap.keySet();
-                Iterator i = debugSet.iterator();
-                while (i.hasNext()) {
-                    Object o = i.next();
-                    String handlerName = (String) o;
-                    String className = (String) debugMap.get(o);
+                for (Map.Entry<String, String> entry: debugMap.entrySet()) {
+                    String handlerName = entry.getKey();
+                    String className = entry.getValue();
                     Debug.logVerbose("[EH] : " + handlerName + " => " + className, module);
                 }
             }
-            debugMap = (Map) map.get("view");
+            debugMap = checkMap(map.get("view"), String.class, String.class);
             if (debugMap != null && debugMap.size() > 0) {
                 Debug.logVerbose("-------------- VIEW --------------", module);
-                Set debugSet = debugMap.keySet();
-                Iterator i = debugSet.iterator();
-                while (i.hasNext()) {
-                    Object o = i.next();
-                    String handlerName = (String) o;
-                    String className = (String) debugMap.get(o);
+                for (Map.Entry<String, String> entry: debugMap.entrySet()) {
+                    String handlerName = entry.getKey();
+                    String className = entry.getValue();
                     Debug.logVerbose("[VH] : " + handlerName + " => " + className, module);
                 }
             }

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java?rev=682067&r1=682066&r2=682067&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/ContextFilter.java Sat Aug  2 14:56:42 2008
@@ -37,6 +37,8 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponseWrapper;
 
+import javolution.util.FastList;
+
 import org.ofbiz.base.container.Container;
 import org.ofbiz.base.container.ContainerException;
 import org.ofbiz.base.container.ContainerLoader;
@@ -44,6 +46,7 @@
 import org.ofbiz.base.util.CachedClassLoader;
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.StringUtil;
+import static org.ofbiz.base.util.UtilGenerics.checkMap;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.UtilObject;
@@ -139,12 +142,10 @@
         String reqAttrMapHex = (String) httpRequest.getSession().getAttribute("_REQ_ATTR_MAP_");
         if (UtilValidate.isNotEmpty(reqAttrMapHex)) {
             byte[] reqAttrMapBytes = StringUtil.fromHexString(reqAttrMapHex);
-            Map reqAttrMap = (Map) UtilObject.getObject(reqAttrMapBytes);
+            Map<String, Object> reqAttrMap = checkMap(UtilObject.getObject(reqAttrMapBytes), String.class, Object.class);
             if (reqAttrMap != null) {
-                Iterator i = reqAttrMap.keySet().iterator();
-                while (i.hasNext()) {
-                    String key = (String) i.next();
-                    request.setAttribute(key, reqAttrMap.get(key));
+                for (Map.Entry<String, Object> entry: reqAttrMap.entrySet()) {
+                    request.setAttribute(entry.getKey(), entry.getValue());
                 }
             }
             httpRequest.getSession().removeAttribute("_REQ_ATTR_MAP_");
@@ -185,7 +186,7 @@
             String redirectPath = config.getInitParameter("redirectPath");
             String errorCode = config.getInitParameter("errorCode");
 
-            List allowList = StringUtil.split(allowedPath, ":");
+            List<String> allowList = StringUtil.split(allowedPath, ":");
             allowList.add("/");  // No path is allowed.
             allowList.add("");   // No path is allowed.
 
@@ -221,8 +222,8 @@
 
             // Verbose Debugging
             if (Debug.verboseOn()) {
-                for (int i = 0; i < allowList.size(); i++) {
-                    Debug.logVerbose("[Allow]: " + allowList.get(i), module);
+                for (String allow: allowList) {
+                    Debug.logVerbose("[Allow]: " + allow, module);
                 }
                 Debug.logVerbose("[Request path]: " + requestPath, module);
                 Debug.logVerbose("[Request info]: " + requestInfo, module);
@@ -280,17 +281,13 @@
                 Debug.logError("[ContextFilter.init] ERROR: delegator not defined.", module);
                 return null;
             }
-            Collection readers = null;
+            Collection<URL> readers = null;
             String readerFiles = config.getServletContext().getInitParameter("serviceReaderUrls");
 
             if (readerFiles != null) {
-                readers = new ArrayList();
-                List readerList = StringUtil.split(readerFiles, ";");
-                Iterator i = readerList.iterator();
-
-                while (i.hasNext()) {
+                readers = FastList.newInstance();
+                for (String name: StringUtil.split(readerFiles, ";")) {
                     try {
-                        String name = (String) i.next();
                         URL readerURL = config.getServletContext().getResource(name);
 
                         if (readerURL != null)

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java?rev=682067&r1=682066&r2=682067&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/LoginWorker.java Sat Aug  2 14:56:42 2008
@@ -47,6 +47,7 @@
 import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.KeyStoreUtil;
 import org.ofbiz.base.util.UtilFormatOut;
+import static org.ofbiz.base.util.UtilGenerics.checkMap;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilProperties;
@@ -271,7 +272,7 @@
 
             // in this condition log them in if not already; if not logged in or can't log in, save parameters and return error
             if ((username == null) || (password == null) || ("error".equals(login(request, response)))) {
-                Map reqParams = UtilHttp.getParameterMap(request);
+                Map<String, Object> reqParams = UtilHttp.getParameterMap(request);
                 String queryString = UtilHttp.urlEncodeArgs(reqParams);
                 Debug.logInfo("reqParams Map: " + reqParams, module);
                 Debug.logInfo("queryString: " + queryString, module);
@@ -319,7 +320,7 @@
             password = (String) request.getAttribute("PASSWORD");
         }
 
-        List unpwErrMsgList = FastList.newInstance();
+        List<String> unpwErrMsgList = FastList.newInstance();
         if (UtilValidate.isEmpty(username)) {
             unpwErrMsgList.add(UtilProperties.getMessage(resourceWebapp, "loginevents.username_was_empty_reenter", UtilHttp.getLocale(request)));
         }
@@ -345,9 +346,9 @@
         String visitId = VisitHandler.getVisitId(session);
 
         LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
-        Map result = null;
+        Map<String, Object> result = null;
         if (UtilValidate.isNotEmpty(requirePasswordChange) && "Y".equals(requirePasswordChange)) {
-            Map inMap = UtilMisc.toMap("login.username", username, "login.password", password, "locale", UtilHttp.getLocale(request));
+            Map<String, Object> inMap = UtilMisc.<String, Object>toMap("login.username", username, "login.password", password, "locale", UtilHttp.getLocale(request));
             inMap.put("userLoginId", username);
             inMap.put("currentPassword", password);
             inMap.put("newPassword", request.getParameter("newPassword"));
@@ -356,13 +357,13 @@
                 result = dispatcher.runSync("updatePassword", inMap);
             } catch (GenericServiceException e) {
                 Debug.logError(e, "Error calling updatePassword service", module);
-                Map messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
+                Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
                 String errMsg = UtilProperties.getMessage(resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request));
                 request.setAttribute("_ERROR_MESSAGE_", errMsg);
                 return "error";
             }
             if (ServiceUtil.isError(result)) {
-                Map messageMap = UtilMisc.toMap("errorMessage", (String) result.get(ModelService.ERROR_MESSAGE));
+                Map<String, String> messageMap = UtilMisc.toMap("errorMessage", (String) result.get(ModelService.ERROR_MESSAGE));
                 String errMsg = UtilProperties.getMessage(resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request));
                 request.setAttribute("_ERROR_MESSAGE_", errMsg);
                 return "error";
@@ -375,7 +376,7 @@
             result = dispatcher.runSync("userLogin", UtilMisc.toMap("login.username", username, "login.password", password, "visitId", visitId, "locale", UtilHttp.getLocale(request)));
         } catch (GenericServiceException e) {
             Debug.logError(e, "Error calling userLogin service", module);
-            Map messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
+            Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
             String errMsg = UtilProperties.getMessage(resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request));
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
@@ -383,7 +384,7 @@
 
         if (ModelService.RESPOND_SUCCESS.equals(result.get(ModelService.RESPONSE_MESSAGE))) {
             GenericValue userLogin = (GenericValue) result.get("userLogin");
-            Map userLoginSession = (Map) result.get("userLoginSession");
+            Map<String, Object> userLoginSession = checkMap(result.get("userLoginSession"), String.class, Object.class);
             if (userLogin != null && "Y".equals(userLogin.getString("requirePasswordChange"))) {
                 return "requirePasswordChange";
             }
@@ -398,14 +399,14 @@
             }
             return doMainLogin(request, response, userLogin, userLoginSession);
         } else {
-            Map messageMap = UtilMisc.toMap("errorMessage", (String) result.get(ModelService.ERROR_MESSAGE));
+            Map<String, String> messageMap = UtilMisc.toMap("errorMessage", (String) result.get(ModelService.ERROR_MESSAGE));
             String errMsg = UtilProperties.getMessage(resourceWebapp, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request));
             request.setAttribute("_ERROR_MESSAGE_", errMsg);
             return "error";
         }
     }
 
-    public static String doMainLogin(HttpServletRequest request, HttpServletResponse response, GenericValue userLogin, Map userLoginSession) {
+    public static String doMainLogin(HttpServletRequest request, HttpServletResponse response, GenericValue userLogin, Map<String, Object> userLoginSession) {
         HttpSession session = request.getSession();
         if (userLogin != null && hasBasePermission(userLogin, request)) {
             doBasicLogin(userLogin, request);
@@ -538,9 +539,9 @@
         Cookie[] cookies = request.getCookies();
         if (Debug.verboseOn()) Debug.logVerbose("Cookies:" + cookies, module);
         if (cookies != null) {
-            for (int i = 0; i < cookies.length; i++) {
-                if (cookies[i].getName().equals(getAutoLoginCookieName(request))) {
-                    autoUserLoginId = cookies[i].getValue();
+            for (Cookie cookie: cookies) {
+                if (cookie.getName().equals(getAutoLoginCookieName(request))) {
+                    autoUserLoginId = cookie.getValue();
                     break;
                 }
             }
@@ -638,7 +639,7 @@
                                 userLogin.store();
 
                                 // login the user
-                                Map ulSessionMap = LoginServices.getUserLoginSession(userLogin);
+                                Map<String, Object> ulSessionMap = LoginServices.getUserLoginSession(userLogin);
                                 return doMainLogin(request, response, userLogin, ulSessionMap); // doing the main login
                             }
                         }
@@ -709,7 +710,7 @@
                                         userLogin.store();
 
                                         // login the user
-                                        Map ulSessionMap = LoginServices.getUserLoginSession(userLogin);
+                                        Map<String, Object> ulSessionMap = LoginServices.getUserLoginSession(userLogin);
                                         return doMainLogin(request, response, userLogin, ulSessionMap); // doing the main login
                                     }
                                 }
@@ -819,9 +820,8 @@
         ComponentConfig.WebappInfo info = ComponentConfig.getWebAppInfo(serverId, contextPath);
         if (security != null) {
             if (info != null) {
-                String[] permissions = info.getBasePermission();
-                for (int i = 0; i < permissions.length; i++) {
-                    if (!"NONE".equals(permissions[i]) && !security.hasEntityPermission(permissions[i], "_VIEW", userLogin)) {
+                for (String permission: info.getBasePermission()) {
+                    if (!"NONE".equals(permission) && !security.hasEntityPermission(permission, "_VIEW", userLogin)) {
                         return false;
                     }
                 }

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java?rev=682067&r1=682066&r2=682067&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestHandler.java Sat Aug  2 14:56:42 2008
@@ -29,6 +29,7 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
+import static org.ofbiz.base.util.UtilGenerics.checkMap;
 import org.ofbiz.base.util.*;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.entity.GenericEntityException;
@@ -184,16 +185,13 @@
                     Debug.logInfo("This is the first request in this visit." + " sessionId=" + UtilHttp.getSessionId(request), module);
                 // This isn't an event because it is required to run. We do not want to make it optional.
                 GenericValue visit = VisitHandler.getVisit(session);
-                Collection events = requestManager.getFirstVisitEvents();
+                Collection<Map<String, String>> events = requestManager.getFirstVisitEvents();
 
                 if (visit != null && events != null) {
-                    Iterator i = events.iterator();
-
-                    while (i.hasNext()) {
-                        Map eventMap = (Map) i.next();
-                        String eType = (String) eventMap.get(ConfigXMLReader.EVENT_TYPE);
-                        String ePath = (String) eventMap.get(ConfigXMLReader.EVENT_PATH);
-                        String eMeth = (String) eventMap.get(ConfigXMLReader.EVENT_METHOD);
+                    for (Map<String, String> eventMap: events) {
+                        String eType = eventMap.get(ConfigXMLReader.EVENT_TYPE);
+                        String ePath = eventMap.get(ConfigXMLReader.EVENT_PATH);
+                        String eMeth = eventMap.get(ConfigXMLReader.EVENT_METHOD);
 
                         try {
                             String returnString = this.runEvent(request, response, eType, ePath, eMeth);
@@ -210,15 +208,12 @@
             }
 
             // Invoke the pre-processor (but NOT in a chain)
-            Collection preProcEvents = requestManager.getPreProcessor();
+            Collection<Map<String, String>> preProcEvents = requestManager.getPreProcessor();
             if (preProcEvents != null) {
-                Iterator i = preProcEvents.iterator();
-
-                while (i.hasNext()) {
-                    Map eventMap = (Map) i.next();
-                    String eType = (String) eventMap.get(ConfigXMLReader.EVENT_TYPE);
-                    String ePath = (String) eventMap.get(ConfigXMLReader.EVENT_PATH);
-                    String eMeth = (String) eventMap.get(ConfigXMLReader.EVENT_METHOD);
+                for (Map<String, String> eventMap: preProcEvents) {
+                    String eType = eventMap.get(ConfigXMLReader.EVENT_TYPE);
+                    String ePath = eventMap.get(ConfigXMLReader.EVENT_PATH);
+                    String eMeth = eventMap.get(ConfigXMLReader.EVENT_METHOD);
                     try {
                         String returnString = this.runEvent(request, response, eType, ePath, eMeth);
                         if (returnString != null && !returnString.equalsIgnoreCase("success")) {
@@ -336,15 +331,13 @@
         if (preReqAttStr != null) {
             request.getSession().removeAttribute("_REQ_ATTR_MAP_");
             byte[] reqAttrMapBytes = StringUtil.fromHexString(preReqAttStr);
-            Map preRequestMap = (Map) UtilObject.getObject(reqAttrMapBytes);
+            Map<String, Object> preRequestMap = checkMap(UtilObject.getObject(reqAttrMapBytes), String.class, Object.class);
             if (preRequestMap != null && preRequestMap.size() > 0) {
-                Iterator keys = preRequestMap.keySet().iterator();
-                while (keys.hasNext()){
-                    String key = (String) keys.next();
+                for (Map.Entry<String, Object> entry: preRequestMap.entrySet()) {
+                    String key = entry.getKey();
                     if("_ERROR_MESSAGE_LIST_".equals(key) || "_ERROR_MESSAGE_MAP_".equals(key) || "_ERROR_MESSAGE_".equals(key) ||
                             "_EVENT_MESSAGE_LIST_".equals(key) || "_EVENT_MESSAGE_".equals(key)) {
-                        Object value = preRequestMap.get(key);
-                        request.setAttribute(key, value);
+                        request.setAttribute(key, entry.getValue());
                    }
                 }
             }
@@ -386,15 +379,12 @@
             doRequest(request, response, nextView, userLogin, delegator);
         } else { // handle views
             // first invoke the post-processor events.
-            Collection postProcEvents = requestManager.getPostProcessor();
+            Collection<Map<String, String>> postProcEvents = requestManager.getPostProcessor();
             if (chain == null && postProcEvents != null) { // don't run post-proc events on chained requests
-                Iterator i = postProcEvents.iterator();
-
-                while (i.hasNext()) {
-                    Map eventMap = (Map) i.next();
-                    String eType = (String) eventMap.get(ConfigXMLReader.EVENT_TYPE);
-                    String ePath = (String) eventMap.get(ConfigXMLReader.EVENT_PATH);
-                    String eMeth = (String) eventMap.get(ConfigXMLReader.EVENT_METHOD);
+                for (Map<String, String> eventMap: postProcEvents) {
+                    String eType = eventMap.get(ConfigXMLReader.EVENT_TYPE);
+                    String ePath = eventMap.get(ConfigXMLReader.EVENT_PATH);
+                    String eMeth = eventMap.get(ConfigXMLReader.EVENT_METHOD);
                     try {
                         String returnString = this.runEvent(request, response, eType, ePath, eMeth);
                         if (returnString != null && !returnString.equalsIgnoreCase("success"))
@@ -462,14 +452,13 @@
     }
 
     public String makeQueryString(HttpServletRequest request) {
-        Map paramMap = UtilHttp.getParameterMap(request);
+        Map<String, Object> paramMap = UtilHttp.getParameterMap(request);
         StringBuilder queryString = new StringBuilder();
         if (paramMap != null && paramMap.size() > 0) {
             queryString.append("?");
-            Iterator i = paramMap.keySet().iterator();
-            while (i.hasNext()) {
-                String name = (String) i.next();
-                Object value = paramMap.get(name);
+            for (Map.Entry<String, Object> entry: paramMap.entrySet()) {
+                String name = entry.getKey();
+                Object value = entry.getValue();
                 if (value instanceof String) {
                     if (queryString.length() > 1) {
                         queryString.append("&");
@@ -504,27 +493,26 @@
     }
 
     public static String getRequestUri(String path) {
-        List pathInfo = StringUtil.split(path, "/");
+        List<String> pathInfo = StringUtil.split(path, "/");
         if (UtilValidate.isEmpty(pathInfo)) {
             Debug.logWarning("Got nothing when splitting URI: " + path, module);
             return null;
         }
-        if (((String)pathInfo.get(0)).indexOf('?') > -1) {
-            return ((String) pathInfo.get(0)).substring(0, ((String)pathInfo.get(0)).indexOf('?'));
+        if (pathInfo.get(0).indexOf('?') > -1) {
+            return pathInfo.get(0).substring(0, pathInfo.get(0).indexOf('?'));
         } else {
-            return (String) pathInfo.get(0);
+            return pathInfo.get(0);
         }
     }
 
     public static String getNextPageUri(String path) {
-        List pathInfo = StringUtil.split(path, "/");
+        List<String> pathInfo = StringUtil.split(path, "/");
         if (pathInfo == null) {
             return null;
         }
 
         String nextPage = null;
-        for (int i = 1; i < pathInfo.size(); i++) {
-            String element = (String) pathInfo.get(i);
+        for (String element: pathInfo) {
             if (element.indexOf('~') != 0) {
                 if (element.indexOf('?') > -1) {
                     element = element.substring(0, element.indexOf('?'));
@@ -539,7 +527,7 @@
         if (Debug.infoOn()) Debug.logInfo("[Sending redirect]: " + url + " sessionId=" + UtilHttp.getSessionId(req), module);
         // set the attributes in the session so we can access it.
         java.util.Enumeration attributeNameEnum = req.getAttributeNames();
-        Map reqAttrMap = FastMap.newInstance();
+        Map<String, Object> reqAttrMap = FastMap.newInstance();
         while (attributeNameEnum.hasMoreElements()) {
             String name = (String) attributeNameEnum.nextElement();
             Object obj = req.getAttribute(name);
@@ -866,14 +854,12 @@
     }
 
     public void runAfterLoginEvents(HttpServletRequest request, HttpServletResponse response) {
-        List afterLoginEvents = requestManager.getAfterLoginEventList();
+        List<Map<String, String>> afterLoginEvents = requestManager.getAfterLoginEventList();
         if (afterLoginEvents != null) {
-            Iterator i = afterLoginEvents.iterator();
-            while (i.hasNext()) {
-                Map eventMap = (Map) i.next();
-                String eType = (String) eventMap.get(ConfigXMLReader.EVENT_TYPE);
-                String ePath = (String) eventMap.get(ConfigXMLReader.EVENT_PATH);
-                String eMeth = (String) eventMap.get(ConfigXMLReader.EVENT_METHOD);
+            for (Map<String, String> eventMap: afterLoginEvents) {
+                String eType = eventMap.get(ConfigXMLReader.EVENT_TYPE);
+                String ePath = eventMap.get(ConfigXMLReader.EVENT_PATH);
+                String eMeth = eventMap.get(ConfigXMLReader.EVENT_METHOD);
                 try {
                     String returnString = this.runEvent(request, response, eType, ePath, eMeth);
                     if (returnString != null && !returnString.equalsIgnoreCase("success")) {
@@ -887,14 +873,12 @@
     }
 
     public void runBeforeLogoutEvents(HttpServletRequest request, HttpServletResponse response) {
-        List beforeLogoutEvents = requestManager.getBeforeLogoutEventList();
+        List<Map<String, String>> beforeLogoutEvents = requestManager.getBeforeLogoutEventList();
         if (beforeLogoutEvents != null) {
-            Iterator i = beforeLogoutEvents.iterator();
-            while (i.hasNext()) {
-                Map eventMap = (Map) i.next();
-                String eType = (String) eventMap.get(ConfigXMLReader.EVENT_TYPE);
-                String ePath = (String) eventMap.get(ConfigXMLReader.EVENT_PATH);
-                String eMeth = (String) eventMap.get(ConfigXMLReader.EVENT_METHOD);
+            for (Map<String, String> eventMap: beforeLogoutEvents) {
+                String eType = eventMap.get(ConfigXMLReader.EVENT_TYPE);
+                String ePath = eventMap.get(ConfigXMLReader.EVENT_PATH);
+                String eMeth = eventMap.get(ConfigXMLReader.EVENT_METHOD);
                 try {
                     String returnString = this.runEvent(request, response, eType, ePath, eMeth);
                     if (returnString != null && !returnString.equalsIgnoreCase("success")) {

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestManager.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestManager.java?rev=682067&r1=682066&r2=682067&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestManager.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/control/RequestManager.java Sat Aug  2 14:56:42 2008
@@ -24,10 +24,12 @@
 import java.util.Collection;
 import java.util.Map;
 import java.util.List;
-import java.util.LinkedList;
 import javax.servlet.ServletContext;
 
+import javolution.util.FastList;
+
 import org.ofbiz.base.util.Debug;
+import static org.ofbiz.base.util.UtilGenerics.checkMap;
 import org.ofbiz.base.util.UtilValidate;
 
 /**
@@ -60,48 +62,50 @@
     }
 
     /** Gets the entire handler mapping */
-    public Map getHandlerMap() {
+    public Map<String, Map<String, String>> getHandlerMap() {
         return ConfigXMLReader.getHandlerMap(configFileUrl);
     }
 
     /** Gets the class name of the named handler */
     public String getHandlerClass(String name, int type) {
-        Map map = getHandlerMap();
-        Map hMap;
+        Map<String, Map<String, String>> map = getHandlerMap();
+        Map<String, String> hMap;
 
         if (type == RequestManager.VIEW_HANDLER_KEY) {
-            hMap = (Map) map.get("view");
+            hMap = checkMap(map.get("view"), String.class, String.class);
         } else {
-            hMap = (Map) map.get("event");
+            hMap = checkMap(map.get("event"), String.class, String.class);
         }
 
         if (!hMap.containsKey(name)) {
             return null;
         } else {
-            return (String) hMap.get(name);
+            return hMap.get(name);
         }
     }
 
-    public List getHandlerKeys(int type) {
-        Map map = getHandlerMap();
-        Map hMap;
+    public List<String> getHandlerKeys(int type) {
+        Map<String, Map<String, String>> map = getHandlerMap();
+        Map<String, String> hMap;
 
         if (type == RequestManager.VIEW_HANDLER_KEY) {
-            hMap = (Map) map.get("view");
+            hMap = checkMap(map.get("view"), String.class, String.class);
         } else {
-            hMap = (Map) map.get("event");
+            hMap = checkMap(map.get("event"), String.class, String.class);
         }
 
         if (hMap != null) {
-            return new LinkedList(hMap.keySet());
+            List<String> result = FastList.newInstance();
+            result.addAll(hMap.keySet());
+            return result;
         } else {
             return null;
         }
     }
 
-    public Map getRequestMapMap(String uriStr) {
+    public Map<String, Object> getRequestMapMap(String uriStr) {
         if (UtilValidate.isNotEmpty(uriStr)) {
-            return (Map) ConfigXMLReader.getRequestMap(configFileUrl).get(uriStr);
+            return ConfigXMLReader.getRequestMap(configFileUrl).get(uriStr);
         } else {
             return null;
         }
@@ -114,7 +118,7 @@
             String value = (String) uri.get(attribute);
             if (value == null) {
                 // not found, try the response Map (though better to hit that directly when desired)
-                Map<String, String> responseMap = (Map<String, String>) uri.get(ConfigXMLReader.RESPONSE_MAP);
+                Map<String, String> responseMap = checkMap(uri.get(ConfigXMLReader.RESPONSE_MAP), String.class, String.class);
                 value = responseMap.get(attribute);
             }
             return value;
@@ -130,7 +134,7 @@
         
         Map<String, Object> uri = getRequestMapMap(uriStr);
         if (uri == null) return null;
-        Map<String, String> responseMap = (Map<String, String>) uri.get(ConfigXMLReader.RESPONSE_MAP);
+        Map<String, String> responseMap = checkMap(uri.get(ConfigXMLReader.RESPONSE_MAP), String.class, String.class);
         if (responseMap == null) return null;
         
         return responseMap.get(responseName);
@@ -138,7 +142,7 @@
 
     /** Gets the event class from the requestMap */
     public String getEventPath(String uriStr) {
-        Map uri = getRequestMapMap(uriStr);
+        Map<String, Object> uri = getRequestMapMap(uriStr);
 
         if (uri != null)
             return (String) uri.get(ConfigXMLReader.EVENT_PATH);
@@ -164,7 +168,7 @@
 
     /** Gets the event method from the requestMap */
     public String getEventMethod(String uriStr) {
-        Map uri = getRequestMapMap(uriStr);
+        Map<String, Object> uri = getRequestMapMap(uriStr);
 
         if (uri != null) {
             return (String) uri.get(ConfigXMLReader.EVENT_METHOD);
@@ -177,7 +181,7 @@
 
     /** Gets the event global-transaction from the requestMap */
     public boolean getEventGlobalTransaction(String uriStr) {
-        Map uri = getRequestMapMap(uriStr);
+        Map<String, Object> uri = getRequestMapMap(uriStr);
 
         if (uri != null) {
             return Boolean.valueOf((String) uri.get(ConfigXMLReader.EVENT_GLOBAL_TRANSACTION)).booleanValue();
@@ -195,7 +199,7 @@
         Map<String, Object> uri = getRequestMapMap(uriStr);
 
         if (uri != null)
-            return (String) ((Map<String, String>) uri.get(ConfigXMLReader.RESPONSE_MAP)).get(ConfigXMLReader.NEXT_PAGE_DEFAULT);
+            return checkMap(uri.get(ConfigXMLReader.RESPONSE_MAP), String.class, String.class).get(ConfigXMLReader.NEXT_PAGE_DEFAULT);
         else {
             Debug.logWarning("[RequestManager.getViewName] View name for uri \"" + uriStr + "\" not found", module);
             return null;
@@ -205,10 +209,10 @@
     /** Gets the next page (jsp) from the viewMap */
     public String getViewPage(String viewStr) {
         if (viewStr != null && viewStr.startsWith("view:")) viewStr = viewStr.substring(viewStr.indexOf(':') + 1);
-        Map page = (Map) ConfigXMLReader.getViewMap(configFileUrl).get(viewStr);
+        Map<String, String> page = ConfigXMLReader.getViewMap(configFileUrl).get(viewStr);
 
         if (page != null) {
-            return (String) page.get(ConfigXMLReader.VIEW_PAGE);
+            return page.get(ConfigXMLReader.VIEW_PAGE);
         } else {
             Debug.logWarning("[RequestManager.getViewPage] View with name \"" + viewStr + "\" not found", module);
             return null;
@@ -217,10 +221,10 @@
 
     /** Gets the type of this view */
     public String getViewType(String viewStr) {
-        Map view = (Map) ConfigXMLReader.getViewMap(configFileUrl).get(viewStr);
+        Map<String, String> view = ConfigXMLReader.getViewMap(configFileUrl).get(viewStr);
 
         if (view != null) {
-            return (String) view.get(ConfigXMLReader.VIEW_TYPE);
+            return view.get(ConfigXMLReader.VIEW_TYPE);
         } else {
             Debug.logWarning("[RequestManager.getViewType] View with name \"" + viewStr + "\" not found", module);
             return null;
@@ -229,10 +233,10 @@
 
     /** Gets the info of this view */
     public String getViewInfo(String viewStr) {
-        Map view = (Map) ConfigXMLReader.getViewMap(configFileUrl).get(viewStr);
+        Map<String, String> view = ConfigXMLReader.getViewMap(configFileUrl).get(viewStr);
 
         if (view != null) {
-            return (String) view.get(ConfigXMLReader.VIEW_INFO);
+            return view.get(ConfigXMLReader.VIEW_INFO);
         } else {
             Debug.logWarning("[RequestManager.getViewInfo] View with name \"" + viewStr + "\" not found", module);
             return null;
@@ -241,10 +245,10 @@
     
     /** Gets the content-type of this view */
     public String getViewContentType(String viewStr) {
-        Map view = (Map) ConfigXMLReader.getViewMap(configFileUrl).get(viewStr);
+        Map<String, String> view = ConfigXMLReader.getViewMap(configFileUrl).get(viewStr);
 
         if (view != null) {
-            return (String) view.get(ConfigXMLReader.VIEW_CONTENT_TYPE);
+            return view.get(ConfigXMLReader.VIEW_CONTENT_TYPE);
         } else {
             Debug.logWarning("[RequestManager.getViewInfo] View with name \"" + viewStr + "\" not found", module);
             return null;
@@ -266,11 +270,11 @@
     /** Gets the error page from the requestMap, if none uses the default */
     public String getErrorPage(String uriStr) {
         //Debug.logInfo("uriStr is: " + uriStr, module);
-        Map uri = getRequestMapMap(uriStr);
+        Map<String, Object> uri = getRequestMapMap(uriStr);
         //Debug.logInfo("RequestMapMap is: " + uri, module);
 
         if (uri != null) {
-            String errorViewUri = (String) ((Map<String, String>) uri.get(ConfigXMLReader.RESPONSE_MAP)).get(ConfigXMLReader.ERROR_PAGE_DEFAULT);
+            String errorViewUri = checkMap(uri.get(ConfigXMLReader.RESPONSE_MAP), String.class, String.class).get(ConfigXMLReader.ERROR_PAGE_DEFAULT);
             //Debug.logInfo("errorViewUri is: " + errorViewUri, module);
             String returnPage = getViewPage(errorViewUri);
             //Debug.logInfo("Got returnPage for ErrorPage: " + returnPage, module);
@@ -295,7 +299,7 @@
     }
 
     public boolean requiresAuth(String uriStr) {
-        Map uri = getRequestMapMap(uriStr);
+        Map<String, Object> uri = getRequestMapMap(uriStr);
 
         if (uri != null) {
             String value = (String) uri.get(ConfigXMLReader.SECURITY_AUTH);
@@ -307,7 +311,7 @@
     }
 
     public boolean requiresHttps(String uriStr) {
-        Map uri = getRequestMapMap(uriStr);
+        Map<String, Object> uri = getRequestMapMap(uriStr);
 
         if (uri != null) {
             String value = (String) uri.get(ConfigXMLReader.SECURITY_HTTPS);
@@ -332,7 +336,7 @@
     }
       
     public boolean allowExtView(String uriStr) {
-        Map uri = getRequestMapMap(uriStr);
+        Map<String, Object> uri = getRequestMapMap(uriStr);
 
         if (uri != null) {
             String value = (String) uri.get(ConfigXMLReader.SECURITY_EXTVIEW);
@@ -344,7 +348,7 @@
     }
 
     public boolean allowDirectRequest(String uriStr) {
-        Map uri = getRequestMapMap(uriStr);
+        Map<String, Object> uri = getRequestMapMap(uriStr);
 
         if (uri != null) {
             String value = (String) uri.get(ConfigXMLReader.SECURITY_DIRECT);
@@ -359,23 +363,28 @@
         return ConfigXMLReader.getDefaultRequest(configFileUrl);
     }
 
-    public Collection getFirstVisitEvents() {
-        return (Collection) ConfigXMLReader.getConfigMap(configFileUrl).get(ConfigXMLReader.FIRSTVISIT);
+    @SuppressWarnings("unchecked")
+    public Collection<Map<String, String>> getFirstVisitEvents() {
+        return (Collection<Map<String, String>>) ConfigXMLReader.getConfigMap(configFileUrl).get(ConfigXMLReader.FIRSTVISIT);
     }
 
-    public Collection getPreProcessor() {
-        return (Collection) ConfigXMLReader.getConfigMap(configFileUrl).get(ConfigXMLReader.PREPROCESSOR);
+    @SuppressWarnings("unchecked")
+    public Collection<Map<String, String>> getPreProcessor() {
+        return (Collection<Map<String, String>>) ConfigXMLReader.getConfigMap(configFileUrl).get(ConfigXMLReader.PREPROCESSOR);
     }
 
-    public Collection getPostProcessor() {
-        return (Collection) ConfigXMLReader.getConfigMap(configFileUrl).get(ConfigXMLReader.POSTPROCESSOR);
+    @SuppressWarnings("unchecked")
+    public Collection<Map<String, String>> getPostProcessor() {
+        return (Collection<Map<String, String>>) ConfigXMLReader.getConfigMap(configFileUrl).get(ConfigXMLReader.POSTPROCESSOR);
     }
 
-    public List getAfterLoginEventList() {
-        return (List) ConfigXMLReader.getConfigMap(configFileUrl).get("after-login");
+    @SuppressWarnings("unchecked")
+    public List<Map<String, String>> getAfterLoginEventList() {
+        return (List<Map<String, String>>) ConfigXMLReader.getConfigMap(configFileUrl).get("after-login");
     }
 
-    public List getBeforeLogoutEventList() {
-        return (List) ConfigXMLReader.getConfigMap(configFileUrl).get("before-logout");        
+    @SuppressWarnings("unchecked")
+    public List<Map<String, String>> getBeforeLogoutEventList() {
+        return (List<Map<String, String>>) ConfigXMLReader.getConfigMap(configFileUrl).get("before-logout");        
     }
 }

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/AbstractJSONEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/AbstractJSONEventHandler.java?rev=682067&r1=682066&r2=682067&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/AbstractJSONEventHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/AbstractJSONEventHandler.java Sat Aug  2 14:56:42 2008
@@ -48,7 +48,7 @@
                 // call into the java handler for parameters parsing and invocation
         String respCode = service.invoke(eventPath, eventMethod, request, response);
         // pull out the service response from the request attribute
-        Map attrMap = getAttributesAsMap(request);
+        Map<String, Object> attrMap = getAttributesAsMap(request);
             
         // create a JSON Object for return
         JSONObject json = JSONObject.fromMap(attrMap);
@@ -78,8 +78,8 @@
         return respCode;
     }
 
-    private Map getAttributesAsMap(HttpServletRequest request) {
-        Map attrMap = FastMap.newInstance();
+    private Map<String, Object> getAttributesAsMap(HttpServletRequest request) {
+        Map<String, Object> attrMap = FastMap.newInstance();
         Enumeration en = request.getAttributeNames();
         while (en.hasMoreElements()) {
             String name = (String) en.nextElement();
@@ -96,4 +96,4 @@
         return attrMap;
     }
 
-}
\ No newline at end of file
+}

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java?rev=682067&r1=682066&r2=682067&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/BsfEventHandler.java Sat Aug  2 14:56:42 2008
@@ -38,7 +38,7 @@
 public class BsfEventHandler implements EventHandler {
     
     public static final String module = BsfEventHandler.class.getName();    
-    public static UtilCache eventCache = new UtilCache("webapp.BsfEvents");
+    public static UtilCache<String, String> eventCache = new UtilCache<String, String>("webapp.BsfEvents");
 
     /**
      * @see org.ofbiz.webapp.event.EventHandler#init(javax.servlet.ServletContext)
@@ -78,7 +78,7 @@
             if (eventPath == null || eventPath.length() == 0) {
                 // we are a resource to be loaded off the classpath
                 cacheName = eventMethod;
-                scriptString = (String) eventCache.get(cacheName);
+                scriptString = eventCache.get(cacheName);
                 if (scriptString == null) {
                     synchronized(this) {
                         if (scriptString == null) {
@@ -95,7 +95,7 @@
             } else {
                 // we are a script in the webapp - load by resource
                 cacheName = context.getServletContextName() + ":" + eventPath + eventMethod;
-                scriptString = (String) eventCache.get(cacheName);
+                scriptString = eventCache.get(cacheName);
                 if (scriptString == null) {
                     synchronized(this) {
                         if (scriptString == null) {                                  

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java?rev=682067&r1=682066&r2=682067&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/CoreEvents.java Sat Aug  2 14:56:42 2008
@@ -25,7 +25,6 @@
 import java.sql.Timestamp;
 import java.util.Collection;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
@@ -39,6 +38,8 @@
 import javolution.util.FastMap;
 
 import org.ofbiz.base.util.Debug;
+import static org.ofbiz.base.util.UtilGenerics.checkCollection;
+import static org.ofbiz.base.util.UtilGenerics.checkMap;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
@@ -204,7 +205,7 @@
         Locale locale = UtilHttp.getLocale(request);
         TimeZone timeZone = UtilHttp.getTimeZone(request);
         
-        Map params = UtilHttp.getParameterMap(request);
+        Map<String, Object> params = UtilHttp.getParameterMap(request);
         // get the schedule parameters
         String jobName = (String) params.remove("JOB_NAME");
         String serviceName = (String) params.remove("SERVICE_NAME");
@@ -217,7 +218,7 @@
         String retryCnt = (String) params.remove("SERVICE_MAXRETRY");
 
         // the frequency map
-        Map freqMap = new HashMap();
+        Map<String, Integer> freqMap = FastMap.newInstance();
 
         freqMap.put("SECONDLY", Integer.valueOf(1));
         freqMap.put("MINUTELY", Integer.valueOf(2));
@@ -261,10 +262,10 @@
         }
         
         // make the context valid; using the makeValid method from ModelService
-        Map serviceContext = new HashMap();
-        Iterator ci = modelService.getInParamNames().iterator();
+        Map<String, Object> serviceContext = FastMap.newInstance();
+        Iterator<String> ci = modelService.getInParamNames().iterator();
         while (ci.hasNext()) {
-            String name = (String) ci.next();
+            String name = ci.next();
 
             // don't include userLogin, that's taken care of below
             if ("userLogin".equals(name)) continue;
@@ -375,7 +376,7 @@
                     String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.invalid_format_frequency", locale);
                     errorBuf.append("<li>" + errMsg);
                 } else {
-                    frequency = ((Integer) freqMap.get(serviceFreq.toUpperCase())).intValue();
+                    frequency = freqMap.get(serviceFreq.toUpperCase()).intValue();
                 }
             }
         }
@@ -402,7 +403,7 @@
             return "error";
         }
                 
-        Map syncServiceResult = null;
+        Map<String, Object> syncServiceResult = null;
         // schedule service
         try {
             if(null!=request.getParameter("_RUN_SYNC_") && request.getParameter("_RUN_SYNC_").equals("Y")){
@@ -428,7 +429,7 @@
     public static String saveServiceResultsToSession(HttpServletRequest request, HttpServletResponse response) {
         HttpSession session = request.getSession();
         Locale locale = UtilHttp.getLocale(request);
-        Map syncServiceResult = (Map)session.getAttribute("_RUN_SYNC_RESULT_");
+        Map<String, Object> syncServiceResult = checkMap(session.getAttribute("_RUN_SYNC_RESULT_"), String.class, Object.class);
         if(null==syncServiceResult){
             String errMsg = UtilProperties.getMessage(CoreEvents.err_resource, "coreEvents.no_fields_in_session", locale);
             request.setAttribute("_ERROR_MESSAGE_", "<li>" + errMsg);
@@ -438,13 +439,10 @@
         if(null!=request.getParameter("_CLEAR_PREVIOUS_PARAMS_") && request.getParameter("_CLEAR_PREVIOUS_PARAMS_").equalsIgnoreCase("on"))
             session.removeAttribute("_SAVED_SYNC_RESULT_");
         
-        Map serviceFieldsToSave = request.getParameterMap();
-        Map savedFields = FastMap.newInstance();
-        Set keys = serviceFieldsToSave.keySet();
-        Iterator keysItr = keys.iterator();
+        Map<String, String[]> serviceFieldsToSave = checkMap(request.getParameterMap(), String.class, String[].class);
+        Map<String, Object> savedFields = FastMap.newInstance();
         
-        while(keysItr.hasNext()){
-            String key = (String)keysItr.next();
+        for (String key: serviceFieldsToSave.keySet()) {
             if(null!=serviceFieldsToSave.get(key) && request.getParameter(key).equalsIgnoreCase("on") && !key.equals("_CLEAR_PREVIOUS_PARAMS_")){
                 String[] servicePath = key.split("\\|\\|");
                 String partialKey = servicePath[servicePath.length-1];
@@ -452,7 +450,7 @@
             }
         }
         if(null!=session.getAttribute("_SAVED_SYNC_RESULT_")){
-            Map savedSyncResult = (Map)session.getAttribute("_SAVED_SYNC_RESULT_");
+            Map<String, Object> savedSyncResult = checkMap(session.getAttribute("_SAVED_SYNC_RESULT_"), String.class, Object.class);
             savedSyncResult.putAll(savedFields);
             savedFields = savedSyncResult;
         }
@@ -460,11 +458,11 @@
         return "success";
     }
     
-    //Tries to return a map, if Object is one of HashMap, GenericEntity, List
-    public static Object getObjectFromServicePath(String servicePath, Map serviceResult){
+    //Tries to return a map, if Object is one of Map, GenericEntity, List
+    public static Object getObjectFromServicePath(String servicePath, Map<String, ? extends Object> serviceResult){
         String[] sp = servicePath.split("\\|\\|");
         Object servicePathObject = null;
-        Map servicePathMap = null;
+        Map<String, Object> servicePathMap = null;
         for(int i=0;i<sp.length;i++){
             String servicePathEntry = sp[i];
             if(null==servicePathMap){
@@ -474,24 +472,20 @@
             }
             servicePathMap = null;
             
-            if(servicePathObject instanceof HashMap){
-                servicePathMap = (HashMap)servicePathObject;
+            if(servicePathObject instanceof Map){
+                servicePathMap = checkMap(servicePathObject);
             }else if(servicePathObject instanceof GenericEntity){
                 GenericEntity servicePathEntity = (GenericEntity)servicePathObject;
-                Set servicePathEntitySet = servicePathEntity.keySet();
-                Iterator spesItr = servicePathEntitySet.iterator();
                 servicePathMap = FastMap.newInstance();
-                while(spesItr.hasNext()){
-                    String spesKey = (String)spesItr.next();
-                    servicePathMap.put(spesKey, servicePathEntity.get(spesKey));
+                for (Map.Entry<String, Object> entry: servicePathEntity.entrySet()) {
+                    servicePathMap.put(entry.getKey(), entry.getValue());
                 }
             }else if(servicePathObject instanceof Collection){
-                Collection servicePathColl = (Collection)servicePathObject;
-                Iterator splItr = servicePathColl.iterator();
+                Collection<?> servicePathColl = checkCollection(servicePathObject);
                 int count=0;
                 servicePathMap = FastMap.newInstance();
-                while(splItr.hasNext()){
-                    servicePathMap.put("_"+count+"_", splItr.next());
+                for (Object value: servicePathColl) {
+                    servicePathMap.put("_"+count+"_", value);
                     count++;
                 }
             }

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/DojoJSONServiceEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/DojoJSONServiceEventHandler.java?rev=682067&r1=682066&r2=682067&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/DojoJSONServiceEventHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/DojoJSONServiceEventHandler.java Sat Aug  2 14:56:42 2008
@@ -22,8 +22,6 @@
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
 import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.LinkedList;
 import java.util.Locale;
 import java.util.Map;
 import java.util.List;
@@ -34,6 +32,7 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
+import javolution.util.FastList;
 import javolution.util.FastMap;
 import net.sf.json.JSONObject;
 
@@ -70,7 +69,7 @@
         String respCode = service.invoke(eventPath, eventMethod, request, response);
 
         // pull out the service response from the request attribute
-        Map attrMap = getAttributesAsMap(request);
+        Map<String, Object> attrMap = getAttributesAsMap(request);
 
         LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
         if (dispatcher == null) {
@@ -105,8 +104,8 @@
         if (model == null) {
             throw new EventHandlerException("Problems getting the service model");
         }
-        List errorMessages = new LinkedList();
-        Map serviceContext = new HashMap();
+        List<Object> errorMessages = FastList.newInstance();
+        Map<String, Object> serviceContext = FastMap.newInstance();
         serviceContext = model.makeValid(attrMap, ModelService.OUT_PARAM, true, errorMessages, timeZone, locale);
 
         // create a JSON Object for return
@@ -139,8 +138,8 @@
         return respCode;
     }
 
-    private Map getAttributesAsMap(HttpServletRequest request) {
-        Map attrMap = FastMap.newInstance();
+    private Map<String, Object> getAttributesAsMap(HttpServletRequest request) {
+        Map<String, Object> attrMap = FastMap.newInstance();
         Enumeration en = request.getAttributeNames();
         while (en.hasMoreElements()) {
             String name = (String) en.nextElement();

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/EventFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/EventFactory.java?rev=682067&r1=682066&r2=682067&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/EventFactory.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/EventFactory.java Sat Aug  2 14:56:42 2008
@@ -18,14 +18,14 @@
  *******************************************************************************/
 package org.ofbiz.webapp.event;
 
-import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import javolution.util.FastMap;
+
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.GeneralRuntimeException;
 import org.ofbiz.base.util.ObjectType;
@@ -42,10 +42,10 @@
     protected RequestHandler requestHandler = null;
     protected RequestManager requestManager = null;
     protected ServletContext context = null;
-    protected Map handlers = null;
+    protected Map<String, EventHandler> handlers = null;
 
     public EventFactory(RequestHandler requestHandler) {
-        handlers = new HashMap();
+        handlers = FastMap.newInstance();
         this.requestHandler = requestHandler;
         this.requestManager = requestHandler.getRequestManager();
         this.context = requestHandler.getServletContext();
@@ -60,11 +60,9 @@
     }
 
     private void preLoadAll() throws EventHandlerException {
-        List handlers = requestManager.getHandlerKeys(RequestManager.EVENT_HANDLER_KEY);
+        List<String> handlers = requestManager.getHandlerKeys(RequestManager.EVENT_HANDLER_KEY);
         if (handlers != null) {
-            Iterator i = handlers.iterator();
-            while (i.hasNext()) {
-                String type = (String) i.next();
+            for (String type: handlers) {
                 this.handlers.put(type, this.loadEventHandler(type));
             }
         }
@@ -77,11 +75,11 @@
         }
 
         // attempt to get a pre-loaded handler
-        EventHandler handler = (EventHandler) handlers.get(type);
+        EventHandler handler = handlers.get(type);
 
         if (handler == null) {
             synchronized (EventHandler.class) {
-                handler = (EventHandler) handlers.get(type);
+                handler = handlers.get(type);
                 if (handler == null) {
                     handler = this.loadEventHandler(type);
                     handlers.put(type, handler);

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/JSONJavaEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/JSONJavaEventHandler.java?rev=682067&r1=682066&r2=682067&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/JSONJavaEventHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/JSONJavaEventHandler.java Sat Aug  2 14:56:42 2008
@@ -51,7 +51,7 @@
         String respCode = service.invoke(eventPath, eventMethod, request, response);
 
         // pull out the service response from the request attribute
-        Map attrMap = getAttributesAsMap(request);
+        Map<String, Object> attrMap = getAttributesAsMap(request);
 
         // create a JSON Object for return
         JSONObject json = JSONObject.fromMap(attrMap);
@@ -82,8 +82,8 @@
         return respCode;
     }
 
-    private Map getAttributesAsMap(HttpServletRequest request) {
-        Map attrMap = FastMap.newInstance();
+    private Map<String, Object> getAttributesAsMap(HttpServletRequest request) {
+        Map<String, Object> attrMap = FastMap.newInstance();
         Enumeration en = request.getAttributeNames();
         while (en.hasMoreElements()) {
             String name = (String) en.nextElement();

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/JSONServiceEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/JSONServiceEventHandler.java?rev=682067&r1=682066&r2=682067&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/JSONServiceEventHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/JSONServiceEventHandler.java Sat Aug  2 14:56:42 2008
@@ -51,7 +51,7 @@
         String respCode = service.invoke(eventPath, eventMethod, request, response);
 
         // pull out the service response from the request attribute
-        Map attrMap = getAttributesAsMap(request);
+        Map<String, Object> attrMap = getAttributesAsMap(request);
 
         // create a JSON Object for return
         JSONObject json = JSONObject.fromMap(attrMap);
@@ -82,8 +82,8 @@
         return respCode;
     }
 
-    private Map getAttributesAsMap(HttpServletRequest request) {
-        Map attrMap = FastMap.newInstance();
+    private Map<String, Object> getAttributesAsMap(HttpServletRequest request) {
+        Map<String, Object> attrMap = FastMap.newInstance();
         Enumeration en = request.getAttributeNames();
         while (en.hasMoreElements()) {
             String name = (String) en.nextElement();

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/JavaEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/JavaEventHandler.java?rev=682067&r1=682066&r2=682067&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/JavaEventHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/JavaEventHandler.java Sat Aug  2 14:56:42 2008
@@ -19,12 +19,13 @@
 package org.ofbiz.webapp.event;
 
 import java.lang.reflect.Method;
-import java.util.HashMap;
 import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.ServletContext;
 
+import javolution.util.FastMap;
+
 import org.ofbiz.base.util.Debug;
 
 /**
@@ -34,7 +35,7 @@
 
     public static final String module = JavaEventHandler.class.getName();
 
-    private Map eventClassMap = new HashMap();
+    private Map<String, Class<?>> eventClassMap = FastMap.newInstance();
 
     /**
      * @see org.ofbiz.webapp.event.EventHandler#init(javax.servlet.ServletContext)
@@ -46,11 +47,11 @@
      * @see org.ofbiz.webapp.event.EventHandler#invoke(java.lang.String, java.lang.String, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
      */
     public String invoke(String eventPath, String eventMethod, HttpServletRequest request, HttpServletResponse response) throws EventHandlerException {
-        Class eventClass = (Class) this.eventClassMap.get(eventPath);
+        Class<?> eventClass = this.eventClassMap.get(eventPath);
 
         if (eventClass == null) {
             synchronized (this) {
-                eventClass = (Class) this.eventClassMap.get(eventPath);
+                eventClass = this.eventClassMap.get(eventPath);
                 if (eventClass == null) {
                     try {
                         ClassLoader loader = Thread.currentThread().getContextClassLoader();
@@ -66,7 +67,7 @@
         }
         if (Debug.verboseOn()) Debug.logVerbose("[Set path/method]: " + eventPath + " / " + eventMethod, module);
 
-        Class[] paramTypes = new Class[] {HttpServletRequest.class, HttpServletResponse.class};
+        Class<?>[] paramTypes = new Class<?>[] {HttpServletRequest.class, HttpServletResponse.class};
 
         Debug.logVerbose("*[[Event invocation]]*", module);
         Object[] params = new Object[] {request, response};
@@ -74,7 +75,7 @@
         return invoke(eventPath, eventMethod, eventClass, paramTypes, params);
     }
 
-    private String invoke(String eventPath, String eventMethod, Class eventClass, Class[] paramTypes, Object[] params) throws EventHandlerException {
+    private String invoke(String eventPath, String eventMethod, Class<?> eventClass, Class[] paramTypes, Object[] params) throws EventHandlerException {
         if (eventClass == null) {
             throw new EventHandlerException("Error invoking event, the class " + eventPath + " was not found");
         }

Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java?rev=682067&r1=682066&r2=682067&view=diff
==============================================================================
--- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java (original)
+++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/SOAPEventHandler.java Sat Aug  2 14:56:42 2008
@@ -21,7 +21,6 @@
 import java.io.IOException;
 import java.io.Writer;
 import java.io.OutputStream;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -32,6 +31,8 @@
 import javax.xml.soap.SOAPException;
 import javax.wsdl.WSDLException;
 
+import javolution.util.FastMap;
+
 import org.ofbiz.base.util.Debug;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilXml;
@@ -121,9 +122,7 @@
                     sb.append("<html><head><title>OFBiz SOAP/1.1 Services</title></head>");
                     sb.append("<body>No such service.").append("<p>Services:<ul>");
 
-                    Iterator i = dctx.getAllServiceNames().iterator();
-                    while (i.hasNext()) {
-                        String scvName = (String) i.next();
+                    for (String scvName: dctx.getAllServiceNames()) {
                         ModelService model = dctx.getModelService(scvName);
                         if (model.export) {
                             sb.append("<li><a href=\"").append(locationUri).append("/").append(model.name).append("?wsdl\">");
@@ -204,10 +203,7 @@
         Debug.logVerbose("[Processing]: SOAP Event", module);
 
         // each is a different service call
-        Iterator i = bodies.iterator();
-
-        while (i.hasNext()) {
-            Object o = i.next();
+        for (Object o: bodies) {
 
             if (o instanceof RPCElement) {
                 RPCElement body = (RPCElement) o;
@@ -220,7 +216,7 @@
                     sendError(response, e);
                     throw new EventHandlerException(e.getMessage(), e);
                 }
-                Map serviceContext = new HashMap();
+                Map<String, Object> serviceContext = FastMap.newInstance();
                 Iterator p = params.iterator();
 
                 while (p.hasNext()) {
@@ -234,19 +230,16 @@
                     ModelService model = dispatcher.getDispatchContext().getModelService(serviceName);
 
                     if (model != null && model.export) {
-                        Map result = dispatcher.runSync(serviceName, serviceContext);
+                        Map<String, Object> result = dispatcher.runSync(serviceName, serviceContext);
 
                         Debug.logVerbose("[EventHandler] : Service invoked", module);
                         RPCElement resBody = new RPCElement(serviceName + "Response");
 
                         resBody.setPrefix(body.getPrefix());
                         resBody.setNamespaceURI(body.getNamespaceURI());
-                        Set keySet = result.keySet();
-                        Iterator ri = keySet.iterator();
 
-                        while (ri.hasNext()) {
-                            Object key = ri.next();
-                            RPCParam par = new RPCParam(((String) key), result.get(key));
+                        for (Map.Entry<String, Object> entry: result.entrySet()) {
+                            RPCParam par = new RPCParam(entry.getKey(), entry.getValue());
 
                             resBody.addParam(par);
                         }