调整Listener参数
This commit is contained in:
@@ -25,22 +25,22 @@ public class SimpleListener implements FlowableListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFlowEnd(FlowableInstance instance, FlowableNode node) {
|
||||
public void onFlowEnd(FlowableInstance instance, FlowableNode node, FlowableAction action) {
|
||||
log.info("onFlowEnd with spring: {}", flowableManager.listNodes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionStart(FlowableInstance instance, FlowableNode node) {
|
||||
public void onActionStart(FlowableInstance instance, FlowableNode node, FlowableAction action) {
|
||||
log.info("onActionStart with spring: {}", flowableManager.listNodes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAction(FlowableInstance instance, FlowableAction action) {
|
||||
public void onAction(FlowableInstance instance, FlowableNode node, FlowableAction action) {
|
||||
log.info("onAction with spring: {}", flowableManager.listNodes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionComplete(FlowableInstance instance, FlowableNode node) {
|
||||
public void onActionComplete(FlowableInstance instance, FlowableNode node, FlowableAction action) {
|
||||
log.info("onActionComplete with spring: {}", flowableManager.listNodes());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,8 +144,18 @@ public abstract class FlowableManager {
|
||||
action(instance, node, null, "系统自动执行");
|
||||
}
|
||||
|
||||
private void action(FlowableInstance instance, FlowableNode node, FlowableAction action, String comment) {
|
||||
callListeners(node.getListeners(), listener -> listener.onActionStart(instance, node));
|
||||
private void action(FlowableInstance instance, FlowableNode node, final FlowableAction inputAction, String comment) {
|
||||
String handlerClass = node.getHandler();
|
||||
if (StringHelper.isBlank(handlerClass)) {
|
||||
throw new IllegalArgumentException("节点执行器为空");
|
||||
}
|
||||
FlowableHandler handler = createBean(handlerClass);
|
||||
final FlowableAction action = handler.handle(configuration, instance, node, inputAction);
|
||||
if (Objects.isNull(action)) {
|
||||
throw new IllegalArgumentException("节点执行结果不能为空");
|
||||
}
|
||||
|
||||
callListeners(node.getListeners(), listener -> listener.onActionStart(instance, node, action));
|
||||
|
||||
if (FlowableInstance.Status.COMPLETED.equals(instance.getStatus()) || FlowableInstance.Status.TERMINAL.equals(instance.getStatus())) {
|
||||
throw new IllegalArgumentException("ID为" + instance.getInstanceId() + "的流程已结束,无法操作");
|
||||
@@ -160,18 +170,7 @@ public abstract class FlowableManager {
|
||||
throw new IllegalArgumentException("权限校验不通过");
|
||||
}
|
||||
|
||||
String handlerClass = node.getHandler();
|
||||
if (StringHelper.isBlank(handlerClass)) {
|
||||
throw new IllegalArgumentException("节点执行器为空");
|
||||
}
|
||||
FlowableHandler handler = createBean(handlerClass);
|
||||
action = handler.handle(configuration, instance, node, action);
|
||||
if (Objects.isNull(action)) {
|
||||
throw new IllegalArgumentException("节点执行结果不能为空");
|
||||
}
|
||||
|
||||
FlowableAction tempAction = action;
|
||||
callListeners(node.getListeners(), listener -> listener.onAction(instance, tempAction));
|
||||
callListeners(node.getListeners(), listener -> listener.onAction(instance, node, action));
|
||||
|
||||
// 如果是挂起操作,就直接返回,不做操作
|
||||
if (FlowableAction.SUSPEND.equals(action)) {
|
||||
@@ -187,7 +186,7 @@ public abstract class FlowableManager {
|
||||
|| !node.getTargets().containsKey(action)
|
||||
|| StringHelper.isBlank(node.getTargets().get(action))) {
|
||||
saveInstance(instance, FlowableInstance.Status.COMPLETED, action, comment);
|
||||
callListeners(node.getListeners(), listener -> listener.onFlowEnd(instance, node));
|
||||
callListeners(node.getListeners(), listener -> listener.onFlowEnd(instance, node, action));
|
||||
return;
|
||||
}
|
||||
String nextNodeId = node.getTargets().get(action);
|
||||
@@ -195,7 +194,7 @@ public abstract class FlowableManager {
|
||||
instance.setCurrentNodeId(nextNode.getNodeId());
|
||||
saveInstance(instance, FlowableInstance.Status.RUNNING, action, comment);
|
||||
|
||||
callListeners(node.getListeners(), listener -> listener.onActionComplete(instance, node));
|
||||
callListeners(node.getListeners(), listener -> listener.onActionComplete(instance, node, action));
|
||||
if (FlowableNode.Type.AUTOMATIC.equals(nextNode.getType())) {
|
||||
automaticAction(instance, node);
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ package com.lanyuanxiaoyao.flowable.core.model;
|
||||
public interface FlowableListener {
|
||||
void onFlowStart(FlowableInstance instance, FlowableNode node);
|
||||
|
||||
void onFlowEnd(FlowableInstance instance, FlowableNode node);
|
||||
void onFlowEnd(FlowableInstance instance, FlowableNode node, FlowableAction action);
|
||||
|
||||
void onActionStart(FlowableInstance instance, FlowableNode node);
|
||||
void onActionStart(FlowableInstance instance, FlowableNode node, FlowableAction action);
|
||||
|
||||
void onAction(FlowableInstance instance, FlowableAction action);
|
||||
void onAction(FlowableInstance instance, FlowableNode node, FlowableAction action);
|
||||
|
||||
void onActionComplete(FlowableInstance instance, FlowableNode node);
|
||||
void onActionComplete(FlowableInstance instance, FlowableNode node, FlowableAction action);
|
||||
}
|
||||
|
||||
@@ -18,22 +18,22 @@ public class SimpleListener implements FlowableListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFlowEnd(FlowableInstance instance, FlowableNode node) {
|
||||
public void onFlowEnd(FlowableInstance instance, FlowableNode node, FlowableAction action) {
|
||||
log.info("onFlowEnd");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionStart(FlowableInstance instance, FlowableNode node) {
|
||||
public void onActionStart(FlowableInstance instance, FlowableNode node, FlowableAction action) {
|
||||
log.info("onActionStart");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAction(FlowableInstance instance, FlowableAction action) {
|
||||
public void onAction(FlowableInstance instance, FlowableNode node, FlowableAction action) {
|
||||
log.info("onAction");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionComplete(FlowableInstance instance, FlowableNode node) {
|
||||
public void onActionComplete(FlowableInstance instance, FlowableNode node, FlowableAction action) {
|
||||
log.info("onActionComplete");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user