Search in sources :

Example 1 with InternalWorkingMemoryEntryPoint

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

the class DefaultKnowledgeHelper method update.

public void update(final FactHandle handle, BitMask mask, Class<?> modifiedClass) {
    InternalFactHandle h = (InternalFactHandle) handle;
    if (h.getDataSource() != null) {
        // This handle has been insert from a datasource, so update it
        h.getDataSource().update(h, ((InternalFactHandle) handle).getObject(), mask, modifiedClass, this.activation);
        return;
    }
    ((InternalWorkingMemoryEntryPoint) h.getEntryPoint()).update(h, ((InternalFactHandle) handle).getObject(), mask, modifiedClass, this.activation);
    if (h.isTraitOrTraitable()) {
        workingMemory.updateTraits(h, mask, modifiedClass, this.activation);
    }
}
Also used : InternalFactHandle(org.drools.core.common.InternalFactHandle) InternalWorkingMemoryEntryPoint(org.drools.core.common.InternalWorkingMemoryEntryPoint)

Example 2 with InternalWorkingMemoryEntryPoint

use of org.drools.core.common.InternalWorkingMemoryEntryPoint 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

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