use of org.drools.core.WorkingMemoryEntryPoint in project drools by kiegroup.
the class ObjectTypeNode method attach.
/**
* Rete needs to know that this ObjectTypeNode has been added
*/
public void attach(BuildContext context) {
this.source.addObjectSink(this);
InternalWorkingMemory[] workingMemories = context.getWorkingMemories();
InternalWorkingMemory workingMemory = workingMemories.length > 0 ? workingMemories[0] : null;
if (workingMemory != null) {
WorkingMemoryEntryPoint wmEntryPoint = workingMemory.getWorkingMemoryEntryPoint(((EntryPointNode) source).getEntryPoint().getEntryPointId());
ObjectTypeConf objectTypeConf = wmEntryPoint.getObjectTypeConfigurationRegistry().getObjectTypeConfByClass(((ClassObjectType) objectType).getClassType());
if (objectTypeConf != null) {
objectTypeConf.resetCache();
}
}
}
use of org.drools.core.WorkingMemoryEntryPoint in project drools by kiegroup.
the class TraitHelper 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 TraitHelper method makeTraitable.
private <K> TraitableBean makeTraitable(K core, TraitFactory 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() : ((StatefulKnowledgeSessionImpl) workingMemory).getEntryPoint("DEFAULT");
ObjectTypeConfigurationRegistry reg = ep.getObjectTypeConfigurationRegistry();
ObjectTypeConf coreConf = reg.getObjectTypeConf(ep.getEntryPoint(), core);
ObjectTypeConf innerConf = reg.getObjectTypeConf(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 AbstractFactHandleFactory method newFactHandle.
public final InternalFactHandle newFactHandle(final long id, final Object object, final long recency, final ObjectTypeConf conf, final ReteEvaluator reteEvaluator, final WorkingMemoryEntryPoint wmEntryPoint) {
WorkingMemoryEntryPoint entryPoint = getWmEntryPoint(reteEvaluator, wmEntryPoint);
boolean isTrait = conf != null && conf.isTrait();
if (conf != null && conf.isEvent()) {
TypeDeclaration type = conf.getTypeDeclaration();
long timestamp;
if (type != null && type.getTimestampExtractor() != null) {
timestamp = type.getTimestampExtractor().getLongValue(reteEvaluator, object);
} else {
timestamp = reteEvaluator.getTimerService().getCurrentTime();
}
long duration = 0;
if (type != null && type.getDurationExtractor() != null) {
duration = type.getDurationExtractor().getLongValue(reteEvaluator, object);
}
return createEventFactHandle(id, object, recency, entryPoint, isTrait, timestamp, duration);
} else {
return createDefaultFactHandle(id, object, recency, entryPoint, isTrait);
}
}
use of org.drools.core.WorkingMemoryEntryPoint in project drools by kiegroup.
the class StatefulKnowledgeSessionImpl method dispose.
public void dispose() {
alive = false;
if (pool != null) {
pool.release(this);
return;
}
if (!agenda.dispose(this)) {
return;
}
if (logger != null) {
try {
logger.close();
} catch (Exception e) {
/* the logger was already closed, swallow */
}
}
for (WorkingMemoryEntryPoint ep : this.entryPointsManager.getEntryPoints()) {
ep.dispose();
}
for (AsyncReceiveNode.AsyncReceiveMemory receiveMemory : this.receiveNodeMemories) {
receiveMemory.dispose();
}
this.ruleRuntimeEventSupport.clear();
this.ruleEventListenerSupport.clear();
this.agendaEventSupport.clear();
for (KieBaseEventListener listener : kieBaseEventListeners) {
this.kBase.removeEventListener(listener);
}
if (this.processRuntime != null) {
this.processRuntime.dispose();
}
if (this.timerService != null) {
this.timerService.shutdown();
}
if (this.workItemManager != null) {
((org.drools.core.process.instance.WorkItemManager) this.workItemManager).dispose();
}
this.kBase.disposeStatefulSession(this);
if (this.mbeanRegistered.get()) {
DroolsManagementAgent.getInstance().unregisterKnowledgeSessionUnderName(mbeanRegisteredCBSKey, this);
}
}
Aggregations