AnsweredAssumed Answered

serviceTask field types

Question asked by h.ter.schuur on Feb 28, 2011
Latest reply on Mar 1, 2011 by jbarrez
I am looking for a possibility to implement a serviceTask which should be able to create objects with arbitrary properties. I would like to have these properties injected as Map into my serviceTask expression.

For example I want to define this in my process definition like:
<serviceTask id="javaService" name="Java service invocation" activiti:class="org.activiti.examples.bpmn.servicetask.CreateObject">
  <activiti:field name="objectType" stringValue="dummy"/>
  <activiti:field name="properties">
    <activiti:map>
      <activiti:entry key="key0"><activiti:string>Hello World</activiti:string></activiti:entry>
      <activiti:entry key="key1"><activiti:expression>Hello ${gender == 'male' ? 'Mr.' : 'Mrs.'} ${name}</activiti:expression></activiti:entry>
    </activiti:map>
  </activiti:field>
</serviceTask>

My service task implementation would be like this:

public class CreateObject implements JavaDelegate {
  …
  private Expression objectType;
  private Expression properties;

  public void execute(DelegateExecution execution) {
    String type = (String) objectType.getValue(execution);
    Map props = (Map)properties.getValue(execution);

    myRepository.addNode(type, props);
  }
}


As far as I know, currently only activiti:string and activiti:expression are supported. Are there any plans for supporting such a serviceTask field type.
Or should I use a different implementation strategy?

Outcomes