KieSession stateful = null;
if (sessionId != null) {
stateful = kieStoreServices.loadKieSession(sessionId, _base, _sessionConfiguration, env);
}
if (stateful == null) {
stateful = kieStoreServices.newKieSession(_base, _sessionConfiguration, env);
}
KnowledgeDisposal loggersDisposal = Loggers.registerLoggersForDisposal(getModel(), getLoader(), stateful);
Listeners.registerListeners(getModel(), getLoader(), stateful);
Channels.registerChannels(getModel(), getLoader(), getDomain(), stateful);
return new KnowledgeSession(stateful, false, true, loggersDisposal);