任务监听器
@Component
public class MyTaskListener implements TaskListener {
private static final long serialVersionUID = 9213309167936632864L;
protected static Logger logger = LoggerFactory.getLogger(TaskListener.class);
@Override
public void notify(DelegateTask delegateTask) {
String taskDefKey = delegateTask.getTaskDefinitionKey();
Date createTime = delegateTask.getCreateTime();
String name = delegateTask.getName();
String eventName = delegateTask.getEventName();
String assignee = delegateTask.getAssignee();
Set<IdentityLink> candidates = delegateTask.getCandidates();
logger.info("演示任务相关信息===========================================================");
logger.info("任务Key:{}", taskDefKey);
logger.info("任务Name:{}", name);
logger.info("任务createTime:{}", createTime);
logger.info("任务assignee:{}", assignee);
logger.info("任务candidates:{}", candidates);
logger.error("演示事件执行顺序===========================================================");
if ("create".endsWith(eventName)) {
logger.info("创建:create=========");
} else if ("assignment".endsWith(eventName)) {
logger.info("指派:assignment========");
} else if ("complete".endsWith(eventName)) {
logger.info("完成:complete===========");
} else if ("delete".endsWith(eventName)) {
logger.info("销毁:delete=============");
}
}
执行监听器
public class UserTaskSkipListener implements ExecutionListener {
private static final long serialVersionUID = -5669900748456795940L;
@Override
public void notify(DelegateExecution execution) {
UserTask userTask = (UserTask) execution.getCurrentFlowElement();
userTask.setSkipExpression("${1==1}");
}
}