Search in sources :

Example 1 with ActivitiEventListener

use of org.activiti.engine.delegate.event.ActivitiEventListener in project Activiti by Activiti.

the class DelegateExpressionActivitiEventListener method onEvent.

@Override
public void onEvent(ActivitiEvent event) {
    if (isValidEvent(event)) {
        Object delegate = DelegateExpressionUtil.resolveDelegateExpression(expression, new NoExecutionVariableScope());
        if (delegate instanceof ActivitiEventListener) {
            // Cache result of isFailOnException() from delegate-instance until next
            // event is received. This prevents us from having to resolve the expression twice when
            // an error occurs.
            failOnException = ((ActivitiEventListener) delegate).isFailOnException();
            // Call the delegate
            ((ActivitiEventListener) delegate).onEvent(event);
        } else {
            // Force failing, since the exception we're about to throw cannot be ignored, because it
            // did not originate from the listener itself
            failOnException = true;
            throw new ActivitiIllegalArgumentException("Delegate expression " + expression + " did not resolve to an implementation of " + ActivitiEventListener.class.getName());
        }
    }
}
Also used : ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) NoExecutionVariableScope(org.activiti.engine.impl.el.NoExecutionVariableScope) ActivitiEventListener(org.activiti.engine.delegate.event.ActivitiEventListener)

Aggregations

ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)1 ActivitiEventListener (org.activiti.engine.delegate.event.ActivitiEventListener)1 NoExecutionVariableScope (org.activiti.engine.impl.el.NoExecutionVariableScope)1