X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=sandbox%2Fargeo.slc.executionflow%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fexecutionflow%2FSimpleExecutionFlow.java;h=cb27e68401327d34e1342a0cf3408b9d9f9a4d53;hb=f3797d5a7f833ecb183ce8d4a31a7897fbca4035;hp=952bce0de2b8d6ee1f4b578d4ffa33a33762edf7;hpb=d219191bc5879dc486e21d1ae05fc1d82a1ef5a5;p=gpl%2Fargeo-slc.git diff --git a/sandbox/argeo.slc.executionflow/src/main/java/org/argeo/slc/executionflow/SimpleExecutionFlow.java b/sandbox/argeo.slc.executionflow/src/main/java/org/argeo/slc/executionflow/SimpleExecutionFlow.java index 952bce0de..cb27e6840 100644 --- a/sandbox/argeo.slc.executionflow/src/main/java/org/argeo/slc/executionflow/SimpleExecutionFlow.java +++ b/sandbox/argeo.slc.executionflow/src/main/java/org/argeo/slc/executionflow/SimpleExecutionFlow.java @@ -10,26 +10,22 @@ import org.apache.commons.lang.math.RandomUtils; import org.argeo.slc.SlcException; import org.argeo.slc.process.Executable; import org.argeo.slc.test.ExecutableTestRun; +import org.springframework.beans.factory.BeanNameAware; import org.springframework.beans.factory.InitializingBean; import org.springframework.validation.MapBindingResult; -public class SimpleExecutionFlow implements ExecutionFlow, InitializingBean { - private static ThreadLocal executionFlow = new ThreadLocal(); - - private ExecutionSpec executionSpec; +public class SimpleExecutionFlow implements ExecutionFlow, InitializingBean, + BeanNameAware { + private ExecutionSpec executionSpec = new SimpleExecutionSpec(); + private String name = null; private Map attributes = new HashMap(); private List executables = new ArrayList(); private final String uuid = UUID.randomUUID().toString(); public void execute() { - try { - executionFlow.set(this); - for (Executable executable : executables) { - executable.execute(); - } - } finally { - executionFlow.set(null); + for (Executable executable : executables) { + executable.execute(); } } @@ -54,10 +50,11 @@ public class SimpleExecutionFlow implements ExecutionFlow, InitializingBean { if (executionSpecAttr instanceof RefSpecAttribute) { RefSpecAttribute rsa = (RefSpecAttribute) executionSpecAttr; Class targetClass = rsa.getTargetClass(); - if (!targetClass.isAssignableFrom(obj.getClass())) - errors.rejectValue(key, - "Not compatible with target class " - + targetClass); + if (!targetClass.isAssignableFrom(obj.getClass())) { + errors.reject(key + + " not compatible with target class " + + targetClass); + } } } } @@ -67,6 +64,10 @@ public class SimpleExecutionFlow implements ExecutionFlow, InitializingBean { + errors.toString()); } + public void setBeanName(String name) { + this.name = name; + } + public void setExecutables(List executables) { this.executables = executables; } @@ -79,10 +80,6 @@ public class SimpleExecutionFlow implements ExecutionFlow, InitializingBean { this.attributes = attributes; } - public static ExecutionFlow getCurrentExecutionFlow() { - return executionFlow.get(); - } - public Map getAttributes() { return attributes; } @@ -91,4 +88,12 @@ public class SimpleExecutionFlow implements ExecutionFlow, InitializingBean { return uuid; } + public ExecutionSpec getExecutionSpec() { + return executionSpec; + } + + public String toString() { + return new StringBuffer("Flow ").append(name).toString();// .append(" [#") + // .append(uuid).append(']').toString(); + } }