Author: doogie
Date: Sat Oct 20 21:02:48 2007 New Revision: 586853 URL: http://svn.apache.org/viewvc?rev=586853&view=rev Log: java 1.5 markup for internal code/methods/fields. Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelNotification.java ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaRule.java ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/AbstractEngine.java ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GenericEngineFactory.java ofbiz/trunk/framework/service/src/org/ofbiz/service/group/GroupModel.java ofbiz/trunk/framework/service/src/org/ofbiz/service/group/GroupServiceModel.java ofbiz/trunk/framework/service/src/org/ofbiz/service/group/ServiceGroupReader.java Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelNotification.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelNotification.java?rev=586853&r1=586852&r2=586853&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelNotification.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelNotification.java Sat Oct 20 21:02:48 2007 @@ -22,6 +22,7 @@ import org.ofbiz.service.config.ServiceConfigUtil; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilGenerics; import java.util.List; import java.util.Map; @@ -55,7 +56,7 @@ } public Map buildContext(Map context, Map result, ModelService model) throws GenericServiceException { - Map userLogin = (Map) context.get("userLogin"); + Map<String, Object> userLogin = UtilGenerics.checkMap(context.get("userLogin")); String partyId = null; if (userLogin != null) { partyId = (String) userLogin.get("partyId"); @@ -100,7 +101,7 @@ public String buildTo() { ServiceConfigUtil.NotificationGroup group = ServiceConfigUtil.getNotificationGroup(notificationGroupName); if (group != null) { - List addr = group.getAddress("to"); + List<String> addr = group.getAddress("to"); if (addr != null && addr.size() > 0) { return StringUtil.join(addr, ","); } @@ -111,7 +112,7 @@ public String buildCc() { ServiceConfigUtil.NotificationGroup group = ServiceConfigUtil.getNotificationGroup(notificationGroupName); if (group != null) { - List addr = group.getAddress("cc"); + List<String> addr = group.getAddress("cc"); if (addr != null) { return StringUtil.join(addr, ","); } @@ -122,7 +123,7 @@ public String buildBcc() { ServiceConfigUtil.NotificationGroup group = ServiceConfigUtil.getNotificationGroup(notificationGroupName); if (group != null) { - List addr = group.getAddress("bcc"); + List<String> addr = group.getAddress("bcc"); if (addr != null && addr.size() > 0) { return StringUtil.join(addr, ","); } @@ -133,9 +134,9 @@ public String buildFrom() { ServiceConfigUtil.NotificationGroup group = ServiceConfigUtil.getNotificationGroup(notificationGroupName); if (group != null) { - List addr = group.getAddress("from"); + List<String> addr = group.getAddress("from"); if (addr != null && addr.size() > 0) { - return (String) addr.get(0); + return addr.get(0); } } return null; Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java?rev=586853&r1=586852&r2=586853&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ModelService.java Sat Oct 20 21:02:48 2007 @@ -142,25 +142,25 @@ public int semaphoreSleep; /** Set of services this service implements */ - public Set implServices = new LinkedHashSet(); + public Set<ModelServiceIface> implServices = new LinkedHashSet<ModelServiceIface>(); /** Set of override parameters */ - public Set overrideParameters = new LinkedHashSet(); + public Set<ModelParam> overrideParameters = new LinkedHashSet<ModelParam>(); /** List of permission groups for service invocation */ - public List permissionGroups = FastList.newInstance(); + public List<ModelPermGroup> permissionGroups = FastList.newInstance(); /** List of email-notifications for this service */ - public List notifications = FastList.newInstance(); + public List<ModelNotification> notifications = FastList.newInstance(); /** Internal Service Group */ public GroupModel internalGroup = null; /** Context Information, a Map of parameters used by the service, contains ModelParam objects */ - protected Map contextInfo = FastMap.newInstance(); + protected Map<String, ModelParam> contextInfo = FastMap.newInstance(); /** Context Information, a List of parameters used by the service, contains ModelParam objects */ - protected List contextParamList = FastList.newInstance(); + protected List<ModelParam> contextParamList = FastList.newInstance(); /** Flag to say if we have pulled in our addition parameters from our implemented service(s) */ protected boolean inheritedParameters = false; @@ -190,10 +190,9 @@ this.inheritedParameters = model.inheritedParameters(); this.internalGroup = model.internalGroup; - List modelParamList = model.getModelParamList(); - Iterator i = modelParamList.iterator(); - while (i.hasNext()) { - this.addParamClone((ModelParam) i.next()); + List<ModelParam> modelParamList = model.getModelParamList(); + for (ModelParam param: modelParamList) { + this.addParamClone(param); } } @@ -266,7 +265,7 @@ * @return ModelParam object with the specified name */ public ModelParam getParam(String name) { - return (ModelParam) contextInfo.get(name); + return contextInfo.get(name); } /** @@ -302,23 +301,17 @@ } } - public Set getAllParamNames() { - Set nameList = new LinkedHashSet(); - Iterator i = this.contextParamList.iterator(); - - while (i.hasNext()) { - ModelParam p = (ModelParam) i.next(); + public Set<String> getAllParamNames() { + Set<String> nameList = new TreeSet<String>(); + for (ModelParam p: this.contextParamList) { nameList.add(p.name); } return nameList; } - public Set getInParamNames() { - Set nameList = new LinkedHashSet(); - Iterator i = this.contextParamList.iterator(); - - while (i.hasNext()) { - ModelParam p = (ModelParam) i.next(); + public Set<String> getInParamNames() { + Set<String> nameList = new TreeSet<String>(); + for (ModelParam p: this.contextParamList) { // don't include OUT parameters in this list, only IN and INOUT if ("OUT".equals(p.mode)) continue; nameList.add(p.name); @@ -330,9 +323,7 @@ public int getDefinedInCount() { int count = 0; - Iterator i = this.contextParamList.iterator(); - while (i.hasNext()) { - ModelParam p = (ModelParam) i.next(); + for (ModelParam p: this.contextParamList) { // don't include OUT parameters in this list, only IN and INOUT if ("OUT".equals(p.mode) || p.internal) continue; count++; @@ -341,12 +332,9 @@ return count; } - public Set getOutParamNames() { - Set nameList = new LinkedHashSet(); - Iterator i = this.contextParamList.iterator(); - - while (i.hasNext()) { - ModelParam p = (ModelParam) i.next(); + public Set<String> getOutParamNames() { + Set<String> nameList = new TreeSet<String>(); + for (ModelParam p: this.contextParamList) { // don't include IN parameters in this list, only OUT and INOUT if ("IN".equals(p.mode)) continue; nameList.add(p.name); @@ -358,9 +346,7 @@ public int getDefinedOutCount() { int count = 0; - Iterator i = this.contextParamList.iterator(); - while (i.hasNext()) { - ModelParam p = (ModelParam) i.next(); + for (ModelParam p: this.contextParamList) { // don't include IN parameters in this list, only OUT and INOUT if ("IN".equals(p.mode) || p.internal) continue; count++; @@ -370,11 +356,9 @@ } public void updateDefaultValues(Map context, String mode) { - List params = this.getModelParamList(); + List<ModelParam> params = this.getModelParamList(); if (params != null) { - Iterator i = params.iterator(); - while (i.hasNext()) { - ModelParam param = (ModelParam) i.next(); + for (ModelParam param: params) { if ("INOUT".equals(param.mode) || mode.equals(param.mode)) { Object defaultValueObj = param.getDefaultValue(); if (defaultValueObj != null && context.get(param.name) == null) { @@ -407,9 +391,7 @@ } // get the info values - Iterator contextParamIter = this.contextParamList.iterator(); - while (contextParamIter.hasNext()) { - ModelParam modelParam = (ModelParam) contextParamIter.next(); + for (ModelParam modelParam: this.contextParamList) { // Debug.logInfo("In ModelService.validate preparing parameter [" + modelParam.name + (modelParam.optional?"(optional):":"(required):") + modelParam.mode + "] for service [" + this.name + "]", module); if ("INOUT".equals(modelParam.mode) || mode.equals(modelParam.mode)) { if (modelParam.optional) { @@ -553,7 +535,7 @@ } // * Validate types next - List typeFailMsgs = FastList.newInstance(); + List<String> typeFailMsgs = FastList.newInstance(); Iterator i = testSet.iterator(); while (i.hasNext()) { String key = (String) i.next(); @@ -563,9 +545,7 @@ String infoType = (String) info.get(key); if (param.validators != null && param.validators.size() > 0) { - Iterator vali = param.validators.iterator(); - while (vali.hasNext()) { - ModelParam.ModelParamValidator val = (ModelParam.ModelParamValidator) vali.next(); + for (ModelParam.ModelParamValidator val: param.validators) { if (UtilValidate.isNotEmpty(val.getMethodName())) { try { if (!typeValidate(val, testObject)) { @@ -677,8 +657,8 @@ * @param internal True to include internal parameters * @return List of parameter names */ - public List getParameterNames(String mode, boolean optional, boolean internal) { - List names = FastList.newInstance(); + public List<String> getParameterNames(String mode, boolean optional, boolean internal) { + List<String> names = FastList.newInstance(); if (!"IN".equals(mode) && !"OUT".equals(mode) && !"INOUT".equals(mode)) { return names; @@ -686,11 +666,7 @@ if (contextInfo.size() == 0) { return names; } - Iterator i = contextParamList.iterator(); - - while (i.hasNext()) { - ModelParam param = (ModelParam) i.next(); - + for (ModelParam param: contextParamList) { if (param.mode.equals("INOUT") || param.mode.equals(mode)) { if (optional || !param.optional) { if (internal || !param.internal) { @@ -702,7 +678,7 @@ return names; } - public List getParameterNames(String mode, boolean optional) { + public List<String> getParameterNames(String mode, boolean optional) { return this.getParameterNames(mode, optional, true); } @@ -781,14 +757,11 @@ } } - Iterator i = contextParamList.iterator(); - - while (i.hasNext()) { - ModelParam param = (ModelParam) i.next(); + for (ModelParam param: contextParamList) { //boolean internalParam = param.internal; if (param.mode.equals("INOUT") || param.mode.equals(mode)) { - Object key = param.name; + String key = param.name; // internal map of strings if (param.stringMapPrefix != null && param.stringMapPrefix.length() > 0 && !source.containsKey(key)) { @@ -924,9 +897,7 @@ * Evaluates notifications */ public void evalNotifications(DispatchContext dctx, Map context, Map result) { - Iterator i = this.notifications.iterator(); - while (i.hasNext()) { - ModelNotification notify = (ModelNotification) i.next(); + for (ModelNotification notify: this.notifications) { notify.callNotify(dctx, this, context, result); } } @@ -940,9 +911,7 @@ public boolean evalPermissions(DispatchContext dctx, Map context) { // old permission checking if (this.containsPermissions()) { - Iterator i = this.permissionGroups.iterator(); - while (i.hasNext()) { - ModelPermGroup group = (ModelPermGroup) i.next(); + for (ModelPermGroup group: this.permissionGroups) { if (!group.evalPermissions(dctx, context)) { return false; } @@ -965,10 +934,7 @@ if (contextInfo == null || contextInfo.size() == 0) { return target; } - Iterator contextParamIter = this.contextParamList.iterator(); - while (contextParamIter.hasNext()) { - ModelParam modelParam = (ModelParam) contextParamIter.next(); - + for (ModelParam modelParam: this.contextParamList) { // don't include OUT parameters in this list, only IN and INOUT if ("OUT".equals(modelParam.mode)) continue; @@ -984,8 +950,8 @@ * Returns a list of ModelParam objects in the order they were defined when * the service was created. */ - public List getModelParamList() { - List newList = FastList.newInstance(); + public List<ModelParam> getModelParamList() { + List<ModelParam> newList = FastList.newInstance(); newList.addAll(this.contextParamList); return newList; } @@ -994,12 +960,9 @@ * Returns a list of ModelParam objects in the order they were defined when * the service was created. */ - public List getInModelParamList() { - List inList = FastList.newInstance(); - Iterator contactParamIter = this.contextParamList.iterator(); - while (contactParamIter.hasNext()) { - ModelParam modelParam = (ModelParam) contactParamIter.next(); - + public List<ModelParam> getInModelParamList() { + List<ModelParam> inList = FastList.newInstance(); + for (ModelParam modelParam: this.contextParamList) { // don't include OUT parameters in this list, only IN and INOUT if ("OUT".equals(modelParam.mode)) continue; @@ -1021,10 +984,7 @@ group = ServiceGroupReader.getGroupModel(this.location); } if (group != null) { - List groupedServices = group.getServices(); - Iterator i = groupedServices.iterator(); - while (i.hasNext()) { - GroupServiceModel sm = (GroupServiceModel) i.next(); + for (GroupServiceModel sm: group.getServices()) { implServices.add(new ModelServiceIface(sm.getName(), sm.isOptional())); if (Debug.verboseOn()) Debug.logVerbose("Adding service [" + sm.getName() + "] as interface of: [" + this.name + "]", module); } @@ -1033,18 +993,14 @@ // handle interfaces if (implServices != null && implServices.size() > 0 && dctx != null) { - Iterator implIter = implServices.iterator(); - while (implIter.hasNext()) { - ModelServiceIface iface = (ModelServiceIface) implIter.next(); + for (ModelServiceIface iface: implServices) { String serviceName = iface.getService(); boolean optional = iface.isOptional(); ModelService model = dctx.getModelService(serviceName); if (model != null) { - Iterator contextParamIter = model.contextParamList.iterator(); - while (contextParamIter.hasNext()) { - ModelParam newParam = (ModelParam) contextParamIter.next(); - ModelParam existingParam = (ModelParam) this.contextInfo.get(newParam.name); + for (ModelParam newParam: model.contextParamList) { + ModelParam existingParam = this.contextInfo.get(newParam.name); if (existingParam != null) { // if the existing param is not INOUT and the newParam.mode is different from existingParam.mode, make the existing param optional and INOUT // TODO: this is another case where having different optional/required settings for IN and OUT would be quite valuable... @@ -1072,10 +1028,8 @@ // handle any override parameters if (overrideParameters != null && overrideParameters.size() > 0) { - Iterator keySetIter = overrideParameters.iterator(); - while (keySetIter.hasNext()) { - ModelParam overrideParam = (ModelParam) keySetIter.next(); - ModelParam existingParam = (ModelParam) contextInfo.get(overrideParam.name); + for (ModelParam overrideParam: overrideParameters) { + ModelParam existingParam = contextInfo.get(overrideParam.name); // keep the list clean, remove it then add it back contextParamList.remove(existingParam); @@ -1132,14 +1086,12 @@ public void getWSDL(Definition def, String locationURI) throws WSDLException { // set the IN parameters Input input = def.createInput(); - List inParam = this.getParameterNames(IN_PARAM, true, false); + List<String> inParam = this.getParameterNames(IN_PARAM, true, false); if (inParam != null) { Message inMessage = def.createMessage(); inMessage.setQName(new QName(TNS, this.name + "Request")); inMessage.setUndefined(false); - Iterator i = inParam.iterator(); - while (i.hasNext()) { - String paramName = (String) i.next(); + for (String paramName: inParam) { ModelParam param = this.getParam(paramName); if (!param.internal) { inMessage.addPart(param.getWSDLPart(def)); @@ -1151,14 +1103,12 @@ // set the OUT parameters Output output = def.createOutput(); - List outParam = this.getParameterNames(OUT_PARAM, true, false); + List<String> outParam = this.getParameterNames(OUT_PARAM, true, false); if (outParam != null) { Message outMessage = def.createMessage(); outMessage.setQName(new QName(TNS, this.name + "Response")); outMessage.setUndefined(false); - Iterator i = outParam.iterator(); - while (i.hasNext()) { - String paramName = (String) i.next(); + for (String paramName: outParam) { ModelParam param = this.getParam(paramName); if (!param.internal) { outMessage.addPart(param.getWSDLPart(def)); Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java?rev=586853&r1=586852&r2=586853&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/ServiceDispatcher.java Sat Oct 20 21:02:48 2007 @@ -33,6 +33,7 @@ import org.ofbiz.security.SecurityConfigurationException; import org.ofbiz.security.SecurityFactory; import org.ofbiz.service.config.ServiceConfigUtil; +import org.ofbiz.service.eca.ServiceEcaRule; import org.ofbiz.service.eca.ServiceEcaUtil; import org.ofbiz.service.engine.GenericEngine; import org.ofbiz.service.engine.GenericEngineFactory; @@ -44,6 +45,7 @@ import org.w3c.dom.Element; import javax.transaction.Transaction; +import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -59,7 +61,7 @@ public static final int LOCK_RETRIES = 3; protected static final Map<RunningService, ServiceDispatcher> runLog = new LRUMap<RunningService, ServiceDispatcher>(lruLogSize); - protected static Map dispatchers = FastMap.newInstance(); + protected static Map<String, ServiceDispatcher> dispatchers = FastMap.newInstance(); protected static boolean enableJM = true; protected static boolean enableJMS = true; protected static boolean enableSvcs = true; @@ -67,8 +69,8 @@ protected GenericDelegator delegator = null; protected GenericEngineFactory factory = null; protected Security security = null; - protected Map localContext = null; - protected Map callbacks = null; + protected Map<String, DispatchContext> localContext = null; + protected Map<String, List<GenericServiceCallback>> callbacks = null; protected JobManager jm = null; protected JmsListenerFactory jlf = null; @@ -136,11 +138,11 @@ ServiceDispatcher sd; String dispatcherKey = delegator != null ? delegator.getDelegatorName() : "null"; - sd = (ServiceDispatcher) dispatchers.get(dispatcherKey); + sd = dispatchers.get(dispatcherKey); if (sd == null) { synchronized (ServiceDispatcher.class) { if (Debug.verboseOn()) Debug.logVerbose("[ServiceDispatcher.getInstance] : No instance found (" + dispatcherKey + ").", module); - sd = (ServiceDispatcher) dispatchers.get(dispatcherKey); + sd = dispatchers.get(dispatcherKey); if (sd == null) { sd = new ServiceDispatcher(delegator); dispatchers.put(dispatcherKey, sd); @@ -180,7 +182,7 @@ } public synchronized void registerCallback(String serviceName, GenericServiceCallback cb) { - List callBackList = (List) callbacks.get(serviceName); + List<GenericServiceCallback> callBackList = callbacks.get(serviceName); if (callBackList == null) { callBackList = FastList.newInstance(); } @@ -188,8 +190,8 @@ callbacks.put(serviceName, callBackList); } - public List getCallbacks(String serviceName) { - return (List) callbacks.get(serviceName); + public List<GenericServiceCallback> getCallbacks(String serviceName) { + return callbacks.get(serviceName); } /** @@ -258,13 +260,13 @@ RunningService rs = this.logService(localName, modelService, GenericEngine.SYNC_MODE); // get eventMap once for all calls for speed, don't do event calls if it is null - Map eventMap = ServiceEcaUtil.getServiceEventMap(modelService.name); + Map<String, Collection<ServiceEcaRule>> eventMap = ServiceEcaUtil.getServiceEventMap(modelService.name); // check the locale Locale locale = this.checkLocale(context); // setup the engine and context - DispatchContext ctx = (DispatchContext) localContext.get(localName); + DispatchContext ctx = localContext.get(localName); GenericEngine engine = this.getGenericEngine(modelService.engineName); // set IN attributes with default-value as applicable @@ -605,7 +607,7 @@ Locale locale = this.checkLocale(context); // setup the engine and context - DispatchContext ctx = (DispatchContext) localContext.get(localName); + DispatchContext ctx = localContext.get(localName); GenericEngine engine = this.getGenericEngine(service.engineName); // for isolated transactions @@ -638,7 +640,7 @@ try { // get eventMap once for all calls for speed, don't do event calls if it is null - Map eventMap = ServiceEcaUtil.getServiceEventMap(service.name); + Map<String, Collection<ServiceEcaRule>> eventMap = ServiceEcaUtil.getServiceEventMap(service.name); // pre-auth ECA if (eventMap != null) ServiceEcaUtil.evalRules(service.name, eventMap, "auth", ctx, context, result, isError, isFailure); @@ -788,7 +790,7 @@ * @param name of the context to find. */ public DispatchContext getLocalContext(String name) { - return (DispatchContext) localContext.get(name); + return localContext.get(name); } /** @@ -797,7 +799,7 @@ * @return LocalDispatcher matching the loader name */ public LocalDispatcher getLocalDispatcher(String name) { - return ((DispatchContext) localContext.get(name)).getDispatcher(); + return localContext.get(name).getDispatcher(); } /** Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaRule.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaRule.java?rev=586853&r1=586852&r2=586853&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaRule.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaRule.java Sat Oct 20 21:02:48 2007 @@ -45,8 +45,8 @@ protected String eventName = null; protected boolean runOnFailure = false; protected boolean runOnError = false; - protected List conditions = FastList.newInstance(); - protected List actionsAndSets = FastList.newInstance(); + protected List<ServiceEcaCondition> conditions = FastList.newInstance(); + protected List<Object> actionsAndSets = FastList.newInstance(); protected boolean enabled = true; protected ServiceEcaRule() {} @@ -71,9 +71,7 @@ if (Debug.verboseOn()) Debug.logVerbose("Conditions: " + conditions, module); - Set nameSet = FastSet.newInstance(); - nameSet.add("set"); - nameSet.add("action"); + Set<String> nameSet = UtilMisc.toSet("set", "action"); for (Element actionOrSetElement: UtilXml.childElementList(eca, nameSet)) { if ("action".equals(actionOrSetElement.getNodeName())) { this.actionsAndSets.add(new ServiceEcaAction(actionOrSetElement, this.eventName)); @@ -98,10 +96,7 @@ } boolean allCondTrue = true; - Iterator c = conditions.iterator(); - - while (c.hasNext()) { - ServiceEcaCondition ec = (ServiceEcaCondition) c.next(); + for (ServiceEcaCondition ec: conditions) { if (!ec.eval(serviceName, dctx, context)) { if (Debug.infoOn()) Debug.logInfo("For Service ECA [" + this.serviceName + "] on [" + this.eventName + "] got false for condition: " + ec, module); allCondTrue = false; @@ -113,10 +108,8 @@ // if all conditions are true if (allCondTrue) { - Iterator actionsAndSetIter = actionsAndSets.iterator(); boolean allOkay = true; - while (allOkay && actionsAndSetIter.hasNext()) { - Object setOrAction = actionsAndSetIter.next(); + for (Object setOrAction: actionsAndSets) { if (setOrAction instanceof ServiceEcaAction) { ServiceEcaAction ea = (ServiceEcaAction) setOrAction; // in order to enable OR logic without multiple calls to the given service, Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java?rev=586853&r1=586852&r2=586853&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaUtil.java Sat Oct 20 21:02:48 2007 @@ -50,7 +50,7 @@ public static final String module = ServiceEcaUtil.class.getName(); // using a cache is dangerous here because if someone clears it the ECAs won't run: public static UtilCache ecaCache = new UtilCache("service.ServiceECAs", 0, 0, false); - public static Map ecaCache = FastMap.newInstance(); + public static Map<String, Map<String, Collection<ServiceEcaRule>>> ecaCache = FastMap.newInstance(); public static void reloadConfig() { ecaCache.clear(); @@ -90,18 +90,18 @@ for (Element e: UtilXml.childElementList(rootElement, "eca")) { String serviceName = e.getAttribute("service"); String eventName = e.getAttribute("event"); - Map eventMap = (Map) ecaCache.get(serviceName); - List rules = null; + Map<String, Collection<ServiceEcaRule>> eventMap = ecaCache.get(serviceName); + Collection<ServiceEcaRule> rules = null; if (eventMap == null) { eventMap = FastMap.newInstance(); - rules = new LinkedList(); + rules = new LinkedList<ServiceEcaRule>(); ecaCache.put(serviceName, eventMap); eventMap.put(eventName, rules); } else { - rules = (List) eventMap.get(eventName); + rules = eventMap.get(eventName); if (rules == null) { - rules = new LinkedList(); + rules = new LinkedList<ServiceEcaRule>(); eventMap.put(eventName, rules); } } @@ -119,21 +119,19 @@ } } - public static Map getServiceEventMap(String serviceName) { + public static Map<String, Collection<ServiceEcaRule>> getServiceEventMap(String serviceName) { if (ServiceEcaUtil.ecaCache == null) ServiceEcaUtil.readConfig(); - return (Map) ServiceEcaUtil.ecaCache.get(serviceName); + return ServiceEcaUtil.ecaCache.get(serviceName); } - public static Collection getServiceEventRules(String serviceName, String event) { - Map eventMap = getServiceEventMap(serviceName); + public static Collection<ServiceEcaRule> getServiceEventRules(String serviceName, String event) { + Map<String, Collection<ServiceEcaRule>> eventMap = getServiceEventMap(serviceName); if (eventMap != null) { if (event != null) { - return (Collection) eventMap.get(event); + return eventMap.get(event); } else { - List rules = FastList.newInstance(); - Iterator it = eventMap.values().iterator(); - while (it.hasNext()) { - Collection col = (Collection) it.next(); + List<ServiceEcaRule> rules = FastList.newInstance(); + for (Collection<ServiceEcaRule> col: eventMap.values()) { rules.addAll(col); } return rules; @@ -142,23 +140,21 @@ return null; } - public static void evalRules(String serviceName, Map eventMap, String event, DispatchContext dctx, Map context, Map result, boolean isError, boolean isFailure) throws GenericServiceException { + public static void evalRules(String serviceName, Map<String, Collection<ServiceEcaRule>> eventMap, String event, DispatchContext dctx, Map context, Map result, boolean isError, boolean isFailure) throws GenericServiceException { // if the eventMap is passed we save a Map lookup, but if not that's okay we'll just look it up now if (eventMap == null) eventMap = getServiceEventMap(serviceName); if (eventMap == null || eventMap.size() == 0) { return; } - List rules = (List) eventMap.get(event); + Collection<ServiceEcaRule> rules = eventMap.get(event); if (rules == null || rules.size() == 0) { return; } - Iterator i = rules.iterator(); - if (i.hasNext() && Debug.verboseOn()) Debug.logVerbose("Running ECA (" + event + ").", module); - Set actionsRun = new TreeSet(); - while (i.hasNext()) { - ServiceEcaRule eca = (ServiceEcaRule) i.next(); + if (Debug.verboseOn()) Debug.logVerbose("Running ECA (" + event + ").", module); + Set<String> actionsRun = new TreeSet<String>(); + for (ServiceEcaRule eca: rules) { eca.eval(serviceName, dctx, context, result, isError, isFailure, actionsRun); } } Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/AbstractEngine.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/AbstractEngine.java?rev=586853&r1=586852&r2=586853&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/AbstractEngine.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/AbstractEngine.java Sat Oct 20 21:02:48 2007 @@ -41,7 +41,7 @@ public abstract class AbstractEngine implements GenericEngine { public static final String module = AbstractEngine.class.getName(); - protected static Map locationMap = null; + protected static Map<String, String> locationMap = null; protected ServiceDispatcher dispatcher = null; @@ -77,7 +77,7 @@ // uses the lookup map to determin if the location has been aliased in serviceconfig.xml protected String getLocation(ModelService model) { if (locationMap.containsKey(model.location)) { - return (String) locationMap.get(model.location); + return locationMap.get(model.location); } else { return model.location; } @@ -88,11 +88,11 @@ */ public void sendCallbacks(ModelService model, Map context, int mode) throws GenericServiceException { if (!allowCallbacks(model, context, mode)) return; - List callbacks = dispatcher.getCallbacks(model.name); + List<GenericServiceCallback> callbacks = dispatcher.getCallbacks(model.name); if (callbacks != null) { - Iterator i = callbacks.iterator(); + Iterator<GenericServiceCallback> i = callbacks.iterator(); while (i.hasNext()) { - GenericServiceCallback gsc = (GenericServiceCallback) i.next(); + GenericServiceCallback gsc = i.next(); if (gsc.isEnabled()) { gsc.receiveEvent(context); } else { @@ -104,11 +104,11 @@ public void sendCallbacks(ModelService model, Map context, Throwable t, int mode) throws GenericServiceException { if (!allowCallbacks(model, context, mode)) return; - List callbacks = dispatcher.getCallbacks(model.name); + List<GenericServiceCallback> callbacks = dispatcher.getCallbacks(model.name); if (callbacks != null) { - Iterator i = callbacks.iterator(); + Iterator<GenericServiceCallback> i = callbacks.iterator(); while (i.hasNext()) { - GenericServiceCallback gsc = (GenericServiceCallback) i.next(); + GenericServiceCallback gsc = i.next(); if (gsc.isEnabled()) { gsc.receiveEvent(context,t ); } else { @@ -120,11 +120,11 @@ public void sendCallbacks(ModelService model, Map context, Map result, int mode) throws GenericServiceException { if (!allowCallbacks(model, context, mode)) return; - List callbacks = dispatcher.getCallbacks(model.name); + List<GenericServiceCallback> callbacks = dispatcher.getCallbacks(model.name); if (callbacks != null) { - Iterator i = callbacks.iterator(); + Iterator<GenericServiceCallback> i = callbacks.iterator(); while (i.hasNext()) { - GenericServiceCallback gsc = (GenericServiceCallback) i.next(); + GenericServiceCallback gsc = i.next(); if (gsc.isEnabled()) { gsc.receiveEvent(context, result); } else { Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GenericEngineFactory.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GenericEngineFactory.java?rev=586853&r1=586852&r2=586853&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GenericEngineFactory.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/GenericEngineFactory.java Sat Oct 20 21:02:48 2007 @@ -36,7 +36,7 @@ public class GenericEngineFactory { protected ServiceDispatcher dispatcher = null; - protected Map engines = null; + protected Map<String, GenericEngine> engines = null; public GenericEngineFactory(ServiceDispatcher dispatcher) { this.dispatcher = dispatcher; @@ -64,11 +64,11 @@ String className = engineElement.getAttribute("class"); - GenericEngine engine = (GenericEngine) engines.get(engineName); + GenericEngine engine = engines.get(engineName); if (engine == null) { synchronized (GenericEngineFactory.class) { - engine = (GenericEngine) engines.get(engineName); + engine = engines.get(engineName); if (engine == null) { try { ClassLoader loader = Thread.currentThread().getContextClassLoader(); Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/group/GroupModel.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/group/GroupModel.java?rev=586853&r1=586852&r2=586853&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/group/GroupModel.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/group/GroupModel.java Sat Oct 20 21:02:48 2007 @@ -42,7 +42,7 @@ public static final String module = GroupModel.class.getName(); private String groupName, sendMode; - private List services; + private List<GroupServiceModel> services; private boolean optional = false; private int lastServiceRan; @@ -53,7 +53,7 @@ public GroupModel(Element group) { this.sendMode = group.getAttribute("send-mode"); this.groupName = group.getAttribute("name"); - this.services = new LinkedList(); + this.services = new LinkedList<GroupServiceModel>(); this.lastServiceRan = -1; if (groupName == null) { @@ -81,7 +81,7 @@ * @param sendMode Mode used (see DTD) * @param services List of GroupServiceModel objects */ - public GroupModel(String groupName, String sendMode, List services) { + public GroupModel(String groupName, String sendMode, List<GroupServiceModel> services) { this.lastServiceRan = -1; this.groupName = groupName; this.sendMode = sendMode; @@ -108,7 +108,7 @@ * Returns a list of services in this group * @return List */ - public List getServices() { + public List<GroupServiceModel> getServices() { return this.services; } @@ -153,9 +153,7 @@ private Map runAll(ServiceDispatcher dispatcher, String localName, Map context) throws GenericServiceException { Map runContext = UtilMisc.makeMapWritable(context); Map result = FastMap.newInstance(); - Iterator i = services.iterator(); - while (i.hasNext()) { - GroupServiceModel model = (GroupServiceModel) i.next(); + for (GroupServiceModel model: services) { if (Debug.verboseOn()) Debug.logVerbose("Using Context: " + runContext, module); Map thisResult = model.invoke(dispatcher, localName, runContext); if (Debug.verboseOn()) Debug.logVerbose("Result: " + thisResult, module); @@ -176,15 +174,13 @@ } private Map runIndex(ServiceDispatcher dispatcher, String localName, Map context, int index) throws GenericServiceException { - GroupServiceModel model = (GroupServiceModel) services.get(index); + GroupServiceModel model = services.get(index); return model.invoke(dispatcher, localName, context); } private Map runOne(ServiceDispatcher dispatcher, String localName, Map context) throws GenericServiceException { Map result = null; - Iterator i = services.iterator(); - while (i.hasNext() && result != null) { - GroupServiceModel model = (GroupServiceModel) i.next(); + for (GroupServiceModel model: services) { try { result = model.invoke(dispatcher, localName, context); } catch (GenericServiceException e) { Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/group/GroupServiceModel.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/group/GroupServiceModel.java?rev=586853&r1=586852&r2=586853&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/group/GroupServiceModel.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/group/GroupServiceModel.java Sat Oct 20 21:02:48 2007 @@ -111,7 +111,7 @@ Map thisContext = model.makeValid(context, ModelService.IN_PARAM); Debug.logInfo("Running grouped service [" + serviceName + "]", module); if (getMode().equals("async")) { - List requiredOut = model.getParameterNames(ModelService.OUT_PARAM, false); + List<String> requiredOut = model.getParameterNames(ModelService.OUT_PARAM, false); if (requiredOut.size() > 0) { Debug.logWarning("Grouped service (" + getName() + ") requested 'async' invocation; running sync because of required OUT parameters.", module); return dispatcher.runSync(localName, model, thisContext); Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/group/ServiceGroupReader.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/group/ServiceGroupReader.java?rev=586853&r1=586852&r2=586853&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/group/ServiceGroupReader.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/group/ServiceGroupReader.java Sat Oct 20 21:02:48 2007 @@ -41,7 +41,7 @@ public static final String module = ServiceGroupReader.class.getName(); // using a cache is dangerous here because if someone clears it the groups won't work at all: public static UtilCache groupsCache = new UtilCache("service.ServiceGroups", 0, 0, false); - public static Map groupsCache = FastMap.newInstance(); + public static Map<String, GroupModel> groupsCache = FastMap.newInstance(); public static void readConfig() { Element rootElement = null; @@ -95,6 +95,6 @@ if (groupsCache.size() == 0) { ServiceGroupReader.readConfig(); } - return (GroupModel) groupsCache.get(serviceName); + return groupsCache.get(serviceName); } } |
Free forum by Nabble | Edit this page |