AnsweredAssumed Answered

Process Parsing to add task listeners

Question asked by mprakash on Jun 19, 2017
Latest reply on Jun 20, 2017 by mprakash

I am trying to hook into process parsing to add task listeners to all tasks. I tried the following config:

 

     <bean id="processEngineConfiguration"
          class="org.activiti.engine.impl.cfg.StandaloneInMemProcessEngineConfiguration">

             ...
          <property name="postBpmnParseHandlers">
               <list>
                    <bean class="xxx.yyy.DecorateTask" />
               </list>
          </property>
     </bean>

Where the code for DecorateTask is:

public class DecorateTask extends AbstractBpmnParseHandler<UserTask> {

     // private List<ActivitiListener> listeners = new ArrayList<>();
     private String logfile = "logger.txt";
     FileWriter log;

     public  DecorateTask() {
          try {
               log = new FileWriter(logfile, true);
               log.write("Initialising Devorator\n");
          } catch (IOException e) {
               e.printStackTrace();
          }
     }
     @Override
     protected Class getHandledType() {
          return UserTask.class;
     }

     @Override
     protected void executeParse(BpmnParse bpmnParse, UserTask element) {
          try {
               log.write(" >> " + element.getClass().getName() + "\n");
          } catch (IOException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
          }
     }

}

However, the class is not even being instantiated, as I see no entries in the output file. Ideally, I want to intercept all tasks to emit events for internal logging purposes, but I tried to use BaseElement instead of UserTask, and that did not work either.

Any clues how to make it work will be greatly appreciated.

Thanks,

  Mayank.

Outcomes