cancel
Showing results for 
Search instead for 
Did you mean: 

Manipulating BPMNs programmatically prior to deployment

ronif
Champ in-the-making
Champ in-the-making
Hi,
I have a bytestream of BPMN and i'm looking to add an activiti listener on the end event just prior to deployment.
Is there any API of activiti I can use to add such listener to the process? Perhaps one that parses the BPMN to a POJO I can then traverse and manipulate by adding elements just before deployment?

Thanks.
4 REPLIES 4

ronif
Champ in-the-making
Champ in-the-making
Figured it out:

public class ProcessWithEndEventParseListener extends ProcessParseHandler {
@Override
protected void executeParse(BpmnParse bpmnParse, org.activiti.bpmn.model.Process process) {
  ActivitiListener endEventListener = new ActivitiListener();
  endEventListener.setEvent(ExecutionListener.EVENTNAME_END);
  endEventListener.setImplementation(MyEndEventExecutionListener.class.getName());
  endEventListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_CLASS);
  process.setExecutionListeners(Lists.newArrayList(endEventListener));
}
}

worked like a charm Smiley Happy

frederikherema1
Star Contributor
Star Contributor
That's indeed the way we recommend doing such things to process definitions prior to deploying it for usage by the engine.

blezek
Champ on-the-rise
Champ on-the-rise
How is ProcessWithEndEventParseListener attached?  Do you set a CustomDefault or some other means?

<java>
    SpringProcessEngineConfiguration configuration = new SpringProcessEngineConfiguration();
    configuration.getCustomDefaultBpmnParseHandlers().add(new ProcessWithEndEventParseListener());
</java>

trademak
Star Contributor
Star Contributor
getPostBpmnParseHandlers() would be the default method to use for this use case.