Search in sources :

Example 1 with ClassObjectTypeConf

use of org.drools.core.reteoo.ClassObjectTypeConf in project drools by kiegroup.

the class StatefulKnowledgeSessionImpl method initInitialFact.

public InternalFactHandle initInitialFact(InternalKnowledgeBase kBase, InternalWorkingMemoryEntryPoint entryPoint, EntryPointId epId, MarshallerReaderContext context) {
    InitialFact initialFact = InitialFactImpl.getInstance();
    InternalFactHandle handle = new DefaultFactHandle(0, initialFact, 0, entryPoint);
    ClassObjectTypeConf otc = (ClassObjectTypeConf) entryPoint.getObjectTypeConfigurationRegistry().getObjectTypeConf(epId, initialFact);
    ObjectTypeNode otn = otc.getConcreteObjectTypeNode();
    if (otn != null) {
        PropagationContextFactory ctxFact = kBase.getConfiguration().getComponentFactory().getPropagationContextFactory();
        PropagationContext pctx = ctxFact.createPropagationContext(0, PropagationContext.Type.INSERTION, null, null, handle, epId, context);
        otn.assertInitialFact(handle, pctx, this);
    }
    return handle;
}
Also used : PropagationContextFactory(org.drools.core.common.PropagationContextFactory) DefaultFactHandle(org.drools.core.common.DefaultFactHandle) ClassObjectTypeConf(org.drools.core.reteoo.ClassObjectTypeConf) PropagationContext(org.drools.core.spi.PropagationContext) InitialFact(org.drools.core.InitialFact) ObjectTypeNode(org.drools.core.reteoo.ObjectTypeNode) InternalFactHandle(org.drools.core.common.InternalFactHandle)

Example 2 with ClassObjectTypeConf

use of org.drools.core.reteoo.ClassObjectTypeConf in project drools by kiegroup.

the class ObjectTypeConfigurationRegistry method getObjectTypeConf.

/**
 * Returns the ObjectTypeConfiguration object for the given object or
 * creates a new one if none is found in the cache
 */
public ObjectTypeConf getObjectTypeConf(EntryPointId entrypoint, Object object) {
    // first see if it's a ClassObjectTypeConf
    Object key;
    if (object instanceof Activation) {
        key = ClassObjectType.Match_ObjectType.getClassType();
    } else if (object instanceof Fact) {
        key = ((Fact) object).getFactTemplate().getName();
    } else {
        key = object.getClass();
    }
    ObjectTypeConf objectTypeConf = this.typeConfMap.get(key);
    // it doesn't exist, so create it.
    if (objectTypeConf == null) {
        if (object instanceof Fact) {
            objectTypeConf = new FactTemplateTypeConf(entrypoint, ((Fact) object).getFactTemplate(), this.kBase);
        } else {
            objectTypeConf = new ClassObjectTypeConf(entrypoint, (Class<?>) key, this.kBase);
        }
        ObjectTypeConf existing = this.typeConfMap.putIfAbsent(key, objectTypeConf);
        if (existing != null) {
            // Raced, take the (now) existing.
            objectTypeConf = existing;
        }
    }
    return objectTypeConf;
}
Also used : FactTemplateTypeConf(org.drools.core.reteoo.FactTemplateTypeConf) ObjectTypeConf(org.drools.core.reteoo.ObjectTypeConf) ClassObjectTypeConf(org.drools.core.reteoo.ClassObjectTypeConf) ClassObjectTypeConf(org.drools.core.reteoo.ClassObjectTypeConf) Activation(org.drools.core.spi.Activation) Fact(org.drools.core.facttemplates.Fact)

Aggregations

ClassObjectTypeConf (org.drools.core.reteoo.ClassObjectTypeConf)2 InitialFact (org.drools.core.InitialFact)1 DefaultFactHandle (org.drools.core.common.DefaultFactHandle)1 InternalFactHandle (org.drools.core.common.InternalFactHandle)1 PropagationContextFactory (org.drools.core.common.PropagationContextFactory)1 Fact (org.drools.core.facttemplates.Fact)1 FactTemplateTypeConf (org.drools.core.reteoo.FactTemplateTypeConf)1 ObjectTypeConf (org.drools.core.reteoo.ObjectTypeConf)1 ObjectTypeNode (org.drools.core.reteoo.ObjectTypeNode)1 Activation (org.drools.core.spi.Activation)1 PropagationContext (org.drools.core.spi.PropagationContext)1