use of org.kie.api.event.kiebase.KieBaseEventListener in project drools by kiegroup.
the class StatefulKnowledgeSessionImpl method dispose.
public void dispose() {
if (!agenda.dispose(this)) {
return;
}
if (logger != null) {
try {
logger.close();
} catch (Exception e) {
/* the logger was already closed, swallow */
}
}
for (WorkingMemoryEntryPoint ep : this.entryPoints.values()) {
ep.dispose();
}
this.ruleRuntimeEventSupport.clear();
this.ruleEventListenerSupport.clear();
this.agendaEventSupport.clear();
for (KieBaseEventListener listener : kieBaseEventListeners) {
this.kBase.removeEventListener(listener);
}
if (processRuntime != null) {
this.processRuntime.dispose();
}
if (timerService != null) {
this.timerService.shutdown();
}
if (this.workItemManager != null) {
((org.drools.core.process.instance.WorkItemManager) this.workItemManager).dispose();
}
this.kBase.disposeStatefulSession(this);
if (this.mbeanRegistered.get()) {
DroolsManagementAgent.getInstance().unregisterKnowledgeSessionUnderName(mbeanRegisteredCBSKey, this);
}
}
use of org.kie.api.event.kiebase.KieBaseEventListener in project drools by kiegroup.
the class StatefulKnowledgeSessionImpl method init.
private void init(SessionConfiguration config, Environment environment, long propagationContext) {
this.config = config;
this.environment = environment;
this.propagationIdCounter = new AtomicLong(propagationContext);
Globals globals = (Globals) this.environment.get(EnvironmentName.GLOBALS);
if (globals != null) {
if (!(globals instanceof GlobalResolver)) {
this.globalResolver = new GlobalsAdapter(globals);
} else {
this.globalResolver = (GlobalResolver) globals;
}
} else {
this.globalResolver = new MapGlobalResolver();
}
this.kieBaseEventListeners = new LinkedList<KieBaseEventListener>();
this.lock = new ReentrantLock();
this.timerService = TimerServiceFactory.getTimerService(this.config);
this.opCounter = new AtomicLong(0);
this.lastIdleTimestamp = new AtomicLong(-1);
}
use of org.kie.api.event.kiebase.KieBaseEventListener in project drools by kiegroup.
the class MultipleKieBaseListenersTest method testKnowledgeBaseEventSupportLeak.
@Test
public void testKnowledgeBaseEventSupportLeak() throws Exception {
final KieBase kieBase = KieBaseUtil.getKieBaseFromKieModuleFromDrl(TestConstants.PACKAGE_REGRESSION, kieBaseTestConfiguration, "");
KieBaseEventListener listener = new DefaultKieBaseEventListener();
kieBase.addEventListener(listener);
kieBase.addEventListener(listener);
kieBase.addEventListener(listener);
Assertions.assertThat(kieBase.getKieBaseEventListeners().size()).isEqualTo(1);
kieBase.removeEventListener(listener);
Assertions.assertThat(kieBase.getKieBaseEventListeners()).isEmpty();
}
use of org.kie.api.event.kiebase.KieBaseEventListener in project drools by kiegroup.
the class Misc2Test method testKnowledgeBaseEventSupportLeak.
@Test
public void testKnowledgeBaseEventSupportLeak() throws Exception {
// JBRULES-3666
KieBase kbase = KieBaseUtil.getKieBaseFromKieModuleFromDrl("test", kieBaseTestConfiguration);
KieBaseEventListener listener = new DefaultKieBaseEventListener();
kbase.addEventListener(listener);
kbase.addEventListener(listener);
assertEquals(1, kbase.getKieBaseEventListeners().size());
kbase.removeEventListener(listener);
assertEquals(0, kbase.getKieBaseEventListeners().size());
}
use of org.kie.api.event.kiebase.KieBaseEventListener in project drools by kiegroup.
the class Misc2Test method testKnowledgeBaseEventSupportLeak.
@Test
public void testKnowledgeBaseEventSupportLeak() throws Exception {
// JBRULES-3666
KieBase kbase = getKnowledgeBase();
KieBaseEventListener listener = new DefaultKieBaseEventListener();
kbase.addEventListener(listener);
kbase.addEventListener(listener);
assertEquals(1, ((KnowledgeBaseImpl) kbase).getKieBaseEventListeners().size());
kbase.removeEventListener(listener);
assertEquals(0, ((KnowledgeBaseImpl) kbase).getKieBaseEventListeners().size());
}
Aggregations