use of org.kie.internal.runtime.manager.WorkItemHandlerProducer in project jbpm by kiegroup.
the class InjectableRegisterableItemsFactory method getWorkItemHandlers.
@Override
public Map<String, WorkItemHandler> getWorkItemHandlers(RuntimeEngine runtime) {
Map<String, WorkItemHandler> handler = new HashMap<String, WorkItemHandler>();
handler.put("Human Task", getHTWorkItemHandler(runtime));
RuntimeManager manager = ((RuntimeEngineImpl) runtime).getManager();
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("ksession", runtime.getKieSession());
parameters.put("taskService", runtime.getTaskService());
parameters.put("runtimeManager", manager);
parameters.put("kieContainer", getRuntimeManager().getKieContainer());
try {
parameters.put("executorService", executorService.get());
} catch (Exception e) {
logger.debug("Executor service not available due to {}", e.getMessage());
}
if (kieContainer != null) {
// add classloader as one of the parameters so it can be easily referenced
parameters.put("classLoader", kieContainer.getClassLoader());
KieSessionModel ksessionModel = null;
if (StringUtils.isEmpty(ksessionName)) {
ksessionModel = ((KieContainerImpl) kieContainer).getKieProject().getDefaultKieSession();
if (ksessionModel == null) {
ksessionModel = ((KieContainerImpl) kieContainer).getKieSessionModel(DEFAULT_KIE_SESSION);
}
} else {
ksessionModel = ((KieContainerImpl) kieContainer).getKieSessionModel(ksessionName);
}
if (ksessionModel == null) {
throw new IllegalStateException("Cannot find ksession, either it does not exist or there are multiple default ksession in kmodule.xml");
}
try {
InjectionHelper.wireSessionComponents(ksessionModel, runtime.getKieSession(), parameters);
} catch (Throwable e) {
// use fallback mechanism
InjectionHelper.wireSessionComponents(ksessionModel, runtime.getKieSession());
}
}
try {
for (WorkItemHandlerProducer producer : workItemHandlerProducer) {
handler.putAll(producer.getWorkItemHandlers(manager.getIdentifier(), parameters));
}
} catch (Exception e) {
// do nothing as work item handler is considered optional
logger.warn("Exception while evalutating work item handler prodcuers {}", e.getMessage());
}
// add handlers from descriptor
handler.putAll(getWorkItemHandlersFromDescriptor(runtime));
return handler;
}
Aggregations