private void resetEventListener() { if ( eventListener != null ) { this.workingMemory.removeEventListener( eventListener ); //remove the old } eventListener = new TestingEventListener(); this.workingMemory.addEventListener( eventListener ); this.ruleFiredVerifier.setFireCounter( eventListener.getFiringCounts() ); }
public void execute(Object object) { InternalWorkingMemory wm = newWorkingMemory(); wm.insert( object ); wm.fireAllRules( this.agendaFilter ); }
public void dispose() { this.ksession.removeEventListener( agendaStats ); if (ksession.getProcessRuntime() != null) { this.ksession.getProcessRuntime().removeEventListener( processStats ); } }
public KnowledgeSessionMonitoring(InternalWorkingMemory ksession) { this.ksession = ksession; this.kbase = (InternalRuleBase) ksession.getRuleBase(); this.name = DroolsManagementAgent.createObjectName(KSESSION_PREFIX + ":type="+kbase.getId()+",group=Sessions,sessionId=Session-"+ksession.getId()); this.agendaStats = new AgendaStats(); this.processStats = new ProcessStats(); this.ksession.addEventListener( agendaStats ); if (ksession.getProcessRuntime() != null) { this.ksession.getProcessRuntime().addEventListener( processStats ); } }
private long getCurrentTime() { return workingMemory.getSessionClock().getCurrentTime(); } }
public void read(MarshallerReaderContext inCtx) throws IOException, ClassNotFoundException { int leftTupleId = inCtx.readInt(); LeftTuple leftTuple = inCtx.terminalTupleMap.get( leftTupleId ); ScheduledAgendaItem item = ( ScheduledAgendaItem ) leftTuple.getObject(); Trigger trigger = InputMarshaller.readTrigger( inCtx ); DefaultAgenda agenda = ( DefaultAgenda ) inCtx.wm.getAgenda(); ActivationTimerJob job = new ActivationTimerJob(); ActivationTimerJobContext ctx = new ActivationTimerJobContext( trigger, item, agenda ); JobHandle jobHandle = ((InternalWorkingMemory)agenda.getWorkingMemory()).getTimerService().scheduleJob( job, ctx, trigger ); item.setJobHandle( jobHandle ); }
if ( rule.getCalendars() != null ) { long timestamp = workingMemory.getSessionClock().getCurrentTime(); for ( String cal : rule.getCalendars() ) { if ( !workingMemory.getCalendars().get( cal ).isTimeIncluded( timestamp ) ) { return false;
private static void assertHandleIntoOTN(MarshallerReaderContext context, InternalWorkingMemory wm, InternalFactHandle handle) { Object object = handle.getObject(); InternalWorkingMemoryEntryPoint ep = (InternalWorkingMemoryEntryPoint) handle.getEntryPoint(); ObjectTypeConf typeConf = ((InternalWorkingMemoryEntryPoint) handle.getEntryPoint()).getObjectTypeConfigurationRegistry().getObjectTypeConf( ep.getEntryPoint(), object ); PropagationContextImpl propagationContext = new PropagationContextImpl( wm.getNextPropagationIdCounter(), PropagationContext.ASSERTION, null, null, handle, ((DefaultAgenda) wm.getAgenda()).getActiveActivations(), ((DefaultAgenda) wm.getAgenda()).getDormantActivations(), ep.getEntryPoint(), context); ep.getEntryPointNode().assertObject( handle, propagationContext, typeConf, wm ); propagationContext.evaluateActionQueue( wm ); wm.executeQueuedActions(); propagationContext.cleanReaderContext(); }
activation = new ScheduledAgendaItem( activationNumber, leftTuple, (InternalAgenda) wm.getAgenda(), pc, ruleTerminalNode ); ( (DefaultAgenda) wm.getAgenda() ).getActivationGroup( activationGroupName ).addActivation( activation ); agendaGroup = (InternalAgendaGroup) ( (DefaultAgenda) wm.getAgenda() ).getAgendaGroup( AgendaGroup.MAIN ); } else { agendaGroup = (InternalAgendaGroup) ( (DefaultAgenda) wm.getAgenda() ).getAgendaGroup( rule.getAgendaGroup() ); agendaGroup.add( activation ); } else { InternalRuleFlowGroup rfg = (InternalRuleFlowGroup) ( (DefaultAgenda) wm.getAgenda() ).getRuleFlowGroup( rule.getRuleFlowGroup() ); rfg.addActivation( activation ); TruthMaintenanceSystem tms = context.wm.getTruthMaintenanceSystem(); while (stream.readShort() == PersisterEnums.LOGICAL_DEPENDENCY) { int factHandleId = stream.readInt(); InternalFactHandle handle = (InternalFactHandle) context.handles.get( factHandleId ); ObjectTypeConf typeConf = context.wm.getObjectTypeConfigurationRegistry().getObjectTypeConf( ((NamedEntryPoint)handle.getEntryPoint()).getEntryPoint(), handle.getObject() ); tms.addLogicalDependency( handle,
public void retractFact(String retractFactName) { this.workingMemory.retract(this.factHandles.get(retractFactName)); this.populatedData.remove(retractFactName); }
@Override public void populate(InternalWorkingMemory workingMemory, Map<String, FactHandle> factHandles) { factHandles.put(fact.getName(), workingMemory.insert(factObject)); }
private void fireAllRules(ScenarioSettings scenarioSettings) { this.workingMemory.fireAllRules( eventListener.getAgendaFilter( scenarioSettings.getRuleList(), scenarioSettings.isInclusive() ), scenarioSettings.getMaxRuleFirings() ); }
public ReteStatelessSessionResult(InternalWorkingMemory workingMemory, GlobalResolver globalResolver) { this.workingMemory = workingMemory; this.objectStore = workingMemory.getObjectStore(); this.globalResolver = globalResolver; }
@Override public void populate(InternalWorkingMemory workingMemory, Map<String, FactHandle> factHandles) { workingMemory.setGlobal(fact.getName(), factObject); }
fieldVerifier.checkFields( verifyFact.getFieldValues() ); } else { Iterator objects = workingMemory.iterateObjects(); while ( objects.hasNext() ) { if ( verifyFact( objects.next(),
private long getCurrentTime() { return workingMemory.getSessionClock().getCurrentTime(); } }
public void deserialize(MarshallerReaderContext inCtx, Timer _timer) throws ClassNotFoundException { ActivationTimer _activation = _timer.getActivation(); LeftTuple leftTuple = inCtx.filter.getTuplesCache().get( PersisterHelper.createActivationKey( _activation.getActivation().getPackageName(), _activation.getActivation().getRuleName(), _activation.getActivation().getTuple() ) ); ScheduledAgendaItem item = (ScheduledAgendaItem) leftTuple.getObject(); Trigger trigger = ProtobufInputMarshaller.readTrigger( inCtx, _activation.getTrigger() ); DefaultAgenda agenda = ( DefaultAgenda ) inCtx.wm.getAgenda(); ActivationTimerJob job = new ActivationTimerJob(); ActivationTimerJobContext ctx = new ActivationTimerJobContext( trigger, item, agenda ); JobHandle jobHandle = ((InternalWorkingMemory)agenda.getWorkingMemory()).getTimerService().scheduleJob( job, ctx, trigger ); item.setJobHandle( jobHandle ); } }
if ( rule.getCalendars() != null ) { long timestamp = workingMemory.getSessionClock().getCurrentTime(); for ( String cal : rule.getCalendars() ) { if ( !workingMemory.getCalendars().get( cal ).isTimeIncluded( timestamp ) ) { return false;
public void retractFact(String retractFactName) { this.workingMemory.retract(this.factHandles.get(retractFactName)); this.populatedData.remove(retractFactName); }