]> git.argeo.org Git - gpl/argeo-slc.git/blob - sandbox/argeo.slc.executionflow/src/main/java/org/argeo/slc/executionflow/SimpleExecutionFlow.java
d816419129577755264a300af367ca1d145ebd67
[gpl/argeo-slc.git] / sandbox / argeo.slc.executionflow / src / main / java / org / argeo / slc / executionflow / SimpleExecutionFlow.java
1 package org.argeo.slc.executionflow;
2
3 import java.util.ArrayList;
4 import java.util.HashMap;
5 import java.util.List;
6 import java.util.Map;
7 import java.util.UUID;
8
9 import org.apache.commons.lang.math.RandomUtils;
10 import org.argeo.slc.process.Executable;
11 import org.argeo.slc.test.ExecutableTestRun;
12 import org.springframework.beans.factory.InitializingBean;
13
14 public class SimpleExecutionFlow implements ExecutionFlow, InitializingBean {
15 private static ThreadLocal<ExecutionFlow> executionFlow = new ThreadLocal<ExecutionFlow>();
16
17 private ExecutionSpec executionSpec;
18 private Map<String, Object> attributes = new HashMap<String, Object>();
19 private List<Executable> executables = new ArrayList<Executable>();
20
21 private final String uuid = UUID.randomUUID().toString();
22
23 public void execute() {
24 try {
25 executionFlow.set(this);
26 for (Executable executable : executables) {
27 executable.execute();
28 }
29 } finally {
30 executionFlow.set(null);
31 }
32 }
33
34 public void afterPropertiesSet() throws Exception {
35 // TODO Auto-generated method stub
36
37 }
38
39 public void setExecutables(List<Executable> executables) {
40 this.executables = executables;
41 }
42
43 public void setExecutionSpec(ExecutionSpec executionSpec) {
44 this.executionSpec = executionSpec;
45 }
46
47 public void setAttributes(Map<String, Object> attributes) {
48 this.attributes = attributes;
49 }
50
51 public static ExecutionFlow getCurrentExecutionFlow() {
52 return executionFlow.get();
53 }
54
55 public Map<String, Object> getAttributes() {
56 return attributes;
57 }
58
59 public String getUuid() {
60 return uuid;
61 }
62
63 }