Search in sources :

Example 1 with TaskListenerInvocation

use of org.camunda.bpm.engine.impl.task.delegate.TaskListenerInvocation in project camunda-bpm-platform by camunda.

the class DelegateExpressionTaskListener method notify.

public void notify(DelegateTask delegateTask) {
    // Note: we can't cache the result of the expression, because the
    // execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}'
    VariableScope variableScope = delegateTask.getExecution();
    if (variableScope == null) {
        variableScope = delegateTask.getCaseExecution();
    }
    Object delegate = expression.getValue(variableScope);
    applyFieldDeclaration(fieldDeclarations, delegate);
    if (delegate instanceof TaskListener) {
        try {
            Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(new TaskListenerInvocation((TaskListener) delegate, delegateTask));
        } catch (Exception e) {
            throw new ProcessEngineException("Exception while invoking TaskListener: " + e.getMessage(), e);
        }
    } else {
        throw new ProcessEngineException("Delegate expression " + expression + " did not resolve to an implementation of " + TaskListener.class);
    }
}
Also used : TaskListenerInvocation(org.camunda.bpm.engine.impl.task.delegate.TaskListenerInvocation) TaskListener(org.camunda.bpm.engine.delegate.TaskListener) VariableScope(org.camunda.bpm.engine.delegate.VariableScope) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 2 with TaskListenerInvocation

use of org.camunda.bpm.engine.impl.task.delegate.TaskListenerInvocation in project camunda-bpm-platform by camunda.

the class TaskEntity method fireEvent.

public void fireEvent(String taskEventName) {
    List<TaskListener> taskEventListeners = getListenersForEvent(taskEventName);
    if (taskEventListeners != null) {
        for (TaskListener taskListener : taskEventListeners) {
            CoreExecution execution = getExecution();
            if (execution == null) {
                execution = getCaseExecution();
            }
            if (execution != null) {
                setEventName(taskEventName);
            }
            try {
                TaskListenerInvocation listenerInvocation = new TaskListenerInvocation(taskListener, this, execution);
                Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(listenerInvocation);
            } catch (Exception e) {
                throw LOG.invokeTaskListenerException(e);
            }
        }
    }
}
Also used : CoreExecution(org.camunda.bpm.engine.impl.core.instance.CoreExecution) TaskListenerInvocation(org.camunda.bpm.engine.impl.task.delegate.TaskListenerInvocation) TaskListener(org.camunda.bpm.engine.delegate.TaskListener) NullValueException(org.camunda.bpm.engine.exception.NullValueException)

Aggregations

TaskListener (org.camunda.bpm.engine.delegate.TaskListener)2 TaskListenerInvocation (org.camunda.bpm.engine.impl.task.delegate.TaskListenerInvocation)2 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)1 VariableScope (org.camunda.bpm.engine.delegate.VariableScope)1 NullValueException (org.camunda.bpm.engine.exception.NullValueException)1 CoreExecution (org.camunda.bpm.engine.impl.core.instance.CoreExecution)1