use of org.jbpm.runtime.manager.impl.RuntimeEngineImpl in project jbpm by kiegroup.
the class InjectableRegisterableItemsFactory method getGlobals.
@Override
public Map<String, Object> getGlobals(RuntimeEngine runtime) {
Map<String, Object> globals = new HashMap<String, Object>();
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());
}
try {
for (GlobalProducer producer : globalProducer) {
globals.putAll(producer.getGlobals(manager.getIdentifier(), parameters));
}
} catch (Exception e) {
// do nothing as work item handler is considered optional
logger.warn("Exception while evalutating globals prodcuers {}", e.getMessage());
}
// add globals from descriptor
globals.putAll(getGlobalsFromDescriptor(runtime));
return globals;
}
use of org.jbpm.runtime.manager.impl.RuntimeEngineImpl 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