AnsweredAssumed Answered

Differences About Parse Listeners b/w 5.11 and 5.12

Question asked by gokceng1 on Mar 20, 2013
Latest reply on Mar 22, 2013 by frederikheremans1
Hi,
I was using 5.11 till today and I was implementing my parse listeners that way:

public class ActivitiParseListener extends AbstractBpmnParseListener {
   private ExecutionListener executionListener;

   public ActivitiParseListener(ExecutionListener executionListener) {
      this.executionListener = executionListener;
   }

   @Override
   public void parseCallActivity(Element callActivityElement, ScopeImpl scope, ActivityImpl activity) {
      activity.addExecutionListener(ExecutionListener.EVENTNAME_START, executionListener);
   }
}

with that conf:

<bean id="unittestProcessEngineConfiguration" parent="mailDisabledProcessEngineConfiguration">
      <property name="customDefaultBpmnParseHandlers">
         <list>
            <bean class="….demo.utils.ActivitiParseListener">
               <constructor-arg name="activitiExecutionListener" ref="activitiExecutionListener"/>
            </bean>
         </list>
      </property>
   </bean>

Today I've migrated project to 5.12 and changed the code like that:

public class ActivitiParseListener implements BpmnParseHandler {
   //ActivitiExecutionListener is my class
   private ActivitiExecutionListener activitiExecutionListener;

   public ActivitiParseListener(ActivitiExecutionListener activitiExecutionListener) {
      this.activitiExecutionListener = activitiExecutionListener;
   }

   @Override
   public Collection<Class<? extends BaseElement>> getHandledTypes() {
      List<Class<? extends BaseElement>> classList = new ArrayList<Class<? extends BaseElement>>();
      classList.add(CallActivity.class);
      return classList;
   }

   @Override
   public void parse(BpmnParse bpmnParse, BaseElement element) {
      bpmnParse.setListenerFactory(new SomListenerFactory(activitiExecutionListener));
   }

where SomListenerFactory is:
public class SomListenerFactory extends DefaultListenerFactory {
   //ActivitiExecutionListener is my class
   private ActivitiExecutionListener activitiExecutionListener;

   public SomListenerFactory(ActivitiExecutionListener activitiExecutionListener) {
      this.activitiExecutionListener = activitiExecutionListener;
   }

   @Override
   public ExecutionListener createDelegateExpressionExecutionListener(ActivitiListener activitiListener) {
      return activitiExecutionListener;
   }
}

with conf :

<bean id="unittestProcessEngineConfiguration" parent="mailDisabledProcessEngineConfiguration">
      <property name="customDefaultBpmnParseHandlers">
         <list>
            <bean class="….demo.utils.ActivitiParseListener">
               <constructor-arg name="activitiExecutionListener" ref="activitiExecutionListener"/>
            </bean>
         </list>
      </property>
   </bean>

Is this correct way of doing it? Also I couldn't understand the use of classes under org.activiti.engine.impl.bpmn.listener and org.activiti.engine.impl.bpmn.parser. Are they intended to be used by us, or are they just internal classes?

Outcomes