use of org.drools.core.impl.RuleBase in project drools by kiegroup.
the class KieContainerImpl method dispose.
public void dispose() {
sessionConfsCache.clear();
kBases.values().forEach(kb -> ((InternalKnowledgeBase) kb).setKieContainer(null));
Set<DroolsManagementAgent.CBSKey> cbskeys = new HashSet<DroolsManagementAgent.CBSKey>();
if (isMBeanOptionEnabled()) {
for (Entry<String, KieSession> kv : kSessions.entrySet()) {
cbskeys.add(new DroolsManagementAgent.CBSKey(containerId, ((RuleBase) kv.getValue().getKieBase()).getId(), kv.getKey()));
}
for (Entry<String, StatelessKieSession> kv : statelessKSessions.entrySet()) {
cbskeys.add(new DroolsManagementAgent.CBSKey(containerId, ((RuleBase) kv.getValue().getKieBase()).getId(), kv.getKey()));
}
}
for (KieSession kieSession : kSessions.values()) {
kieSession.dispose();
}
kSessions.clear();
statelessKSessions.clear();
if (isMBeanOptionEnabled()) {
for (CBSKey c : cbskeys) {
DroolsManagementAgent.getInstance().unregisterKnowledgeSessionBean(c);
}
for (KieBase kb : kBases.values()) {
DroolsManagementAgent.getInstance().unregisterKnowledgeBase((RuleBase) kb);
}
DroolsManagementAgent.getInstance().unregisterMBeansFromOwner(this);
}
((InternalKieServices) KieServices.Factory.get()).clearRefToContainerId(this.containerId, this);
}
Aggregations