Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceEventHandler.java Sat Aug 2 14:56:42 2008 @@ -20,9 +20,7 @@ import java.io.File; import java.nio.ByteBuffer; -import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; 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 org.apache.commons.fileupload.FileItem; @@ -42,6 +41,7 @@ import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.ofbiz.base.util.Debug; +import static org.ofbiz.base.util.UtilGenerics.checkList; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; @@ -147,7 +147,7 @@ String encoding = request.getCharacterEncoding(); // check for multipart content types which may have uploaded items boolean isMultiPart = ServletFileUpload.isMultipartContent(request); - Map multiPartMap = FastMap.newInstance(); + Map<String, Object> multiPartMap = FastMap.newInstance(); if (isMultiPart) { ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory(sizeThreshold, new File(tmpUploadRepository))); @@ -181,9 +181,9 @@ if (multiPartMap.containsKey(fieldName)) { Object mapValue = multiPartMap.get(fieldName); if (mapValue instanceof List) { - ((List) mapValue).add(item.getString()); + checkList(mapValue, Object.class).add(item.getString()); } else if (mapValue instanceof String) { - List newList = new ArrayList(); + List<String> newList = FastList.newInstance(); newList.add((String) mapValue); newList.add(item.getString()); multiPartMap.put(fieldName, newList); @@ -227,10 +227,8 @@ request.setAttribute("multiPartMap", multiPartMap); // we have a service and the model; build the context - Map serviceContext = new HashMap(); - Iterator modelParmInIter = model.getInModelParamList().iterator(); - while (modelParmInIter.hasNext()) { - ModelParam modelParam = (ModelParam) modelParmInIter.next(); + Map<String, Object> serviceContext = FastMap.newInstance(); + for (ModelParam modelParam: model.getInModelParamList()) { String name = modelParam.name; // don't include userLogin, that's taken care of below @@ -302,7 +300,7 @@ // get only the parameters for this service - converted to proper type // TODO: pass in a list for error messages, like could not convert type or not a proper X, return immediately with messages if there are any - List errorMessages = new LinkedList(); + List<Object> errorMessages = FastList.newInstance(); serviceContext = model.makeValid(serviceContext, ModelService.IN_PARAM, true, errorMessages, timeZone, locale); if (errorMessages.size() > 0) { // uh-oh, had some problems... @@ -326,7 +324,7 @@ } // invoke the service - Map result = null; + Map<String, Object> result = null; try { if (ASYNC.equalsIgnoreCase(mode)) { dispatcher.runAsync(serviceName, serviceContext); @@ -372,10 +370,8 @@ request.setAttribute("_EVENT_MESSAGE_", result.get(ModelService.SUCCESS_MESSAGE)); // set the results in the request - Iterator rmei = result.entrySet().iterator(); - while (rmei.hasNext()) { - Map.Entry rme = (Map.Entry) rmei.next(); - String resultKey = (String) rme.getKey(); + for (Map.Entry<String, Object> rme: result.entrySet()) { + String resultKey = rme.getKey(); Object resultValue = rme.getValue(); if (resultKey != null && !ModelService.RESPONSE_MESSAGE.equals(resultKey) && !ModelService.ERROR_MESSAGE.equals(resultKey) && Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceMultiEventHandler.java Sat Aug 2 14:56:42 2008 @@ -152,8 +152,8 @@ String messageSuffixStr = UtilProperties.getMessage("DefaultMessages", "service.message.suffix", locale); // prepare the error message and success message lists - List errorMessages = FastList.newInstance(); - List successMessages = FastList.newInstance(); + List<Object> errorMessages = FastList.newInstance(); + List<String> successMessages = FastList.newInstance(); // Check the global-transaction attribute of the event from the controller to see if the // event should be wrapped in a transaction @@ -186,11 +186,8 @@ } // build the context - Map serviceContext = FastMap.newInstance(); - List modelParmInList = modelService.getInModelParamList(); - Iterator modelParmInIter = modelParmInList.iterator(); - while (modelParmInIter.hasNext()) { - ModelParam modelParam = (ModelParam) modelParmInIter.next(); + Map<String, Object> serviceContext = FastMap.newInstance(); + for (ModelParam modelParam: modelService.getInModelParamList()) { String paramName = modelParam.name; // Debug.logInfo("In ServiceMultiEventHandler processing input parameter [" + modelParam.name + (modelParam.optional?"(optional):":"(required):") + modelParam.mode + "] for service [" + serviceName + "]", module); @@ -287,7 +284,7 @@ // Debug.logInfo("ready to call " + serviceName + " with context " + serviceContext, module); // invoke the service - Map result = null; + Map<String, Object> result = null; try { result = dispatcher.runSync(serviceName, serviceContext); } catch (ServiceAuthException e) { @@ -296,11 +293,10 @@ } catch (ServiceValidationException e) { // not logging since the service engine already did request.setAttribute("serviceValidationException", e); - List errors = e.getMessageList(); + List<String> errors = e.getMessageList(); if (errors != null) { - Iterator erri = errors.iterator(); - while (erri.hasNext()) { - errorMessages.add("Service invocation error on row (" + i + "): " + erri.next()); + for (String message: errors) { + errorMessages.add("Service invocation error on row (" + i + "): " + message); } } else { errorMessages.add(messagePrefixStr + "Service invocation error on row (" + i +"): " + e.getNonNestedMessage()); @@ -338,10 +334,8 @@ } // set the results in the request if ((result != null) && (result.entrySet() != null)) { - Iterator rmei = result.entrySet().iterator(); - while (rmei.hasNext()) { - Map.Entry rme = (Map.Entry) rmei.next(); - String resultKey = (String) rme.getKey(); + for (Map.Entry<String, Object> rme: result.entrySet()) { + String resultKey = rme.getKey(); Object resultValue = rme.getValue(); if (resultKey != null && !ModelService.RESPONSE_MESSAGE.equals(resultKey) && !ModelService.ERROR_MESSAGE.equals(resultKey) && @@ -365,9 +359,7 @@ errorMessages.add(0, errorPrefixStr); errorMessages.add(errorSuffixStr); StringBuilder errorBuf = new StringBuilder(); - Iterator ei = errorMessages.iterator(); - while (ei.hasNext()) { - String em = (String) ei.next(); + for (Object em: errorMessages) { errorBuf.append(em + "\n"); } request.setAttribute("_ERROR_MESSAGE_", errorBuf.toString()); Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceStreamHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceStreamHandler.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceStreamHandler.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/ServiceStreamHandler.java Sat Aug 2 14:56:42 2008 @@ -64,13 +64,13 @@ throw new EventHandlerException(e.getMessage(), e); } - Map context = FastMap.newInstance(); + Map<String, Object> context = FastMap.newInstance(); context.put("inputStream", in); context.put("outputStream", out); if (Debug.infoOn()) Debug.logInfo("Running service with context: " + context, module); - Map resp; + Map<String, Object> resp; try { resp = dispatcher.runSync(eventMethod, context); } catch (GenericServiceException e) { Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/WfsEventHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/WfsEventHandler.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/WfsEventHandler.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/WfsEventHandler.java Sat Aug 2 14:56:42 2008 @@ -26,7 +26,6 @@ import java.io.Writer; import java.io.OutputStream; import java.io.InputStream; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -45,6 +44,7 @@ import javax.xml.parsers.ParserConfigurationException; import javolution.util.FastList; +import javolution.util.FastMap; import org.ofbiz.base.location.FlexibleLocation; import org.ofbiz.base.util.Debug; @@ -201,7 +201,7 @@ public static String processWfsEntity(String entityName, Node domNode, String templatePath) throws TemplateException, FileNotFoundException, IOException, URISyntaxException { String result = null; NodeModel nodeModel = NodeModel.wrap(domNode); - Map ctx = new HashMap(); + Map<String, Object> ctx = FastMap.newInstance(); ctx.put("doc", nodeModel); ctx.put("entityName", entityName); StringWriter outWriter = new StringWriter(); Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/event/XmlRpcEventHandler.java Sat Aug 2 14:56:42 2008 @@ -30,6 +30,7 @@ import org.ofbiz.service.*; import org.ofbiz.entity.GenericDelegator; import org.ofbiz.base.util.Debug; +import static org.ofbiz.base.util.UtilGenerics.checkMap; import org.ofbiz.base.util.UtilValidate; import javax.servlet.ServletContext; @@ -140,11 +141,11 @@ String password = config.getBasicPassword(); // check the account - Map context = FastMap.newInstance(); + Map<String, Object> context = FastMap.newInstance(); context.put("login.username", username); context.put("login.password", password); - Map resp; + Map<String, Object> resp; try { resp = dispatcher.runSync("userLogin", context); } catch (GenericServiceException e) { @@ -195,7 +196,7 @@ } // prepare the context -- single parameter type struct (map) - Map context = this.getContext(xmlRpcReq, serviceName); + Map<String, Object> context = this.getContext(xmlRpcReq, serviceName); // add in auth parameters XmlRpcHttpRequestConfig config = (XmlRpcHttpRequestConfig) xmlRpcReq.getConfig(); @@ -210,7 +211,7 @@ context.put("locale", Locale.getDefault()); // invoke the service - Map resp; + Map<String, Object> resp; try { resp = dispatcher.runSync(serviceName, context); } catch (GenericServiceException e) { @@ -225,7 +226,7 @@ return model.makeValid(resp, ModelService.OUT_PARAM, false, null); } - protected Map getContext(XmlRpcRequest xmlRpcReq, String serviceName) throws XmlRpcException { + protected Map<String, Object> getContext(XmlRpcRequest xmlRpcReq, String serviceName) throws XmlRpcException { ModelService model; try { model = dispatcher.getDispatchContext().getModelService(serviceName); @@ -234,7 +235,7 @@ } // context placeholder - Map context = FastMap.newInstance(); + Map<String, Object> context = FastMap.newInstance(); if (model != null) { int parameterCount = xmlRpcReq.getParameterCount(); @@ -242,9 +243,7 @@ // more than one parameter; use list notation based on service def order if (parameterCount > 1) { int x = 0; - Iterator i = model.getParameterNames("IN", true, true).iterator(); - while (i.hasNext()) { - String name = (String) i.next(); + for (String name: model.getParameterNames("IN", true, true)) { context.put(name, xmlRpcReq.getParameter(x)); x++; @@ -257,7 +256,7 @@ } else if (parameterCount == 1) { Object param = xmlRpcReq.getParameter(0); if (param instanceof Map) { - context = (Map) param; + context = checkMap(param, String.class, Object.class); } else { if (model.getDefinedInCount() == 1) { String paramName = (String) model.getInParamNames().iterator().next(); Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewHandler.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewHandler.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/FreeMarkerViewHandler.java Sat Aug 2 14:56:42 2008 @@ -27,6 +27,8 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import javolution.util.FastMap; + import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.collections.MapStack; import org.ofbiz.base.util.template.FreeMarkerWorker; @@ -85,7 +87,7 @@ } } - public static void prepOfbizRoot(Map root, HttpServletRequest request, HttpServletResponse response) { + public static void prepOfbizRoot(Map<String, Object> root, HttpServletRequest request, HttpServletResponse response) { ServletContext servletContext = (ServletContext) request.getAttribute("servletContext"); HttpSession session = request.getSession(); @@ -119,7 +121,7 @@ root.put("requestAttributes", new HttpRequestHashModel(request, wrapper)); // add the request parameters -- this now uses a Map from UtilHttp - Map requestParameters = UtilHttp.getParameterMap(request); + Map<String, Object> requestParameters = UtilHttp.getParameterMap(request); root.put("requestParameters", requestParameters); // add the TabLibFactory Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizCacheStorage.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizCacheStorage.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizCacheStorage.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/OfbizCacheStorage.java Sat Aug 2 14:56:42 2008 @@ -27,10 +27,10 @@ */ public class OfbizCacheStorage implements CacheStorage { //can't have global cache because names/keys are relative to the webapp - protected final UtilCache localCache; + protected final UtilCache<Object, Object> localCache; public OfbizCacheStorage(String id) { - this.localCache = new UtilCache("webapp.FreeMarkerCache." + id, 0, 0, false); + this.localCache = new UtilCache<Object, Object>("webapp.FreeMarkerCache." + id, 0, 0, false); } public Object get(Object key) { Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/RenderWrappedTextTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/RenderWrappedTextTransform.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/RenderWrappedTextTransform.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/ftl/RenderWrappedTextTransform.java Sat Aug 2 14:56:42 2008 @@ -26,6 +26,7 @@ import freemarker.template.TemplateTransformModel; import org.ofbiz.base.util.Debug; +import static org.ofbiz.base.util.UtilGenerics.checkMap; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.template.FreeMarkerWorker; @@ -38,8 +39,8 @@ public Writer getWriter(final Writer out, Map args) { final Environment env = Environment.getCurrentEnvironment(); - Map ctx = (Map)FreeMarkerWorker.getWrappedObject("context", env); - final String wrappedFTL = FreeMarkerWorker.getArg(args, "wrappedFTL", ctx); + Map<String, Object> ctx = checkMap(FreeMarkerWorker.getWrappedObject("context", env), String.class, Object.class); + final String wrappedFTL = FreeMarkerWorker.getArg(checkMap(args, String.class, Object.class), "wrappedFTL", ctx); return new Writer(out) { Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/region/Region.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/region/Region.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/region/Region.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/region/Region.java Sat Aug 2 14:56:42 2008 @@ -18,7 +18,6 @@ *******************************************************************************/ package org.ofbiz.webapp.region; -import java.util.HashMap; import java.util.Map; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; @@ -28,6 +27,8 @@ import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; +import javolution.util.FastMap; + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilJ2eeCompat; @@ -39,14 +40,14 @@ public static final String module = Region.class.getName(); - private Map sections = new HashMap(); + private Map<String, Section> sections = FastMap.newInstance(); protected String id; public Region(String id, String content) { this(id, content, null); // content is the name of a template } - public Region(String id, String content, Map sections) { + public Region(String id, String content, Map<String, ? extends Section> sections) { super(content, "region"); this.id = id; if (sections != null) { @@ -62,15 +63,15 @@ sections.put(section.getName(), section); } - public void putAll(Map newSections) { + public void putAll(Map<String, ? extends Section> newSections) { sections.putAll(newSections); } public Section get(String name) { - return (Section) sections.get(name); + return sections.get(name); } - public Map getSections() { + public Map<String, ? extends Section> getSections() { return sections; } Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/region/RegionManager.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/region/RegionManager.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/region/RegionManager.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/region/RegionManager.java Sat Aug 2 14:56:42 2008 @@ -19,11 +19,10 @@ package org.ofbiz.webapp.region; import java.net.URL; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; import java.util.Map; +import javolution.util.FastMap; + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; @@ -39,7 +38,7 @@ public static final String module = RegionManager.class.getName(); - protected static UtilCache regionCache = new UtilCache("webapp.Regions.Config", 0, 0); + protected static UtilCache<URL, Map<String, Region>> regionCache = new UtilCache<URL, Map<String, Region>>("webapp.Regions.Config", 0, 0); protected URL regionFile = null; @@ -52,11 +51,11 @@ regionCache.put(regionFile, readRegionXml(regionFile)); } - public Map getRegions() { - Map regions = (Map) regionCache.get(regionFile); + public Map<String, Region> getRegions() { + Map<String, Region> regions = regionCache.get(regionFile); if (regions == null) { synchronized (this) { - regions = (Map) regionCache.get(regionFile); + regions = regionCache.get(regionFile); if (regions == null) { if (Debug.verboseOn()) Debug.logVerbose("Regions not loaded for " + regionFile + ", loading now", module); regions = readRegionXml(regionFile); @@ -69,15 +68,15 @@ public Region getRegion(String regionName) { if (regionFile == null) return null; - return (Region) getRegions().get(regionName); + return getRegions().get(regionName); } public void putRegion(Region region) { getRegions().put(region.getId(), region); } - public Map readRegionXml(URL regionFile) { - Map regions = new HashMap(); + public Map<String, Region> readRegionXml(URL regionFile) { + Map<String, Region> regions = FastMap.newInstance(); Document document = null; @@ -95,11 +94,7 @@ Element rootElement = document.getDocumentElement(); - List defineElements = UtilXml.childElementList(rootElement, "define"); - Iterator defineIter = defineElements.iterator(); - - while (defineIter.hasNext()) { - Element defineElement = (Element) defineIter.next(); + for (Element defineElement: UtilXml.childElementList(rootElement, "define")) { addRegion(defineElement, regions); } @@ -107,7 +102,7 @@ return regions; } - protected void addRegion(Element defineElement, Map regions) { + protected void addRegion(Element defineElement, Map<String, Region> regions) { Region newRegion = null; String idAttr = defineElement.getAttribute("id"); @@ -135,11 +130,7 @@ regions.put(idAttr, newRegion); - List putElements = UtilXml.childElementList(defineElement, "put"); - Iterator putIter = putElements.iterator(); - - while (putIter.hasNext()) { - Element putElement = (Element) putIter.next(); + for (Element putElement: UtilXml.childElementList(defineElement, "put")) { newRegion.put(makeSection(putElement)); } @@ -168,8 +159,8 @@ public static Region getRegion(URL regionFile, String regionName) { if (regionFile == null) return null; - Map regions = (Map) regionCache.get(regionFile); + Map<String, Region> regions = regionCache.get(regionFile); if (regions == null) return null; - return (Region) regions.get(regionName); + return regions.get(regionName); } } Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/region/RegionStack.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/region/RegionStack.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/region/RegionStack.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/region/RegionStack.java Sat Aug 2 14:56:42 2008 @@ -21,21 +21,23 @@ import java.util.Stack; import javax.servlet.ServletRequest; +import static org.ofbiz.base.util.UtilGenerics.checkStack; + public class RegionStack { private RegionStack() {} // no instantiations - public static Stack getStack(ServletRequest request) { - Stack s = (Stack) request.getAttribute("region-stack"); + public static Stack<Region> getStack(ServletRequest request) { + Stack<Region> s = checkStack(request.getAttribute("region-stack"), Region.class); if (s == null) { - s = new Stack(); + s = new Stack<Region>(); request.setAttribute("region-stack", s); } return s; } public static Region peek(ServletRequest request) { - return (Region) getStack(request).peek(); + return getStack(request).peek(); } public static void push(ServletRequest request, Region region) { @@ -43,6 +45,6 @@ } public static Region pop(ServletRequest request) { - return (Region) getStack(request).pop(); + return getStack(request).pop(); } } Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/stats/ServerHitBin.java Sat Aug 2 14:56:42 2008 @@ -21,12 +21,14 @@ import java.net.InetAddress; import java.util.Calendar; import java.util.Date; -import java.util.HashMap; import java.util.Iterator; -import java.util.LinkedList; +import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; +import javolution.util.FastList; +import javolution.util.FastMap; + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilMisc; @@ -114,27 +116,27 @@ } ServerHitBin bin = null; - LinkedList binList = null; + List<ServerHitBin> binList = null; switch (type) { case REQUEST: - binList = (LinkedList) requestHistory.get(id); + binList = requestHistory.get(id); break; case EVENT: - binList = (LinkedList) eventHistory.get(id); + binList = eventHistory.get(id); break; case VIEW: - binList = (LinkedList) viewHistory.get(id); + binList = viewHistory.get(id); break; case ENTITY: - binList = (LinkedList) entityHistory.get(id); + binList = entityHistory.get(id); break; case SERVICE: - binList = (LinkedList) serviceHistory.get(id); + binList = serviceHistory.get(id); break; } @@ -142,27 +144,27 @@ synchronized (ServerHitBin.class) { switch (type) { case REQUEST: - binList = (LinkedList) requestHistory.get(id); + binList = requestHistory.get(id); break; case EVENT: - binList = (LinkedList) eventHistory.get(id); + binList = eventHistory.get(id); break; case VIEW: - binList = (LinkedList) viewHistory.get(id); + binList = viewHistory.get(id); break; case ENTITY: - binList = (LinkedList) entityHistory.get(id); + binList = entityHistory.get(id); break; case SERVICE: - binList = (LinkedList) serviceHistory.get(id); + binList = serviceHistory.get(id); break; } if (binList == null) { - binList = new LinkedList(); + binList = FastList.newInstance(); switch (type) { case REQUEST: requestHistory.put(id, binList); @@ -189,16 +191,16 @@ } if (binList.size() > 0) { - bin = (ServerHitBin) binList.getFirst(); + bin = binList.get(0); } if (bin == null) { synchronized (ServerHitBin.class) { if (binList.size() > 0) { - bin = (ServerHitBin) binList.getFirst(); + bin = binList.get(0); } if (bin == null) { bin = new ServerHitBin(id, type, true, delegator); - binList.addFirst(bin); + binList.add(0, bin); } } } @@ -310,18 +312,18 @@ } // these Maps contain Lists of ServerHitBin objects by id, the most recent is first in the list - public static Map requestHistory = new HashMap(); - public static Map eventHistory = new HashMap(); - public static Map viewHistory = new HashMap(); - public static Map entityHistory = new HashMap(); - public static Map serviceHistory = new HashMap(); + public static Map<String, List<ServerHitBin>> requestHistory = FastMap.newInstance(); + public static Map<String, List<ServerHitBin>> eventHistory = FastMap.newInstance(); + public static Map<String, List<ServerHitBin>> viewHistory = FastMap.newInstance(); + public static Map<String, List<ServerHitBin>> entityHistory = FastMap.newInstance(); + public static Map<String, List<ServerHitBin>> serviceHistory = FastMap.newInstance(); // these Maps contain ServerHitBin objects by id - public static Map requestSinceStarted = new HashMap(); - public static Map eventSinceStarted = new HashMap(); - public static Map viewSinceStarted = new HashMap(); - public static Map entitySinceStarted = new HashMap(); - public static Map serviceSinceStarted = new HashMap(); + public static Map<String, ServerHitBin> requestSinceStarted = FastMap.newInstance(); + public static Map<String, ServerHitBin> eventSinceStarted = FastMap.newInstance(); + public static Map<String, ServerHitBin> viewSinceStarted = FastMap.newInstance(); + public static Map<String, ServerHitBin> entitySinceStarted = FastMap.newInstance(); + public static Map<String, ServerHitBin> serviceSinceStarted = FastMap.newInstance(); GenericDelegator delegator; String delegatorName; @@ -516,35 +518,35 @@ synchronized void advanceBin(long toTime) { // first check to see if this bin has expired, if so save and recycle it while (limitLength && toTime > this.endTime) { - LinkedList binList = null; + List<ServerHitBin> binList = null; switch (type) { case REQUEST: - binList = (LinkedList) requestHistory.get(id); + binList = requestHistory.get(id); break; case EVENT: - binList = (LinkedList) eventHistory.get(id); + binList = eventHistory.get(id); break; case VIEW: - binList = (LinkedList) viewHistory.get(id); + binList = viewHistory.get(id); break; case ENTITY: - binList = (LinkedList) entityHistory.get(id); + binList = entityHistory.get(id); break; case SERVICE: - binList = (LinkedList) serviceHistory.get(id); + binList = serviceHistory.get(id); break; } // the first in the list will be this object, remove and copy it, // put the copy at the first of the list, then put this object back on - binList.removeFirst(); + binList.remove(0); if (this.numberHits > 0) { - binList.addFirst(new ServerHitBin(this)); + binList.add(0, new ServerHitBin(this)); // persist each bin when time ends if option turned on if (UtilProperties.propertyValueEqualsIgnoreCase("serverstats", "stats.persist." + ServerHitBin.typeIds[type] + ".bin", "true")) { @@ -578,7 +580,7 @@ } } this.reset(this.endTime + 1); - binList.addFirst(this); + binList.add(0, this); } } Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/AbstractParameterTag.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/AbstractParameterTag.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/AbstractParameterTag.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/AbstractParameterTag.java Sat Aug 2 14:56:42 2008 @@ -18,47 +18,48 @@ *******************************************************************************/ package org.ofbiz.webapp.taglib; -import java.util.HashMap; import java.util.Map; import javax.servlet.jsp.JspTagException; import javax.servlet.jsp.tagext.TagSupport; +import javolution.util.FastMap; + /** * AbstractParameterTag - Tag which support child parameter tags. */ public abstract class AbstractParameterTag extends TagSupport { - private Map inParameters = null; - private Map outParameters = null; + private Map<String, Object> inParameters = null; + private Map<String, String> outParameters = null; - public void addInParameter(Object name, Object value) { + public void addInParameter(String name, Object value) { if (this.inParameters == null) - this.inParameters = new HashMap(); + this.inParameters = FastMap.newInstance(); inParameters.put(name, value); } - public Map getInParameters() { + public Map<String, Object> getInParameters() { if (this.inParameters == null) - return new HashMap(); + return FastMap.newInstance(); else return this.inParameters; } public void addOutParameter(Object name, Object alias) { if (this.outParameters == null) - this.outParameters = new HashMap(); - outParameters.put(name, alias); + this.outParameters = FastMap.newInstance(); + outParameters.put((String) name, (String) alias); } - public Map getOutParameters() { + public Map<String, String> getOutParameters() { if (this.outParameters == null) - return new HashMap(); + return FastMap.newInstance(); else return this.outParameters; } public int doStartTag() throws JspTagException { - inParameters = new HashMap(); + inParameters = FastMap.newInstance(); return EVAL_BODY_INCLUDE; } Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/I18nMessageTag.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/I18nMessageTag.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/I18nMessageTag.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/I18nMessageTag.java Sat Aug 2 14:56:42 2008 @@ -43,7 +43,7 @@ private ResourceBundle bundle = null; - private final List arguments = new ArrayList(); + private final List<Object> arguments = new ArrayList<Object>(); public void setKey(String key) { this.key = key; Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/IterateNextTag.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/IterateNextTag.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/IterateNextTag.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/IterateNextTag.java Sat Aug 2 14:56:42 2008 @@ -32,7 +32,7 @@ public class IterateNextTag extends BodyTagSupport { protected String name = null; - protected Class type = null; + protected Class<?> type = null; protected Object element = null; protected boolean expandMap = false; @@ -69,7 +69,7 @@ if (iteratorTag == null) throw new JspTagException("IterateNextTag not inside IteratorTag."); - Iterator iterator = iteratorTag.getIterator(); + Iterator<? extends Object> iterator = iteratorTag.getIterator(); if (iterator == null || !iterator.hasNext()) return SKIP_BODY; @@ -91,7 +91,7 @@ Map.Entry entry = (Map.Entry) mapEntries.next(); Object value = entry.getValue(); - if (value == null) value = new String(); + if (value == null) value = ""; pageContext.setAttribute((String) entry.getKey(), value); } } Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/IteratorTag.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/IteratorTag.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/IteratorTag.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/IteratorTag.java Sat Aug 2 14:56:42 2008 @@ -42,7 +42,7 @@ public static final String module = IteratorTag.class.getName(); - protected Iterator iterator = null; + protected Iterator<? extends Object> iterator = null; protected String name = null; protected String property = null; protected Object element = null; @@ -76,7 +76,7 @@ expandMap = "true".equals(expMap); } - public void setIterator(Iterator iterator) { + public void setIterator(Iterator<? extends Object> iterator) { this.iterator = iterator; } @@ -92,7 +92,7 @@ return element; } - public Iterator getIterator() { + public Iterator<? extends Object> getIterator() { return this.iterator; } @@ -153,18 +153,18 @@ private boolean defineIterator() { // clear the iterator, after this it may be set directly - Iterator newIterator = null; - Collection thisCollection = null; + Iterator<? extends Object> newIterator = null; + Collection<? extends Object> thisCollection = null; if (property != null) { if (Debug.verboseOn()) Debug.logVerbose("Getting iterator from property: " + property, module); Object propertyObject = pageContext.findAttribute(property); if (propertyObject instanceof Iterator) { - newIterator = (Iterator) propertyObject; + newIterator = (Iterator<? extends Object>) propertyObject; } else { // if ClassCastException, it should indicate looking for a Collection - thisCollection = (Collection) propertyObject; + thisCollection = (Collection<? extends Object>) propertyObject; } } else { // Debug.logInfo("No property, check for Object Tag.", module); @@ -174,7 +174,7 @@ if (objectTag == null) return false; if (objectTag.getType().equals("java.util.Collection")) { - thisCollection = (Collection) objectTag.getObject(); + thisCollection = (Collection<? extends Object>) objectTag.getObject(); } else { try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); @@ -183,7 +183,7 @@ for (int i = 0; i < m.length; i++) { if (m[i].getName().equals("iterator")) { Debug.logVerbose("Found iterator method. Using it.", module); - newIterator = (Iterator) m[i].invoke( + newIterator = (Iterator<? extends Object>) m[i].invoke( objectTag.getObject(), (Object[]) null); break; } @@ -199,12 +199,12 @@ return false; if (limit > 0 || offset > 0) { - ArrayList colList = new ArrayList(thisCollection); + ArrayList<? extends Object> colList = new ArrayList<Object>(thisCollection); int startIndex = offset > 0 ? offset : 0; int endIndex = limit > 0 ? offset + limit : colList.size(); endIndex = endIndex > colList.size() ? colList.size() : endIndex; - List subList = colList.subList(startIndex, endIndex); + List<? extends Object> subList = colList.subList(startIndex, endIndex); newIterator = subList.iterator(); } else { Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ObjectTag.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ObjectTag.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ObjectTag.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ObjectTag.java Sat Aug 2 14:56:42 2008 @@ -35,7 +35,7 @@ protected Object element = null; protected String name = null; protected String property = null; - protected Class type = null; + protected Class<?> type = null; public void setName(String name) { this.name = name; Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ServiceTag.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ServiceTag.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ServiceTag.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/taglib/ServiceTag.java Sat Aug 2 14:56:42 2008 @@ -95,8 +95,8 @@ throw new JspTagException("Invaild result scope specified. (page, request, session, application)"); } - Map context = getInParameters(); - Map result = null; + Map<String, Object> context = getInParameters(); + Map<String, Object> result = null; if (userLogin != null) context.put("userLogin", userLogin); @@ -110,19 +110,16 @@ throw new JspTagException("Problems invoking the requested service: " + e.getMessage()); } - Map aliases = getOutParameters(); + Map<String, String> aliases = getOutParameters(); if (result != null) { // expand the result - Iterator i = result.entrySet().iterator(); - - while (i.hasNext()) { - Map.Entry entry = (Map.Entry) i.next(); - Object key = entry.getKey(); + for (Map.Entry<String, Object> entry: result.entrySet()) { + String key = entry.getKey(); Object value = entry.getValue(); - String ctxName = (String) (aliases.containsKey(key) ? aliases.get(key) : key); + String ctxName = (aliases.containsKey(key) ? aliases.get(key) : key); - if (value == null) value = new String(); + if (value == null) value = ""; pageContext.setAttribute(ctxName, value, scope); } } Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ViewFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ViewFactory.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ViewFactory.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ViewFactory.java Sat Aug 2 14:56:42 2008 @@ -18,12 +18,13 @@ *******************************************************************************/ package org.ofbiz.webapp.view; -import java.util.HashMap; import java.util.Map; import java.util.List; import java.util.Iterator; import javax.servlet.ServletContext; +import javolution.util.FastMap; + import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.ObjectType; import org.ofbiz.base.util.GeneralRuntimeException; @@ -40,10 +41,10 @@ protected RequestHandler requestHandler = null; protected RequestManager requestManager = null; protected ServletContext context = null; - protected Map handlers = null; + protected Map<String, ViewHandler> handlers = null; public ViewFactory(RequestHandler requestHandler) { - this.handlers = new HashMap(); + this.handlers = FastMap.newInstance(); this.requestHandler = requestHandler; this.requestManager = requestHandler.getRequestManager(); this.context = requestHandler.getServletContext(); @@ -58,11 +59,9 @@ } private void preLoadAll() throws ViewHandlerException { - List handlers = requestManager.getHandlerKeys(RequestManager.VIEW_HANDLER_KEY); + List<String> handlers = requestManager.getHandlerKeys(RequestManager.VIEW_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.loadViewHandler(type)); } } @@ -90,12 +89,12 @@ } // get the view handler by type from the contextHandlers - ViewHandler handler = (ViewHandler) handlers.get(type); + ViewHandler handler = handlers.get(type); // if none found lets create it and add it in if (handler == null) { synchronized (ViewFactory.class) { - handler = (ViewHandler) handlers.get(type); + handler = handlers.get(type); if (handler == null) { handler = this.loadViewHandler(type); handlers.put(type, handler); Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/WfsViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/WfsViewHandler.java?rev=682067&r1=682066&r2=682067&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/WfsViewHandler.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/WfsViewHandler.java Sat Aug 2 14:56:42 2008 @@ -26,7 +26,6 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.util.HashMap; import java.util.Map; import java.util.List; @@ -34,6 +33,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javolution.util.FastMap; + import org.ofbiz.base.location.FlexibleLocation; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.HttpClient; @@ -76,7 +77,7 @@ List entityList = (List)request.getAttribute("entityList"); SimpleSequence simpleList = new SimpleSequence(entityList); - Map ctx = new HashMap(); + Map<String, Object> ctx = FastMap.newInstance(); ctx.put("entityList", simpleList); StringWriter outWriter = new StringWriter(); Template template = getDocTemplate(page); |
Free forum by Nabble | Edit this page |