Search in sources :

Example 1 with DefaultRuleRuntimeEventListener

use of org.drools.core.event.DefaultRuleRuntimeEventListener in project drools by kiegroup.

the class SessionsPoolTest method testListenersReset.

@Test
public void testListenersReset() {
    final KieContainerSessionsPool pool = getKieContainer().newKieSessionsPool(1);
    KieSession ksession = pool.newKieSession();
    try {
        ksession.addEventListener(new DefaultAgendaEventListener());
        ksession.addEventListener(new DefaultRuleRuntimeEventListener());
        ((RuleEventManager) ksession).addEventListener(new RuleEventListener() {
        });
    } finally {
        ksession.dispose();
    }
    ksession = pool.newKieSession();
    try {
        Assertions.assertThat(ksession.getAgendaEventListeners()).hasSize(0);
        Assertions.assertThat(ksession.getRuleRuntimeEventListeners()).hasSize(0);
        Assertions.assertThat(((EventSupport) ksession).getRuleEventSupport().getEventListeners()).hasSize(0);
    } finally {
        ksession.dispose();
    }
}
Also used : KieContainerSessionsPool(org.kie.api.runtime.KieContainerSessionsPool) RuleEventManager(org.kie.internal.event.rule.RuleEventManager) RuleEventListener(org.kie.internal.event.rule.RuleEventListener) DefaultAgendaEventListener(org.drools.core.event.DefaultAgendaEventListener) StatelessKieSession(org.kie.api.runtime.StatelessKieSession) KieSession(org.kie.api.runtime.KieSession) DefaultRuleRuntimeEventListener(org.drools.core.event.DefaultRuleRuntimeEventListener) Test(org.junit.Test)

Example 2 with DefaultRuleRuntimeEventListener

use of org.drools.core.event.DefaultRuleRuntimeEventListener in project drools by kiegroup.

the class FactHandleTest method createCollectEventListener.

private DefaultRuleRuntimeEventListener createCollectEventListener(List<Long> factHandleIDs) {
    return new DefaultRuleRuntimeEventListener() {

        public void objectInserted(ObjectInsertedEvent event) {
            InternalFactHandle ifh = (InternalFactHandle) event.getFactHandle();
            factHandleIDs.add(ifh.getId());
        }
    };
}
Also used : ObjectInsertedEvent(org.kie.api.event.rule.ObjectInsertedEvent) InternalFactHandle(org.drools.core.common.InternalFactHandle) DefaultRuleRuntimeEventListener(org.drools.core.event.DefaultRuleRuntimeEventListener)

Aggregations

DefaultRuleRuntimeEventListener (org.drools.core.event.DefaultRuleRuntimeEventListener)2 InternalFactHandle (org.drools.core.common.InternalFactHandle)1 DefaultAgendaEventListener (org.drools.core.event.DefaultAgendaEventListener)1 Test (org.junit.Test)1 ObjectInsertedEvent (org.kie.api.event.rule.ObjectInsertedEvent)1 KieContainerSessionsPool (org.kie.api.runtime.KieContainerSessionsPool)1 KieSession (org.kie.api.runtime.KieSession)1 StatelessKieSession (org.kie.api.runtime.StatelessKieSession)1 RuleEventListener (org.kie.internal.event.rule.RuleEventListener)1 RuleEventManager (org.kie.internal.event.rule.RuleEventManager)1