CMMN delegate - get field expression


We have a custom expression manager that evaluates expressions defined in the bpmn process using ejb’s. As you may know, when you ask the container to give you a reference to the class, it returns a proxy of that class. We apply this behavior when resolving ServiceTasks, TaskListeners, ExecutionListeners and EventListers implementation at runtime.

Because our implementation returns a proxy of that class, Flowable cannot automatically inject expressions in the class since it cannot find the fields or setters using reflection.
To resolve this issue, we use org.flowable.engine.delegate.DelegateHelper to fetch the field expression when the bean is actually being executed, like for example:

<process id="process" name="My process" isExecutable="true">
    <startEvent id="startNoneEvent1" flowable:initiator="initiator" flowable:formFieldValidation="false"/>
    <sequenceFlow id="sequenceFlow2" sourceRef="startNoneEvent1" targetRef="serviceTask1"/>
    <serviceTask id="serviceTask1" name="Service task" flowable:delegateExpression="${myServiceTaskBean}">
        <flowable:field name="event">
    <endEvent id="endNoneEvent2"/>
    <sequenceFlow id="sequenceFlow3" sourceRef="serviceTask1" targetRef="endNoneEvent2"/>
@Stateless(name = "myServiceTaskBean")
public class MyServiceTask implements JavaDelegate {
    public void execute(DelegateExecution execution) {
        String event = (String) DelegateHelper.getFieldExpression(execution, "event").getValue(execution);
       // event = "CALL_SOMETHING";

This works fine and hasn’t given us problems.

Now we’re starting to use CMMN and a new problem arises: how do we do we apply this type of behavior for the CMMN context, more specifically using org.flowable.cmmn.api.delegate.DelegatePlanItemInstance ? The DelegateHelper only has methods working with org.flowable.engine.delegate.DelegateExecution and org.flowable.task.service.delegate.DelegateTask.

Do you know if there is any other helper class to achive what we need?

Well spotted. The CMMN counterpart for the DelegateHelper was indeed not added to the CMMN engine yet. It is now:

You can copy the CmmnDelegateHelper class in your projects as-is (as they are static methods) and remove it with the next release.

1 Like