AnsweredAssumed Answered

Adding custom functions to ExpressionManager

Question asked by zeroflag on Jul 20, 2017
Latest reply on Jul 20, 2017 by zeroflag

I would like to create a list inside an activiti expression like in the following example:


<serviceTask activiti:class="com.example.workflow.servicetask.Foo" activiti:exclusive="true" id="foo" >
  <activiti:field expression="${list:of(host1, host2, host3)}" name="hosts"/>


This seems to be not supported by default, but JUEL (the unified expression language implementation used by Activiti) provides some methods for adding custom functions.


In the debugger I was able to come up with some code that could evaluate a list expression:


org.activiti.engine.impl.juel.SimpleContext c = new org.activiti.engine.impl.juel.SimpleContext();
c.setFunction("list", "of", Arrays.class.getMethod("asList", Object[].class));

.createValueExpression(c, "${list:of(host1, host2)}", Object.class)
.getValue(((ExecutionEntity) activityExecution).cachedElContext)


How can I configure Activiti to use custom functions like this?