Search in sources :

Example 1 with ClassAwareObjectStore

use of org.drools.core.common.ClassAwareObjectStore in project drools by kiegroup.

the class KieBaseUpdater method clearInstancesOfModifiedClass.

protected void clearInstancesOfModifiedClass(Class<?> cls) {
    // remove all ObjectTypeNodes for the modified classes
    ClassObjectType objectType = new ClassObjectType(cls);
    for (EntryPointNode epn : ctx.kBase.getRete().getEntryPointNodes().values()) {
        epn.removeObjectType(objectType);
    }
    // remove all instance of the old class from the object stores
    for (InternalWorkingMemory wm : ctx.kBase.getWorkingMemories()) {
        for (EntryPoint ep : wm.getEntryPoints()) {
            InternalWorkingMemoryEntryPoint wmEp = (InternalWorkingMemoryEntryPoint) wm.getWorkingMemoryEntryPoint(ep.getEntryPointId());
            ClassAwareObjectStore store = ((ClassAwareObjectStore) wmEp.getObjectStore());
            if (store.clearClassStore(cls)) {
                log.warn("Class " + cls.getName() + " has been modified and therfore its old instances will no longer match");
            }
        }
    }
}
Also used : InternalWorkingMemory(org.drools.core.common.InternalWorkingMemory) EntryPointNode(org.drools.core.reteoo.EntryPointNode) ClassObjectType(org.drools.core.base.ClassObjectType) InternalWorkingMemoryEntryPoint(org.drools.core.common.InternalWorkingMemoryEntryPoint) EntryPoint(org.kie.api.runtime.rule.EntryPoint) ClassAwareObjectStore(org.drools.core.common.ClassAwareObjectStore) InternalWorkingMemoryEntryPoint(org.drools.core.common.InternalWorkingMemoryEntryPoint)

Aggregations

ClassObjectType (org.drools.core.base.ClassObjectType)1 ClassAwareObjectStore (org.drools.core.common.ClassAwareObjectStore)1 InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)1 InternalWorkingMemoryEntryPoint (org.drools.core.common.InternalWorkingMemoryEntryPoint)1 EntryPointNode (org.drools.core.reteoo.EntryPointNode)1 EntryPoint (org.kie.api.runtime.rule.EntryPoint)1