]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.core/src/org/argeo/slc/core/execution/MapExecutionContext.java
First working version of SLC Runtime v2
[gpl/argeo-slc.git] / org.argeo.slc.core / src / org / argeo / slc / core / execution / MapExecutionContext.java
index 0bbc3f0df65abec30f56fc0b4984b8281bce4070..324f973059fc40c150cd4f0ca5abc0935ec7109b 100644 (file)
@@ -23,6 +23,8 @@ import java.util.UUID;
 
 import org.argeo.slc.SlcException;
 import org.argeo.slc.execution.ExecutionContext;
+import org.argeo.slc.execution.ExecutionFlow;
+import org.argeo.slc.execution.ExecutionStack;
 import org.springframework.beans.BeanWrapper;
 import org.springframework.beans.BeanWrapperImpl;
 import org.springframework.beans.BeansException;
@@ -37,6 +39,7 @@ public class MapExecutionContext implements ExecutionContext,
        private final String uuid;
 
        private ApplicationContext applicationContext;
+       private ExecutionStack executionStack;
 
        public MapExecutionContext() {
                uuid = UUID.randomUUID().toString();
@@ -84,6 +87,12 @@ public class MapExecutionContext implements ExecutionContext,
                // try system property in last resort
                if (value == null)
                        value = System.getProperty(key);
+
+               // if the variable was not found, look in the stack starting at the
+               // upper flows
+               if (value == null) {
+                       value = executionStack.findLocalVariable(key);
+               }
                return value;
        }
 
@@ -91,6 +100,20 @@ public class MapExecutionContext implements ExecutionContext,
                return uuid;
        }
 
+       @Override
+       public void beforeFlow(ExecutionFlow executionFlow) {
+               // getUuid();
+               executionStack.enterFlow(executionFlow);
+               setVariable(ExecutionContext.VAR_FLOW_ID,
+                               executionStack.getCurrentStackLevelUuid());
+               setVariable(ExecutionContext.VAR_FLOW_NAME, executionFlow.getName());
+       }
+
+       @Override
+       public void afterFlow(ExecutionFlow executionFlow) {
+               executionStack.leaveFlow(executionFlow);
+       }
+
        @Override
        public boolean equals(Object obj) {
                if (obj instanceof ExecutionContext)
@@ -108,4 +131,8 @@ public class MapExecutionContext implements ExecutionContext,
                this.applicationContext = applicationContext;
        }
 
+       public void setExecutionStack(ExecutionStack executionStack) {
+               this.executionStack = executionStack;
+       }
+
 }