Hello,
Firstly, thanks for Flowable (before Activiti), its awesome!
I am trying to figure out how to skip an Activity Behavior, based on some condition without overriding ActivityBehaviorFactory and writing custom behaviors or using implementation specific classes.
For example I have to skip a timer. Please guide me if the following Execution listener implementation will do the trick.
Execution Listener is set for the timer to invoke on ExecutionListener.EVENTNAME_START
package example;
import org.flowable.bpmn.model.FlowNode;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.DelegateHelper;
import org.flowable.engine.delegate.ExecutionListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class IntermediateCatchEventExecutionListener implements ExecutionListener {
private static final Logger LOG = LoggerFactory.getLogger(IntermediateCatchEventExecutionListener.class);
public void notify(DelegateExecution execution) {
// This is figured out by some external data store
if (execution.hasVariable("THIS_STEP_ALREADY_HAPPENED")) {
LOG.info("IntermediateCatchEvent Execution listener " + execution.getCurrentActivityId() + " is going to fire");
LOG.info("Skipping the timer behavior for " + execution.getCurrentActivityId());
if (execution.getCurrentFlowElement() instanceof FlowNode) {
// Set as Noop Behavior or null
((FlowNode) execution.getCurrentFlowElement()).setBehavior(null);
}
DelegateHelper.leaveDelegate(execution);
}
}
}
Thanks,
Harsha