use of org.kie.api.task.TaskLifeCycleEventListener in project jbpm by kiegroup.
the class HTWorkItemHandlerBaseTest method testTaskCreateFailedWithRethrow.
@SuppressWarnings("unchecked")
@Test
public void testTaskCreateFailedWithRethrow() throws Exception {
TestWorkItemManager manager = new TestWorkItemManager();
TaskLifeCycleEventListener listener = new AddedTaskListener(true);
((EventService<TaskLifeCycleEventListener>) taskService).registerTaskEventListener(listener);
((AbstractHTWorkItemHandler) handler).setAction(OnErrorAction.RETHROW);
ksession.setWorkItemManager(manager);
WorkItemImpl workItem = new WorkItemImpl();
workItem.setName("Human Task");
workItem.setParameter("NodeName", "TaskName");
workItem.setParameter("Comment", "Comment");
workItem.setParameter("Priority", "10");
workItem.setParameter("ActorId", "DoesNotExist");
workItem.setProcessInstanceId(10);
try {
handler.executeWorkItem(workItem, manager);
fail("Should fail due to OnErroAction set to rethrow");
} catch (Exception e) {
// do nothing
}
((EventService<TaskLifeCycleEventListener>) taskService).removeTaskEventListener(listener);
}
use of org.kie.api.task.TaskLifeCycleEventListener in project jbpm by kiegroup.
the class HumanTaskConfigurator method getTaskService.
@SuppressWarnings("unchecked")
public TaskService getTaskService() {
if (service == null) {
TaskEventSupport taskEventSupport = new TaskEventSupport();
this.commandExecutor = new TaskCommandExecutorImpl(this.environment, taskEventSupport);
if (userGroupCallback == null) {
userGroupCallback = new MvelUserGroupCallbackImpl(true);
}
environment.set(EnvironmentName.TASK_USER_GROUP_CALLBACK, userGroupCallback);
if (userInfo == null) {
userInfo = new DefaultUserInfo(true);
}
environment.set(EnvironmentName.TASK_USER_INFO, userInfo);
addDefaultInterceptor();
addTransactionLockInterceptor();
addOptimisticLockInterceptor();
addErrorHandlingInterceptor();
for (PriorityInterceptor pInterceptor : interceptors) {
this.commandExecutor.addInterceptor(pInterceptor.getInterceptor());
}
service = new CommandBasedTaskService(this.commandExecutor, taskEventSupport, this.environment);
// register listeners
for (TaskLifeCycleEventListener listener : listeners) {
((EventService<TaskLifeCycleEventListener>) service).registerTaskEventListener(listener);
}
if (AssignmentServiceProvider.get().isEnabled()) {
((EventService<TaskLifeCycleEventListener>) service).registerTaskEventListener(new AssignmentTaskEventListener());
}
// initialize deadline service with command executor for processing
if (TaskDeadlinesServiceImpl.getInstance() == null) {
TaskDeadlinesServiceImpl.initialize(commandExecutor);
}
}
return service;
}
use of org.kie.api.task.TaskLifeCycleEventListener in project jbpm by kiegroup.
the class TaskEventSupport method fireAfterTaskUpdated.
public void fireAfterTaskUpdated(final Task task, TaskContext context) {
final Iterator<TaskLifeCycleEventListener> iter = getEventListenersIterator();
if (iter.hasNext()) {
do {
TaskLifeCycleEventListener listener = iter.next();
listener.afterTaskUpdatedEvent(new TaskEventImpl(task, context));
} while (iter.hasNext());
}
}
use of org.kie.api.task.TaskLifeCycleEventListener in project jbpm by kiegroup.
the class TaskEventSupport method fireBeforeTaskOutputVariablesChanged.
public void fireBeforeTaskOutputVariablesChanged(final Task task, TaskContext context, Map<String, Object> variables) {
final Iterator<TaskLifeCycleEventListener> iter = getEventListenersIterator();
if (iter.hasNext()) {
do {
TaskLifeCycleEventListener listener = iter.next();
listener.beforeTaskOutputVariableChangedEvent(new TaskEventImpl(task, context), variables);
} while (iter.hasNext());
}
}
use of org.kie.api.task.TaskLifeCycleEventListener in project jbpm by kiegroup.
the class TaskEventSupport method fireBeforeTaskReassigned.
public void fireBeforeTaskReassigned(final Task task, TaskContext context) {
final Iterator<TaskLifeCycleEventListener> iter = getEventListenersIterator();
if (iter.hasNext()) {
do {
TaskLifeCycleEventListener listener = iter.next();
listener.beforeTaskReassignedEvent(new TaskEventImpl(task, context));
} while (iter.hasNext());
}
}
Aggregations