You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2010/04/04 21:08:52 UTC

svn commit: r930738 - /ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaRule.java

Author: doogie
Date: Sun Apr  4 19:08:52 2010
New Revision: 930738

URL: http://svn.apache.org/viewvc?rev=930738&view=rev
Log:
Don't always recreate the nameSet each time; instead, make it a global
static.

Modified:
    ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaRule.java

Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaRule.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaRule.java?rev=930738&r1=930737&r2=930738&view=diff
==============================================================================
--- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaRule.java (original)
+++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/eca/EntityEcaRule.java Sun Apr  4 19:08:52 2010
@@ -41,6 +41,12 @@ public class EntityEcaRule implements ja
 
     public static final String module = EntityEcaRule.class.getName();
 
+    private static final Set<String> nameSet = HashSet<String>(2);
+    static {
+        nameSet.add("set");
+        nameSet.add("action");
+    }
+
     protected String entityName = null;
     protected String operationName = null;
     protected String eventName = null;
@@ -67,9 +73,6 @@ public class EntityEcaRule implements ja
 
         if (Debug.verboseOn()) Debug.logVerbose("Conditions: " + conditions, module);
 
-        Set<String> nameSet = FastSet.newInstance();
-        nameSet.add("set");
-        nameSet.add("action");
         for (Element actionOrSetElement: UtilXml.childElementList(eca, nameSet)) {
             if ("action".equals(actionOrSetElement.getNodeName())) {
                 this.actionsAndSets.add(new EntityEcaAction(actionOrSetElement));
@@ -113,10 +116,9 @@ public class EntityEcaRule implements ja
                     EntityEcaAction ea = (EntityEcaAction) actionOrSet;
                     // in order to enable OR logic without multiple calls to the given service,
                     //only execute a given service name once per service call phase
-                    if (!actionsRun.contains(ea.serviceName)) {
+                    if (actionsRun.add(ea.serviceName)) {
                         if (Debug.infoOn()) Debug.logInfo("Running Entity ECA Service: " + ea.serviceName + ", triggered by rule on Entity: " + value.getEntityName(), module);
                         ea.runAction(dctx, context, value);
-                        actionsRun.add(ea.serviceName);
                     }
                 } else {
                     EntityEcaSetField sf = (EntityEcaSetField) actionOrSet;