cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass extra parameters as a part of the properties set for activiti components?

himangshu_chowd
Champ in-the-making
Champ in-the-making
I have a requirement wherein I need to pass extra parameters,eg-serverName,serverId,etc.. along with the properties of the activiti components and parse them to get their values in the POJO classes(ExecutionListeners/TaskListeners,etc).

Please suggest how do I achieve it and also is there any API which I can leverage rather than parsing the XML directly to get hold of these extra parameters that I am passing along with the default component properties.
5 REPLIES 5

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

use extension elements:
http://activiti.org/userguide/index.html#bpmnCustomExtensions

e.g. (how activiti is using extensions)

<userTask id="theTask" name="make profit">
  <extensionElements>
    <activiti:customResource activiti:name="businessAdministrator">
      <resourceAssignmentExpression>
        <formalExpression>user(kermit), group(management)</formalExpression>
      </resourceAssignmentExpression>
    </activiti:customResource>
  </extensionElements>
</userTask>

extension elements are parsed into the BPMN model in memory so you can easily access them in runtime.

Regards
Martin

Hi Martin,

I donot see a property titled "extensionElements" for any of the components in the Activiti modeler.
Also is there an API to access the values set using these extensions or we need to directly parse it from the BPMN2.0 xml?

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

Also is there an API to access the values set using these extensions or we need to directly parse it from the BPMN2.0 xml?

extension elements are stored in org.activiti.bpmn.model.BaseElement#extensionElementsafter that you can get this extension elements in e.g. org.activiti.engine.impl.bpmn.parser.handler.ServiceTaskParseHandler#executeParse(serviceTask has extension elements in)

I donot see a property titled "extensionElements" for any of the components in the Activiti modeler.
I do not know whether editor supports extensionElements. But it should be possible to add them (we did it in our product).

Regards
Martin

Ok so please have a look at the code below and advise me if I'm going wrong.

   public void execute(DelegateExecution execution) throws Exception {
    this.delegateExecution=execution;
   
          BpmnParser bpmnParser= new BpmnParser();
          BpmnParse bpmnParse= new BpmnParse(bpmnParser);
          BaseElement bE=null;
          new BaseElement() {
   
    @Override
    public BaseElement clone() {
    
     return bE.clone();
    }
   };
  
          ServiceTaskParseHandler s=new ServiceTaskParseHandler();
          s.parse(bpmnParse, bE);
   
 
   }

This executionListener is bound to a ServiceTask in the modeler. Now are you saying that if somehow I'm able to add the extension elements to the components then this is the way to parse it??
If not please correct my understanding.

jbarrez
Star Contributor
Star Contributor
No … this is totally not the way to go in a service task. Unless I'm missing the question here.

Get the BpmnModel for your process definition. get the particular ServiceTask, then get the extension elements.