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;
}
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;
}
Aggregations