Search in sources :

Example 1 with ExternalTaskEventListener

use of org.jbpm.services.task.wih.ExternalTaskEventListener in project jbpm by kiegroup.

the class AbstractRuntimeManager method configureRuntimeOnTaskService.

@SuppressWarnings({ "unchecked", "rawtypes" })
protected void configureRuntimeOnTaskService(InternalTaskService internalTaskService, RuntimeEngine engine) {
    if (internalTaskService != null) {
        ExternalTaskEventListener listener = new ExternalTaskEventListener();
        if (internalTaskService instanceof EventService) {
            ((EventService) internalTaskService).registerTaskEventListener(listener);
        }
        // register task listeners if any
        RegisterableItemsFactory factory = environment.getRegisterableItemsFactory();
        for (TaskLifeCycleEventListener taskListener : factory.getTaskListeners()) {
            ((EventService<TaskLifeCycleEventListener>) internalTaskService).registerTaskEventListener(taskListener);
        }
        if (engine != null && engine instanceof Disposable) {
            ((Disposable) engine).addDisposeListener(new DisposeListener() {

                @Override
                public void onDispose(RuntimeEngine runtime) {
                    if (runtime.getTaskService() instanceof EventService) {
                        ((EventService) runtime.getTaskService()).clearTaskEventListeners();
                        ;
                    }
                }
            });
        }
    }
}
Also used : Disposable(org.kie.internal.runtime.manager.Disposable) DisposeListener(org.kie.internal.runtime.manager.DisposeListener) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) ExternalTaskEventListener(org.jbpm.services.task.wih.ExternalTaskEventListener) InternalRegisterableItemsFactory(org.kie.internal.runtime.manager.InternalRegisterableItemsFactory) RegisterableItemsFactory(org.kie.api.runtime.manager.RegisterableItemsFactory) EventService(org.kie.internal.task.api.EventService) TaskLifeCycleEventListener(org.kie.api.task.TaskLifeCycleEventListener)

Aggregations

ExternalTaskEventListener (org.jbpm.services.task.wih.ExternalTaskEventListener)1 RegisterableItemsFactory (org.kie.api.runtime.manager.RegisterableItemsFactory)1 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)1 TaskLifeCycleEventListener (org.kie.api.task.TaskLifeCycleEventListener)1 Disposable (org.kie.internal.runtime.manager.Disposable)1 DisposeListener (org.kie.internal.runtime.manager.DisposeListener)1 InternalRegisterableItemsFactory (org.kie.internal.runtime.manager.InternalRegisterableItemsFactory)1 EventService (org.kie.internal.task.api.EventService)1