fixed issue 22599: Dual OB contexts: background and regular operations
authorAsier Lostalé <asier.lostale@openbravo.com>
Mon, 17 Dec 2012 13:22:07 +0100
changeset 19230 7df2baff13d2
parent 19229 38af5fb36bd9
child 19231 cdc18afeeefd
fixed issue 22599: Dual OB contexts: background and regular operations

Added a new property to Openbravo.properties: background.policy.
When value for this preference is no-execute, background processes won't be executed in that context.

Notes/limitations:
-Context with this preference set will not execute any background process, including those set to be executed immediately.
-If a background process is scheduled in this context, process will not be scheduled in second context until tomcat is restarted in th
config/Openbravo.properties.template
src/org/openbravo/scheduling/OBScheduler.java
--- a/config/Openbravo.properties.template	Wed Jan 16 11:55:20 2013 +0100
+++ b/config/Openbravo.properties.template	Mon Dec 17 13:22:07 2012 +0100
@@ -204,3 +204,9 @@
 # By default those all not generated anymore for tabs for which they are not needed
 #wad.generateAllClassic250Windows=true
 
+# background.policy property defines whether background processes should be
+# executed in this context or not. To prevent process execution this property must
+# be set to no-execute
+background.policy=default
+
+
--- a/src/org/openbravo/scheduling/OBScheduler.java	Wed Jan 16 11:55:20 2013 +0100
+++ b/src/org/openbravo/scheduling/OBScheduler.java	Mon Dec 17 13:22:07 2012 +0100
@@ -32,6 +32,7 @@
 import org.openbravo.base.ConfigParameters;
 import org.openbravo.base.ConnectionProviderContextListener;
 import org.openbravo.base.secureApp.VariablesSecureApp;
+import org.openbravo.base.session.OBPropertiesProvider;
 import org.openbravo.database.ConnectionProvider;
 import org.openbravo.erpCommon.utility.SequenceIdData;
 import org.openbravo.erpCommon.utility.Utility;
@@ -175,6 +176,12 @@
    */
   public void schedule(String requestId, ProcessBundle bundle, Class<? extends Job> jobClass)
       throws SchedulerException, ServletException {
+    String policy = OBPropertiesProvider.getInstance().getOpenbravoProperties()
+        .getProperty("background.policy", "default");
+    if ("no-execute".equals(policy)) {
+      log.info("Not scheduling process because current context background policy is 'no-execute'");
+      return;
+    }
     if (requestId == null) {
       throw new SchedulerException("Request Id cannot be null.");
     }
@@ -347,7 +354,6 @@
      */
     private static Trigger newInstance(String name, ProcessBundle bundle, ConnectionProvider conn)
         throws ServletException {
-
       final TriggerData data = TriggerData.select(conn, dateTimeFormat, name);
 
       Trigger trigger = null;