svn commit: r614949 - in /ofbiz/trunk/framework/service/src/org/ofbiz/service: GenericDispatcher.java LocalDispatcher.java eca/ServiceEcaAction.java

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

svn commit: r614949 - in /ofbiz/trunk/framework/service/src/org/ofbiz/service: GenericDispatcher.java LocalDispatcher.java eca/ServiceEcaAction.java

sichen
Author: sichen
Date: Thu Jan 24 10:08:45 2008
New Revision: 614949

URL: http://svn.apache.org/viewvc?rev=614949&view=rev
Log:
OFBIZ-1594 ability of dispatcher to disable SECAs

Modified:
    ofbiz/trunk/framework/service/src/org/ofbiz/service/GenericDispatcher.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/LocalDispatcher.java
    ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/GenericDispatcher.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/GenericDispatcher.java?rev=614949&r1=614948&r2=614949&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/GenericDispatcher.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/GenericDispatcher.java Thu Jan 24 10:08:45 2008
@@ -32,7 +32,8 @@
 public class GenericDispatcher extends GenericAbstractDispatcher {
 
     public static final String module = GenericDispatcher.class.getName();
-    
+
+    protected static boolean ecasDisabled = false;
     protected static Map<String, LocalDispatcher> dispatcherCache = FastMap.newInstance();
     
     public static LocalDispatcher getLocalDispatcher(String dispatcherName, GenericDelegator delegator) {
@@ -126,6 +127,18 @@
         ctx.setDispatcher(this);
         ctx.loadReaders();
         if (Debug.infoOn()) Debug.logInfo("[LocalDispatcher] : Created Dispatcher for: " + name, module);
+    }
+
+    public void disableEcas(){
+        this.ecasDisabled = true;
+    }
+
+    public void enableEcas() {
+        this.ecasDisabled = false;
+    }
+
+    public boolean isEcasDisabled() {
+        return this.ecasDisabled;
     }
 
     /**

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/LocalDispatcher.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/LocalDispatcher.java?rev=614949&r1=614948&r2=614949&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/LocalDispatcher.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/LocalDispatcher.java Thu Jan 24 10:08:45 2008
@@ -31,6 +31,25 @@
 public interface LocalDispatcher {
 
     /**
+     * Disables running of Service Engine Condition Actions (SECAs).  Intended to be turned off temporarily.
+     * @throws GenericServiceException
+     */
+    public void disableEcas();
+
+    /**
+     * Reenables running of Service Engine Condition Actions (SECAs).  
+     * @throws GenericServiceException
+     */
+    public void enableEcas();
+
+    /**
+     * Returns whether Service Engine Condition Actions (SECAs) are disabled or not.
+     * @return
+     * @throws GenericServiceException
+     */
+    public boolean isEcasDisabled();
+
+    /**
      * Run the service synchronously and return the result.
      * @param serviceName Name of the service to run.
      * @param context Map of name, value pairs composing the context.

Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java?rev=614949&r1=614948&r2=614949&view=diff
==============================================================================
--- ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java (original)
+++ ofbiz/trunk/framework/service/src/org/ofbiz/service/eca/ServiceEcaAction.java Thu Jan 24 10:08:45 2008
@@ -26,6 +26,7 @@
 import org.ofbiz.base.util.UtilGenerics;
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.Debug;
 import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.LocalDispatcher;
@@ -88,6 +89,11 @@
         
         Map<String, Object> actionResult = null;
         LocalDispatcher dispatcher = dctx.getDispatcher();
+        // if SECAs have been turned off, then just return true which has same effect as if secas ran successfully
+        if (dispatcher.isEcasDisabled()) {
+            Debug.logWarning("SECAs have been disabled on purpose and will not be run for [" + serviceName + "]", module);
+            return true;
+        }
 
         if (eventName.startsWith("global-")) {
             // XA resource ECA