Search in sources :

Example 1 with TransactionDependentTaskListener

use of org.activiti.engine.delegate.TransactionDependentTaskListener in project Activiti by Activiti.

the class DelegateExpressionTransactionDependentTaskListener method notify.

@Override
public void notify(String processInstanceId, String executionId, Task task, Map<String, Object> executionVariables, Map<String, Object> customPropertiesMap) {
    NoExecutionVariableScope scope = new NoExecutionVariableScope();
    Object delegate = expression.getValue(scope);
    if (delegate instanceof TransactionDependentTaskListener) {
        ((TransactionDependentTaskListener) delegate).notify(processInstanceId, executionId, task, executionVariables, customPropertiesMap);
    } else {
        throw new ActivitiIllegalArgumentException("Delegate expression " + expression + " did not resolve to an implementation of " + TransactionDependentTaskListener.class);
    }
}
Also used : TransactionDependentTaskListener(org.activiti.engine.delegate.TransactionDependentTaskListener) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) NoExecutionVariableScope(org.activiti.engine.impl.el.NoExecutionVariableScope)

Example 2 with TransactionDependentTaskListener

use of org.activiti.engine.delegate.TransactionDependentTaskListener in project Activiti by Activiti.

the class ListenerNotificationHelper method executeTaskListeners.

public void executeTaskListeners(UserTask userTask, TaskEntity taskEntity, String eventType) {
    for (ActivitiListener activitiListener : userTask.getTaskListeners()) {
        String event = activitiListener.getEvent();
        if (event.equals(eventType) || event.equals(TaskListener.EVENTNAME_ALL_EVENTS)) {
            BaseTaskListener taskListener = createTaskListener(activitiListener);
            if (activitiListener.getOnTransaction() != null) {
                planTransactionDependentTaskListener(taskEntity.getExecution(), (TransactionDependentTaskListener) taskListener, activitiListener);
            } else {
                taskEntity.setEventName(eventType);
                taskEntity.setCurrentActivitiListener(activitiListener);
                try {
                    Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(new TaskListenerInvocation((TaskListener) taskListener, taskEntity));
                } catch (Exception e) {
                    throw new ActivitiException("Exception while invoking TaskListener: " + e.getMessage(), e);
                } finally {
                    taskEntity.setEventName(null);
                    taskEntity.setCurrentActivitiListener(null);
                }
            }
        }
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) TaskListenerInvocation(org.activiti.engine.impl.delegate.invocation.TaskListenerInvocation) BaseTaskListener(org.activiti.engine.delegate.BaseTaskListener) BaseTaskListener(org.activiti.engine.delegate.BaseTaskListener) TaskListener(org.activiti.engine.delegate.TaskListener) TransactionDependentTaskListener(org.activiti.engine.delegate.TransactionDependentTaskListener) ActivitiListener(org.activiti.bpmn.model.ActivitiListener) ActivitiException(org.activiti.engine.ActivitiException)

Aggregations

TransactionDependentTaskListener (org.activiti.engine.delegate.TransactionDependentTaskListener)2 ActivitiListener (org.activiti.bpmn.model.ActivitiListener)1 ActivitiException (org.activiti.engine.ActivitiException)1 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)1 BaseTaskListener (org.activiti.engine.delegate.BaseTaskListener)1 TaskListener (org.activiti.engine.delegate.TaskListener)1 TaskListenerInvocation (org.activiti.engine.impl.delegate.invocation.TaskListenerInvocation)1 NoExecutionVariableScope (org.activiti.engine.impl.el.NoExecutionVariableScope)1