Search in sources :

Example 1 with JavaDelegate

use of org.camunda.bpm.engine.delegate.JavaDelegate in project camunda-bpm-platform by camunda.

the class ServiceTaskDelegateExpressionActivityBehavior method performExecution.

@Override
public void performExecution(final ActivityExecution execution) throws Exception {
    Callable<Void> callable = new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            // Note: we can't cache the result of the expression, because the
            // execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}'
            Object delegate = expression.getValue(execution);
            applyFieldDeclaration(fieldDeclarations, delegate);
            if (delegate instanceof ActivityBehavior) {
                Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(new ActivityBehaviorInvocation((ActivityBehavior) delegate, execution));
            } else if (delegate instanceof JavaDelegate) {
                Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(new JavaDelegateInvocation((JavaDelegate) delegate, execution));
                leave(execution);
            } else {
                throw LOG.resolveDelegateExpressionException(expression, ActivityBehavior.class, JavaDelegate.class);
            }
            return null;
        }
    };
    executeWithErrorPropagation(execution, callable);
}
Also used : JavaDelegateInvocation(org.camunda.bpm.engine.impl.bpmn.delegate.JavaDelegateInvocation) SignallableActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.SignallableActivityBehavior) ActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior) ActivityBehaviorInvocation(org.camunda.bpm.engine.impl.bpmn.delegate.ActivityBehaviorInvocation) Callable(java.util.concurrent.Callable) JavaDelegate(org.camunda.bpm.engine.delegate.JavaDelegate)

Example 2 with JavaDelegate

use of org.camunda.bpm.engine.delegate.JavaDelegate in project camunda-bpm-platform by camunda.

the class DelegateExpressionExecutionListener method notify.

public void notify(DelegateExecution execution) throws Exception {
    // Note: we can't cache the result of the expression, because the
    // execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}'
    Object delegate = expression.getValue(execution);
    applyFieldDeclaration(fieldDeclarations, delegate);
    if (delegate instanceof ExecutionListener) {
        Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(new ExecutionListenerInvocation((ExecutionListener) delegate, execution));
    } else if (delegate instanceof JavaDelegate) {
        Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(new JavaDelegateInvocation((JavaDelegate) delegate, execution));
    } else {
        throw LOG.resolveDelegateExpressionException(expression, ExecutionListener.class, JavaDelegate.class);
    }
}
Also used : JavaDelegateInvocation(org.camunda.bpm.engine.impl.bpmn.delegate.JavaDelegateInvocation) ExecutionListenerInvocation(org.camunda.bpm.engine.impl.bpmn.delegate.ExecutionListenerInvocation) JavaDelegate(org.camunda.bpm.engine.delegate.JavaDelegate) ExecutionListener(org.camunda.bpm.engine.delegate.ExecutionListener)

Aggregations

JavaDelegate (org.camunda.bpm.engine.delegate.JavaDelegate)2 JavaDelegateInvocation (org.camunda.bpm.engine.impl.bpmn.delegate.JavaDelegateInvocation)2 Callable (java.util.concurrent.Callable)1 ExecutionListener (org.camunda.bpm.engine.delegate.ExecutionListener)1 ActivityBehaviorInvocation (org.camunda.bpm.engine.impl.bpmn.delegate.ActivityBehaviorInvocation)1 ExecutionListenerInvocation (org.camunda.bpm.engine.impl.bpmn.delegate.ExecutionListenerInvocation)1 ActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior)1 SignallableActivityBehavior (org.camunda.bpm.engine.impl.pvm.delegate.SignallableActivityBehavior)1