if (session instanceof StatefulKnowledgeSessionImpl) {
WorkingMemoryEventManager eventManager = ((StatefulKnowledgeSessionImpl) session).session;
eventManager.addEventListener( (WorkingMemoryEventListener) this );
eventManager.addEventListener( (AgendaEventListener) this );
eventManager.addEventListener( (RuleBaseEventListener) this );
InternalProcessRuntime processRuntime = ((StatefulKnowledgeSessionImpl) session).session.getProcessRuntime();
if (processRuntime != null) {
processRuntime.addEventListener( (ProcessEventListener) this );
}
} else if (session instanceof StatelessKnowledgeSessionImpl) {
((StatelessKnowledgeSessionImpl) session).workingMemoryEventSupport.addEventListener( this );
((StatelessKnowledgeSessionImpl) session).agendaEventSupport.addEventListener( this );
((StatelessKnowledgeSessionImpl) session).processEventSupport.addEventListener( this );
((StatelessKnowledgeSessionImpl) session).getRuleBase().addEventListener( this );
} else if (session instanceof CommandBasedStatefulKnowledgeSession) {
ReteooWorkingMemoryInterface eventManager =
((StatefulKnowledgeSessionImpl)((KnowledgeCommandContext)((CommandBasedStatefulKnowledgeSession) session).getCommandService().getContext()).getKieSession()).session;
eventManager.addEventListener( (WorkingMemoryEventListener) this );
eventManager.addEventListener( (AgendaEventListener) this );
InternalProcessRuntime processRuntime = eventManager.getProcessRuntime();
eventManager.addEventListener( (RuleBaseEventListener) this );
if (processRuntime != null) {
processRuntime.addEventListener( (ProcessEventListener) this );
}
} else {
throw new IllegalArgumentException("Not supported session in logger: " + session.getClass());
}
}