use of org.drools.core.WorkingMemoryEntryPoint in project drools by kiegroup.
the class CursoredDataSource method bind.
@Override
public void bind(RuleUnit unit, WorkingMemoryEntryPoint ep) {
setWorkingMemory(ep.getInternalWorkingMemory());
PropagationList propagationList = propagationsMap.get(unit.getUnitIdentity());
if (propagationList != null) {
flush(ep, propagationList.takeAll());
} else {
Iterator<InternalFactHandle> fhs = objectStore.iterateFactHandles();
while (fhs.hasNext()) {
new Insert((DataSourceFactHandle) fhs.next()).execute(ep);
}
propagationsMap.put(unit.getUnitIdentity(), new SynchronizedPropagationList(((WorkingMemoryEntryPoint) ep).getInternalWorkingMemory()));
}
currentUnit = unit.getUnitIdentity();
currentEntryPoint = ep;
}
use of org.drools.core.WorkingMemoryEntryPoint in project drools by kiegroup.
the class DefaultAgenda method insertAndStageActivation.
@Override
public void insertAndStageActivation(final AgendaItem activation) {
if (activationObjectTypeConf == null) {
EntryPointId ep = workingMemory.getEntryPoint();
activationObjectTypeConf = ((WorkingMemoryEntryPoint) workingMemory.getWorkingMemoryEntryPoint(ep.getEntryPointId())).getObjectTypeConfigurationRegistry().getObjectTypeConf(ep, activation);
}
InternalFactHandle factHandle = workingMemory.getFactHandleFactory().newFactHandle(activation, activationObjectTypeConf, workingMemory, workingMemory);
workingMemory.getEntryPointNode().assertActivation(factHandle, activation.getPropagationContext(), workingMemory);
activation.setActivationFactHandle(factHandle);
}
use of org.drools.core.WorkingMemoryEntryPoint in project drools by kiegroup.
the class TraitHelperImpl method lookupHandleForWrapper.
private <K> InternalFactHandle lookupHandleForWrapper(K core) {
for (EntryPoint ep : workingMemory.getEntryPoints()) {
ObjectStore store = ((WorkingMemoryEntryPoint) ep).getObjectStore();
Iterator<InternalFactHandle> iter = store.iterateFactHandles();
while (iter.hasNext()) {
InternalFactHandle handle = iter.next();
if (handle.isTraitable() && handle.getObject() instanceof CoreWrapper && ((CoreWrapper) handle.getObject()).getCore() == core) {
return handle;
}
}
}
return null;
}
use of org.drools.core.WorkingMemoryEntryPoint in project drools by kiegroup.
the class TraitHelperImpl method makeTraitable.
private <K> TraitableBean makeTraitable(K core, TraitFactoryImpl builder, boolean logical, Activation activation) {
boolean needsWrapping = !(core instanceof TraitableBean);
ClassDefinition coreDef = lookupClassDefinition(core);
TraitableBean<K, ? extends TraitableBean> inner = needsWrapping ? builder.asTraitable(core, coreDef) : (TraitableBean<K, ? extends TraitableBean>) core;
if (needsWrapping) {
InternalFactHandle h = (InternalFactHandle) lookupFactHandle(core);
WorkingMemoryEntryPoint ep = h != null ? h.getEntryPoint(workingMemory) : ((StatefulKnowledgeSessionImpl) workingMemory).getEntryPoint("DEFAULT");
ObjectTypeConfigurationRegistry reg = ep.getObjectTypeConfigurationRegistry();
ObjectTypeConf coreConf = reg.getOrCreateObjectTypeConf(ep.getEntryPoint(), core);
ObjectTypeConf innerConf = reg.getOrCreateObjectTypeConf(ep.getEntryPoint(), inner);
if (coreConf.isTMSEnabled()) {
innerConf.enableTMS();
}
if (inner._getFieldTMS() != null && inner._getFieldTMS().needsInit()) {
inner._getFieldTMS().init(workingMemory);
}
} else {
TraitFieldTMS ftms = inner._getFieldTMS();
if (ftms != null) {
FactHandle handle = lookupFactHandle(inner);
if (handle == null) {
handle = this.workingMemory.insert(inner, false, activation.getRule(), activation.getTuple().getTupleSink());
}
if (ftms.needsInit()) {
ftms.init(workingMemory);
}
}
}
return inner;
}
use of org.drools.core.WorkingMemoryEntryPoint in project drools by kiegroup.
the class ProtobufInputMarshaller method assertHandleIntoOTN.
private static void assertHandleIntoOTN(ProtobufMarshallerReaderContext context, InternalWorkingMemory wm, InternalFactHandle handle, List<PropagationContext> pctxs) {
Object object = handle.getObject();
WorkingMemoryEntryPoint ep = handle.getEntryPoint(wm);
ObjectTypeConf typeConf = ep.getObjectTypeConfigurationRegistry().getOrCreateObjectTypeConf(ep.getEntryPoint(), object);
PropagationContextFactory pctxFactory = RuntimeComponentFactory.get().getPropagationContextFactory();
PropagationContext propagationContext = pctxFactory.createPropagationContext(wm.getNextPropagationIdCounter(), PropagationContext.Type.INSERTION, null, null, handle, ep.getEntryPoint(), context);
// keeping this list for a later cleanup is necessary because of the lazy propagations that might occur
pctxs.add(propagationContext);
ep.getEntryPointNode().assertObject(handle, propagationContext, typeConf, wm);
wm.flushPropagations();
}
Aggregations