int id = ((ReteooRuleBase) ((KnowledgeBaseImpl) this.kbase).ruleBase).nextWorkingMemoryCounter();
RuleBaseConfiguration conf = ((ReteooRuleBase) ((KnowledgeBaseImpl) this.kbase).ruleBase).getConfiguration();
ExecutorService executor = ExecutorServiceFactory.createExecutorService( conf.getExecutorService() );
ReteooStatefulSession session = InputMarshaller.readSession( context,
id,
executor,
environment,
(SessionConfiguration) config );
executor.setCommandExecutor( new CommandExecutor( session ) );
context.close();
if ( ((SessionConfiguration) config).isKeepReference() ) {
((ReteooRuleBase) ((KnowledgeBaseImpl) this.kbase).ruleBase).addStatefulSession( session );
}
return (StatefulKnowledgeSession) session.getKnowledgeRuntime();
}