DefaultAgenda agenda = new DefaultAgenda( context.ruleBase,
false );
readAgenda( context,
agenda );
ReteooStatefulSession session = new ReteooStatefulSession( id,
context.ruleBase,
executor,
handleFactory,
initialFactHandle,
propagationCounter,
config,
agenda,
environment );
session.setKnowledgeRuntime(new StatefulKnowledgeSessionImpl(session));
initialFactHandle.setEntryPoint( session.getEntryPoints().get( EntryPoint.DEFAULT.getEntryPointId() ) );
// RuleFlowGroups need to reference the session
for ( RuleFlowGroup group : agenda.getRuleFlowGroupsMap().values() ) {
((RuleFlowGroupImpl) group).setWorkingMemory( session );
}
context.wm = session;
readFactHandles( context );
readActionQueue( context );
readTruthMaintenanceSystem( context );
if ( context.marshalProcessInstances && processMarshaller != null ) {
processMarshaller.readProcessInstances( context );
}
if ( context.marshalWorkItems && processMarshaller != null ) {
processMarshaller.readWorkItems( context );
}
if ( processMarshaller != null ) {
processMarshaller.readProcessTimers( context );
}
if( multithread ) {
session.startPartitionManagers();
}
return session;
}