Search in sources :

Example 1 with FactTemplateTypeConf

use of org.drools.core.reteoo.FactTemplateTypeConf 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

Fact (org.drools.core.facttemplates.Fact)1 ClassObjectTypeConf (org.drools.core.reteoo.ClassObjectTypeConf)1 FactTemplateTypeConf (org.drools.core.reteoo.FactTemplateTypeConf)1 ObjectTypeConf (org.drools.core.reteoo.ObjectTypeConf)1 Activation (org.drools.core.spi.Activation)1