cancel
Showing results for 
Search instead for 
Did you mean: 

How to add a TaskListener use BpmnParseHandler

kafeitu
Champ on-the-rise
Champ on-the-rise
I want to add a TaskListener dynamically in class that implements BpmnParseHandler, can you show me the example code ?
1 REPLY 1

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Henry,

One example can be found in the activiti tests org.activiti.standalone.parsing.BPMNParseHandlerTest.
Adding task listener is similar:


public class MailNotificationUserTaskParseHandler extends UserTaskParseHandler {

  @Override
  protected void executeParse(BpmnParse bpmnParse, UserTask userTask) {
   super.executeParse(bpmnParse, userTask);

      ActivityImpl activity = findActivity(bpmnParse, userTask.getId());
      UserTaskActivityBehavior userTaskActivityBehavior = (UserTaskActivityBehavior) activity.getActivityBehavior();
      userTaskActivityBehavior.getTaskDefinition().addTaskListener(TaskListener.EVENTNAME_ASSIGNMENT, new MailNotificationTaskListener());
  }

}

Regards
Martin