X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=runtime%2Forg.argeo.slc.support.simple%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fcore%2Fexecution%2FMapExecutionContext.java;h=5d26c52b42fd3d0bbda91618805173d8e9bff9ef;hb=2531d7501fcb56eed16a7c61b2d842bd65228f53;hp=a700ca3b810801e05f67db3ec11e0a026cc34152;hpb=7fdc9af3e710f0b5e63974aeb4e71e6631fcd1ff;p=gpl%2Fargeo-slc.git diff --git a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/MapExecutionContext.java b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/MapExecutionContext.java index a700ca3b8..5d26c52b4 100644 --- a/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/MapExecutionContext.java +++ b/runtime/org.argeo.slc.support.simple/src/main/java/org/argeo/slc/core/execution/MapExecutionContext.java @@ -1,5 +1,6 @@ package org.argeo.slc.core.execution; +import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Stack; @@ -17,15 +18,17 @@ import org.springframework.beans.factory.ObjectFactory; public class MapExecutionContext implements ExecutionContext { private final static Log log = LogFactory.getLog(MapExecutionContext.class); - private final Stack stack = new Stack(); // TODO: make it thread safe? private final Map variables = new HashMap(); private final String uuid = UUID.randomUUID().toString(); - - public void addVariables(Map variablesToAdd) { + + private final Date creationDate = new Date(); + + public void addVariables( + Map variablesToAdd) { variables.putAll(variablesToAdd); } @@ -40,7 +43,7 @@ public class MapExecutionContext implements ExecutionContext { Map specAttrs = executionFlow .getExecutionSpec().getAttributes(); for (String key : specAttrs.keySet()) { - //ExecutionSpecAttribute esa = specAttrs.get(key); + // ExecutionSpecAttribute esa = specAttrs.get(key); if (executionFlow.isSetAsParameter(key)) { runtime.getLocalVariables().put(key, executionFlow.getParameter(key)); @@ -59,14 +62,14 @@ public class MapExecutionContext implements ExecutionContext { return obj; } - protected Object findVariable(String key) { + public Object findVariable(String key) { Object obj = null; - + // Look if the variable is set in the global execution variables // (i.e. the variable was overridden) if (variables.containsKey(key)) - obj = variables.get(key); - + obj = variables.get(key); + // if the variable was not found, look in the stack starting at the // upper flows if (obj == null) { @@ -103,12 +106,12 @@ public class MapExecutionContext implements ExecutionContext { leftEf.getLocalVariables().clear(); } - + public void addScopedObject(String name, Object obj) { - //TODO: check that the object is not set yet ? + // TODO: check that the object is not set yet ? stack.peek().getScopedObjects().put(name, obj); } - + /** return null if not found */ public Object findScopedObject(String name) { Object obj = null; @@ -125,6 +128,10 @@ public class MapExecutionContext implements ExecutionContext { return uuid; } + public Date getCreationDate() { + return creationDate; + } + private static class ExecutionFlowRuntime { private final ExecutionFlow executionFlow; private final Map scopedObjects = new HashMap();