use of org.kie.internal.runtime.manager.DisposeListener 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();
;
}
}
});
}
}
}
Aggregations