Search in sources :

Example 1 with CBSKey

use of org.drools.core.management.DroolsManagementAgent.CBSKey in project drools by kiegroup.

the class KieContainerImpl method dispose.

public void dispose() {
    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, ((InternalKnowledgeBase) kv.getValue().getKieBase()).getId(), kv.getKey()));
        }
        for (Entry<String, StatelessKieSession> kv : statelessKSessions.entrySet()) {
            cbskeys.add(new DroolsManagementAgent.CBSKey(containerId, ((InternalKnowledgeBase) 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((InternalKnowledgeBase) kb);
        }
        DroolsManagementAgent.getInstance().unregisterMBeansFromOwner(this);
    }
    ((InternalKieServices) KieServices.Factory.get()).clearRefToContainerId(this.containerId, this);
}
Also used : DroolsManagementAgent(org.drools.core.management.DroolsManagementAgent) CBSKey(org.drools.core.management.DroolsManagementAgent.CBSKey) KieBase(org.kie.api.KieBase) StatelessKieSession(org.kie.api.runtime.StatelessKieSession) StatelessKieSession(org.kie.api.runtime.StatelessKieSession) KieSession(org.kie.api.runtime.KieSession) CBSKey(org.drools.core.management.DroolsManagementAgent.CBSKey) InternalKnowledgeBase(org.drools.core.impl.InternalKnowledgeBase) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)1 DroolsManagementAgent (org.drools.core.management.DroolsManagementAgent)1 CBSKey (org.drools.core.management.DroolsManagementAgent.CBSKey)1 KieBase (org.kie.api.KieBase)1 KieSession (org.kie.api.runtime.KieSession)1 StatelessKieSession (org.kie.api.runtime.StatelessKieSession)1