任务监听器

  1. @Component
  2. public class MyTaskListener implements TaskListener {
  3. private static final long serialVersionUID = 9213309167936632864L;
  4. protected static Logger logger = LoggerFactory.getLogger(TaskListener.class);
  5. @Override
  6. public void notify(DelegateTask delegateTask) {
  7. String taskDefKey = delegateTask.getTaskDefinitionKey();
  8. Date createTime = delegateTask.getCreateTime();
  9. String name = delegateTask.getName();
  10. String eventName = delegateTask.getEventName();
  11. String assignee = delegateTask.getAssignee();
  12. Set<IdentityLink> candidates = delegateTask.getCandidates();
  13. logger.info("演示任务相关信息===========================================================");
  14. logger.info("任务Key:{}", taskDefKey);
  15. logger.info("任务Name:{}", name);
  16. logger.info("任务createTime:{}", createTime);
  17. logger.info("任务assignee:{}", assignee);
  18. logger.info("任务candidates:{}", candidates);
  19. logger.error("演示事件执行顺序===========================================================");
  20. if ("create".endsWith(eventName)) {
  21. logger.info("创建:create=========");
  22. } else if ("assignment".endsWith(eventName)) {
  23. logger.info("指派:assignment========");
  24. } else if ("complete".endsWith(eventName)) {
  25. logger.info("完成:complete===========");
  26. } else if ("delete".endsWith(eventName)) {
  27. logger.info("销毁:delete=============");
  28. }
  29. }

执行监听器

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}");
    }
}