use of org.drools.kiesession.session.StatefulSessionPool in project drools by kiegroup.
the class KieContainerImpl method createKieSessionsPool.
StatefulSessionPool createKieSessionsPool(String kSessionName, KieSessionConfiguration conf, Environment env, int initialSize, boolean stateless) {
KieSessionModel kSessionModel = kSessionName != null ? getKieSessionModel(kSessionName) : findKieSessionModel(false);
if (kSessionModel == null) {
log.error("Unknown KieSession name: " + kSessionName);
return null;
}
InternalKnowledgeBase kBase = (InternalKnowledgeBase) getKieBaseFromKieSessionModel(kSessionModel);
return kBase == null ? null : new StatefulSessionPool(kBase, initialSize, () -> {
SessionConfiguration sessConf = conf != null ? (SessionConfiguration) conf : kBase.getSessionConfiguration();
StatefulKnowledgeSessionImpl kSession = stateless ? ((StatefulKnowledgeSessionImpl) RuntimeComponentFactory.get().createStatefulSession(kBase, env, sessConf, false)).setStateless(true) : (StatefulKnowledgeSessionImpl) kBase.newKieSession(sessConf, env);
registerNewKieSession(kSessionModel, kBase, kSession);
return kSession;
});
}
Aggregations