isPhreak = statefulSession.getKnowledgeBase().getConfiguration().isPhreakEnabled();
WorkingMemoryEventManager eventManager = statefulSession;
eventManager.addEventListener( (RuleRuntimeEventListener) this );
eventManager.addEventListener( (AgendaEventListener) this );
eventManager.addEventListener( (KieBaseEventListener) this );
InternalProcessRuntime processRuntime = ((StatefulKnowledgeSessionImpl) session).getProcessRuntime();
if (processRuntime != null) {
processRuntime.addEventListener( this );
}
} else if (session instanceof StatelessKnowledgeSessionImpl) {
StatelessKnowledgeSessionImpl statelessSession = ((StatelessKnowledgeSessionImpl) session);
isPhreak = statelessSession.getKnowledgeBase().getConfiguration().isPhreakEnabled();
statelessSession.addEventListener((RuleRuntimeEventListener) this);
statelessSession.addEventListener( (AgendaEventListener) this );
statelessSession.getKnowledgeBase().addEventListener( (KieBaseEventListener) this );
} else if (session instanceof CommandBasedStatefulKnowledgeSession) {
StatefulKnowledgeSessionImpl statefulSession =
((StatefulKnowledgeSessionImpl)((KnowledgeCommandContext)((CommandBasedStatefulKnowledgeSession) session).getCommandService().getContext()).getKieSession());
isPhreak = statefulSession.getKnowledgeBase().getConfiguration().isPhreakEnabled();
ReteooWorkingMemoryInterface eventManager = statefulSession;
eventManager.addEventListener( (RuleRuntimeEventListener) this );
eventManager.addEventListener( (AgendaEventListener) this );
InternalProcessRuntime processRuntime = eventManager.getProcessRuntime();
eventManager.addEventListener( (KieBaseEventListener) this );
if (processRuntime != null) {
processRuntime.addEventListener( this );
}
} else {
throw new IllegalArgumentException("Not supported session in logger: " + session.getClass());
}
}