Project address: The activiti-workflow
class implements TaskListener and uses the @Service annotation to ensure that this class can be automatically scanned by Spring.
@Service("taskExpressionService")
public class TaskExpressionService implements TaskListener {
@Autowired
private UserServiceImpl userService;
@Override
public void notify(DelegateTask delegateExecution) {
String eventName = delegateExecution.getEventName();
if ("create".endsWith(eventName)) {
System.out.println("create=========");
}else if ("assignment".endsWith(eventName)) {
System.out.println("assignment========"+delegateExecution.getAssignee());
}else if ("complete".endsWith(eventName)) {
System.out.println("complete===========");
}else if ("delete".endsWith(eventName)) {
System.out.println("delete=============");
}
}
}
This configuration in the link can inject Spring beans.