cancel
Showing results for 
Search instead for 
Did you mean: 

Extending BPMN 2.0 Activities

gokceng1
Champ in-the-making
Champ in-the-making
Hey,
I've searched and found some links about extending tasks(call activities, gateways etc) but they are very old, about Activiti 5.0. I want to extend process -but my question is about general situation-.
Which way do you suggest me to go?
There are 'customDefaultBpmnParseHandlers', but I think I need to create preBpmnParseHandlers. Though I don't know how to register them to processEngine.
3 REPLIES 3

frederikherema1
Star Contributor
Star Contributor
As of activiti 5.12, there is a ActivityBehaviourFactory, which creates instances of the right ActivityBehaviours used for all the BPMN-constructs that are present in your XML-file.

Javadoc says it all. You can extend the org.activiti.engine.impl.bpmn.parser.factory.DefaultActivityBehaviorFactory class and implement the methods you want to have custom ActivityBehaviours for.


/**
* Factory class used by the {@link BpmnParser} and {@link BpmnParse} to instantiate
* the behaviour classes. For example when parsing an exclusive gateway, this factory
* will be requested to create a new {@link ActivityBehavior} that will be set on the
* {@link ActivityImpl} of that step of the process and will implement the spec-compliant
* behavior of the exclusive gateway.
*
* You can provide your own implementation of this class. This way, you can give
* different execution semantics to a standard bpmn xml construct. Eg. you could
* tweak the exclusive gateway to do something completely different if you would want that.
* Creating your own {@link ActivityBehaviorFactory} is only advisable if you
* want to change the default behavior of any BPMN default construct.
* And even then, think twice, because it won't be spec compliant bpmn anymore.
*
* Note that you can always express any custom step as a service task with a class delegation.
*
* The easiest and advisable way to implement your own {@link ActivityBehaviorFactory}
* is to extend the {@link DefaultActivityBehaviorFactory} class and override
* the method specific to the {@link ActivityBehavior} you want to change.
*
* An instance of this interface can be injected in the {@link ProcessEngineConfigurationImpl}
* and its subclasses.
*
* @author Joram Barrez
*/
public interface ActivityBehaviorFactory {

Hi Frederic
I am interested in the customization of ScriptTask behaviorand I would like to understand how I can integrate the extended DefaultActivityBehaviorFactory class in a standalone mode. Currently I setup the process engine configuration by doing:

ProcessEngineConfiguration conf = QAProcessEngineConfiguration.createStandaloneProcessEngineConfiguration();
   conf.setDatabaseType("mysql");
   conf.setJdbcDriver("com.mysql.jdbc.Driver");
   conf.setJdbcUrl("jdbc:mysql://localhost/activiti");
   conf.setJdbcUsername("test");
   conf.setJdbcPassword("test");
   conf.setMailServerHost("smtp.gmail.com");
   conf.setMailServerPort(587);
   conf.setMailServerUsername("xxxx@gmail.com");
   conf.setMailServerPassword("xxxx");
   conf.setMailServerUseTLS(true);
   conf.buildProcessEngine();

Can you give an example how doing that?
Thank's
JP

gokceng1
Champ in-the-making
Champ in-the-making
Thank you frederik, I'll take a look at it.