// if we have an agent always get the rulebase from there
this.ruleBase = (InternalRuleBase) ((KnowledgeBaseImpl) this.kagent.getKnowledgeBase()).ruleBase;
}
this.ruleBase.readLock();
try {
AbstractWorkingMemory wm = (AbstractWorkingMemory) wmFactory.createWorkingMemory(this.ruleBase.nextWorkingMemoryCounter(), this.ruleBase,
(SessionConfiguration) this.conf, this.environment);
// we don't pass the mapped listener wrappers to the session constructor anymore,
// because they would be ignored anyway, since the wm already contains those listeners
ksession = new StatefulKnowledgeSessionImpl(wm,
new KnowledgeBaseImpl(this.ruleBase));
((Globals) wm.getGlobalResolver()).setDelegate(this.sessionGlobals);
if (!initialized) {
// copy over the default generated listeners that are used for internal stuff once
registerSystemListeners(wm);
registerCustomListeners();
initialized = true;
}
wm.setAgendaEventSupport( this.agendaEventSupport );
wm.setWorkingMemoryEventSupport( this.workingMemoryEventSupport );
InternalProcessRuntime processRuntime = wm.getProcessRuntime();
if ( processRuntime != null ) {
processRuntime.setProcessEventSupport( this.processEventSupport );
}
for( Map.Entry<String, Channel> entry : this.channels.entrySet() ) {
wm.registerChannel( entry.getKey(), entry.getValue() );
}
// final InternalFactHandle handle = wm.getFactHandleFactory().newFactHandle( InitialFactImpl.getInstance(),
// wm.getObjectTypeConfigurationRegistry().getObjectTypeConf( EntryPointId.DEFAULT,
// InitialFactImpl.getInstance() ),