]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.core/src/org/argeo/slc/core/execution/DefaultExecutionFlow.java
First working version of SLC Runtime v2
[gpl/argeo-slc.git] / org.argeo.slc.core / src / org / argeo / slc / core / execution / DefaultExecutionFlow.java
index 535c42dad7224fdded4a561e864ec801f768d67f..bebde75128243049d80a54b9d35dea87f379f555 100644 (file)
@@ -24,6 +24,7 @@ import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.slc.SlcException;
+import org.argeo.slc.execution.ExecutionContext;
 import org.argeo.slc.execution.ExecutionFlow;
 import org.argeo.slc.execution.ExecutionSpec;
 import org.argeo.slc.execution.ExecutionSpecAttribute;
@@ -46,6 +47,9 @@ public class DefaultExecutionFlow implements ExecutionFlow, InitializingBean,
 
        private Boolean failOnError = true;
 
+       // Only needed if stacked execution flows are used
+       private ExecutionContext executionContext = null;
+
        public DefaultExecutionFlow() {
                this.executionSpec = new DefaultExecutionSpec();
        }
@@ -154,7 +158,16 @@ public class DefaultExecutionFlow implements ExecutionFlow, InitializingBean,
        }
 
        public void doExecuteRunnable(Runnable runnable) {
-               runnable.run();
+               try {
+                       if (executionContext != null)
+                               if (runnable instanceof ExecutionFlow)
+                                       executionContext.beforeFlow((ExecutionFlow) runnable);
+                       runnable.run();
+               } finally {
+                       if (executionContext != null)
+                               if (runnable instanceof ExecutionFlow)
+                                       executionContext.afterFlow((ExecutionFlow) runnable);
+               }
        }
 
        public void afterPropertiesSet() throws Exception {
@@ -258,4 +271,8 @@ public class DefaultExecutionFlow implements ExecutionFlow, InitializingBean,
                this.failOnError = failOnError;
        }
 
+       public void setExecutionContext(ExecutionContext executionContext) {
+               this.executionContext = executionContext;
+       }
+
 }