refactoring env
This commit is contained in:
parent
aaf71a015b
commit
c0ab592cef
|
@ -146,10 +146,10 @@ public class GraphUtils {
|
||||||
|
|
||||||
private static Function<RuntimeEnv, Boolean> generateFunction(final String condition) {
|
private static Function<RuntimeEnv, Boolean> generateFunction(final String condition) {
|
||||||
if (StringUtils.isBlank(condition)) { return env -> true; }
|
if (StringUtils.isBlank(condition)) { return env -> true; }
|
||||||
return token -> {
|
return env -> {
|
||||||
final ExpressionParser parser = new SpelExpressionParser();
|
final ExpressionParser parser = new SpelExpressionParser();
|
||||||
|
|
||||||
final StandardEvaluationContext context = new StandardEvaluationContext(token.getAttributes());
|
final StandardEvaluationContext context = new StandardEvaluationContext(env.getAttributes());
|
||||||
context.addPropertyAccessor(new MapAccessor());
|
context.addPropertyAccessor(new MapAccessor());
|
||||||
|
|
||||||
return parser.parseExpression(condition).getValue(context, Boolean.class);
|
return parser.parseExpression(condition).getValue(context, Boolean.class);
|
||||||
|
|
|
@ -52,7 +52,7 @@ public abstract class ProcessNode implements BeanNameAware {
|
||||||
public void onSuccess(final RuntimeEnv env) {
|
public void onSuccess(final RuntimeEnv env) {
|
||||||
try {
|
try {
|
||||||
saveOutputParams(env);
|
saveOutputParams(env);
|
||||||
ProcessNode.this.engine.releaseToken(ProcessNode.this.process, ProcessNode.this.graphNode, env);
|
ProcessNode.this.engine.releaseEnv(ProcessNode.this.process, ProcessNode.this.graphNode, env);
|
||||||
} catch (final WorkflowManagerException e) {
|
} catch (final WorkflowManagerException e) {
|
||||||
onFail(env, e);
|
onFail(env, e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -216,16 +216,16 @@ public class ProcessEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void releaseToken(final WorkflowProcess process, final RuntimeNode oldGraphNode, final RuntimeEnv oldEnv) {
|
public void releaseEnv(final WorkflowProcess process, final RuntimeNode oldGraphNode, final RuntimeEnv oldEnv) {
|
||||||
try {
|
try {
|
||||||
for (final RuntimeNode graphNode : GraphUtils.nextNodes(process.getJobDetails().getGraph(), oldGraphNode, oldEnv)) {
|
for (final RuntimeNode graphNode : GraphUtils.nextNodes(process.getJobDetails().getGraph(), oldGraphNode, oldEnv)) {
|
||||||
if (graphNode.isJoin() || graphNode.isSuccessNode()) {
|
if (graphNode.isJoin() || graphNode.isSuccessNode()) {
|
||||||
|
|
||||||
if (!process.getPausedJoinNodeTokens().containsKey(graphNode.getName())) {
|
if (!process.getPausedJoinNodeEnvs().containsKey(graphNode.getName())) {
|
||||||
process.getPausedJoinNodeTokens().put(graphNode.getName(), new ArrayList<>());
|
process.getPausedJoinNodeEnvs().put(graphNode.getName(), new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<RuntimeEnv> list = process.getPausedJoinNodeTokens().get(graphNode.getName());
|
final List<RuntimeEnv> list = process.getPausedJoinNodeEnvs().get(graphNode.getName());
|
||||||
|
|
||||||
list.add(oldEnv);
|
list.add(oldEnv);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class WorkflowProcess implements Comparable<WorkflowProcess> {
|
||||||
private ProcessCallback callback;
|
private ProcessCallback callback;
|
||||||
private List<RuntimeEnv> envs = new CopyOnWriteArrayList<>();
|
private List<RuntimeEnv> envs = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
private final Map<String, List<RuntimeEnv>> pausedJoinNodeTokens = new HashMap<>();
|
private final Map<String, List<RuntimeEnv>> pausedJoinNodeEnvs = new HashMap<>();
|
||||||
private final Map<String, String> outputParams = new HashMap<>();
|
private final Map<String, String> outputParams = new HashMap<>();
|
||||||
|
|
||||||
private Throwable error;
|
private Throwable error;
|
||||||
|
@ -47,8 +47,8 @@ public class WorkflowProcess implements Comparable<WorkflowProcess> {
|
||||||
return this.jobDetails;
|
return this.jobDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, List<RuntimeEnv>> getPausedJoinNodeTokens() {
|
public Map<String, List<RuntimeEnv>> getPausedJoinNodeEnvs() {
|
||||||
return this.pausedJoinNodeTokens;
|
return this.pausedJoinNodeEnvs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RuntimeEnv> getEnvs() {
|
public List<RuntimeEnv> getEnvs() {
|
||||||
|
|
Loading…
Reference in New Issue