Search in sources :

Example 21 with RuleBase

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);
}
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) RuleBase(org.drools.core.impl.RuleBase) HashSet(java.util.HashSet)

Aggregations

RuleBase (org.drools.core.impl.RuleBase)21 Test (org.junit.Test)16 KieBase (org.kie.api.KieBase)9 ObjectTypeNode (org.drools.core.reteoo.ObjectTypeNode)6 KieSession (org.kie.api.runtime.KieSession)6 Rete (org.drools.core.reteoo.Rete)5 LeftInputAdapterNode (org.drools.core.reteoo.LeftInputAdapterNode)4 InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)3 BuildContext (org.drools.core.reteoo.builder.BuildContext)3 FactHandle (org.kie.api.runtime.rule.FactHandle)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ClassObjectType (org.drools.core.base.ClassObjectType)2 AlphaNode (org.drools.core.reteoo.AlphaNode)2 LeftTupleSink (org.drools.core.reteoo.LeftTupleSink)2 RuleTerminalNode (org.drools.core.reteoo.RuleTerminalNode)2 IndexableConstraint (org.drools.core.rule.IndexableConstraint)2 KieBaseConfiguration (org.kie.api.KieBaseConfiguration)2 ReleaseId (org.kie.api.builder.ReleaseId)2 KiePackage (org.kie.api.definition.KiePackage)2