public KnowledgeSession getPersistentSession(Map<String, Object> environmentOverrides, Integer sessionId) {
KieStoreServices kieStoreServices = KieServices.Factory.get().getStoreServices();
Environment env = Environments.getEnvironment(environmentOverrides);
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);