public void addEventListener(final AgendaEventListener listener) { this.agendaEventSupport.addEventListener( listener ); }
public AbstractWorkingMemory(final int id, final InternalRuleBase ruleBase, final FactHandleFactory handleFactory, final boolean initInitialFactHandle, final long propagationContext, final SessionConfiguration config, final InternalAgenda agenda, final Environment environment) { this( id, ruleBase, handleFactory, initInitialFactHandle, propagationContext, config, environment, new WorkingMemoryEventSupport(), new AgendaEventSupport(), agenda ); }
public void reset() { this.clear(); } }
private void registerSystemListeners(AbstractWorkingMemory wm) { for ( org.drools.event.AgendaEventListener listener : wm.getAgendaEventSupport().getEventListeners()) { this.agendaEventSupport.addEventListener( listener ); } for ( org.drools.event.WorkingMemoryEventListener listener : wm.getWorkingMemoryEventSupport().getEventListeners()) { this.workingMemoryEventSupport.addEventListener( listener ); } InternalProcessRuntime processRuntime = wm.getProcessRuntime(); if ( processRuntime != null ) { for ( ProcessEventListener listener : processRuntime.getProcessEventListeners() ) { this.processEventSupport.addEventListener( listener ); } } }
((EventSupport) this.workingMemory).getAgendaEventSupport().fireBeforeRuleFlowGroupActivated( this, this.workingMemory ); if ( this.list.isEmpty() ) { triggerActivations(); ((EventSupport) this.workingMemory).getAgendaEventSupport().fireAfterRuleFlowGroupActivated( this, this.workingMemory ); } else { ((EventSupport) this.workingMemory).getAgendaEventSupport().fireBeforeRuleFlowGroupDeactivated( this, this.workingMemory ); final Iterator<ActivationNode> it = this.list.iterator(); ((EventSupport) this.workingMemory).getAgendaEventSupport().fireAfterRuleFlowGroupDeactivated( this, this.workingMemory );
Scheduler.removeAgendaItem( item, this ); eventsupport.getAgendaEventSupport().fireActivationCancelled( item, this.workingMemory, ActivationCancelledCause.CLEAR );
eventsupport.getAgendaEventSupport().fireBeforeActivationFired( activation, this.workingMemory ); eventsupport.getAgendaEventSupport().fireAfterActivationFired( activation, this.workingMemory );
item.setSequenence( rtn.getSequence() ); ((EventSupport) workingMemory).getAgendaEventSupport().fireActivationCreated( item, workingMemory ); return true;
public boolean setFocus(final AgendaGroup agendaGroup) { // Set the focus to the agendaGroup if it doesn't already have the focus if ( this.focusStack.getLast() != agendaGroup ) { ((InternalAgendaGroup) this.focusStack.getLast()).setActive( false ); this.focusStack.add(agendaGroup); ((InternalAgendaGroup) agendaGroup).setActive(true); final EventSupport eventsupport = (EventSupport) this.workingMemory; eventsupport.getAgendaEventSupport().fireAgendaGroupPushed( agendaGroup, this.workingMemory ); return true; } else { return false; } }
public AgendaGroup getNextFocus() { InternalAgendaGroup agendaGroup; // Iterate until we find a populate AgendaModule or we reach the MAIN, // default, AgendaGroup while ( true ) { agendaGroup = (InternalAgendaGroup) this.focusStack.getLast(); final boolean empty = agendaGroup.isEmpty(); // No populated queues found so pop the focusStack and repeat if ( empty && (this.focusStack.size() > 1) ) { agendaGroup.setActive( false ); this.focusStack.removeLast(); final EventSupport eventsupport = (EventSupport) this.workingMemory; eventsupport.getAgendaEventSupport().fireAgendaGroupPopped( agendaGroup, this.workingMemory ); } else { agendaGroup = (empty) ? null : agendaGroup; break; } } if ( agendaGroup != null ) { agendaGroup.setActive( true ); } return agendaGroup; }
if (!initialized) { for (org.drools.event.AgendaEventListener listener: wm.getAgendaEventSupport().getEventListeners()) { this.agendaEventSupport.addEventListener(listener);
public void clearAndCancelActivationGroup(final ActivationGroup activationGroup) { final EventSupport eventsupport = (EventSupport) this.workingMemory; for ( final Iterator it = activationGroup.iterator(); it.hasNext(); ) { final ActivationGroupNode node = (ActivationGroupNode) it.next(); final Activation activation = node.getActivation(); activation.setActivationGroupNode( null ); if ( activation.isActivated() ) { activation.setActivated( false ); activation.remove(); if ( activation.getActivationNode() != null ) { final InternalRuleFlowGroup ruleFlowGroup = (InternalRuleFlowGroup) activation.getActivationNode().getParentContainer(); ruleFlowGroup.removeActivation( activation ); } eventsupport.getAgendaEventSupport().fireActivationCancelled( activation, this.workingMemory, ActivationCancelledCause.CLEAR ); } } activationGroup.clear(); }
item.setSequenence( rtn.getSequence() ); ((EventSupport) workingMemory).getAgendaEventSupport().fireActivationCreated( item, workingMemory ); return true;
public void addEventListener(final AgendaEventListener listener) { this.agendaEventSupport.addEventListener( listener ); }
public void clearAndCancelStagedActivations() { if ( getStageActivationsGroup().isEmpty() ) { return; } org.drools.core.util.LinkedList<ActivationGroupNode> list = getStageActivationsGroup().getList(); final EventSupport eventsupport = (EventSupport) this.workingMemory; for ( ActivationGroupNode node = list.removeFirst(); node != null; node = list.removeFirst() ) { AgendaItem item = ( AgendaItem ) node.getActivation(); // This must be set to false otherwise modify won't work properly item.setActivated( false ); eventsupport.getAgendaEventSupport().fireActivationCancelled( item, this.workingMemory, ActivationCancelledCause.CLEAR ); } }
/** * Construct. * * @param ruleBase * The backing rule-base. */ public AbstractWorkingMemory(final int id, final InternalRuleBase ruleBase, boolean initInitFactHandle, final FactHandleFactory handleFactory, final SessionConfiguration config, final Environment environment) { this( id, ruleBase, handleFactory, initInitFactHandle, 1, config, environment, new WorkingMemoryEventSupport(), new AgendaEventSupport(), null ); }
private void registerCustomListeners() { if ( mappedAgendaListeners != null ) { for (AgendaEventListenerWrapper agendaListener : mappedAgendaListeners.values()) { this.agendaEventSupport.addEventListener( agendaListener ); } } if ( mappedWorkingMemoryListeners != null ) { for (WorkingMemoryEventListenerWrapper wmListener : mappedWorkingMemoryListeners.values()) { this.workingMemoryEventSupport.addEventListener( wmListener ); } } if ( cachedProcessEventListener != null ) { for (ProcessEventListener processListener : cachedProcessEventListener) { this.processEventSupport.addEventListener( processListener ); } } }
public void clearAndCancelAgendaGroup(final AgendaGroup agendaGroup) { final EventSupport eventsupport = (EventSupport) this.workingMemory; // this is thread safe for BinaryHeapQueue // Binary Heap locks while it returns the array and reset's it's own internal array. Lock is released afer getAndClear() for (Activation aQueueable : ((InternalAgendaGroup) agendaGroup).getAndClear()) { final AgendaItem item = (AgendaItem) aQueueable; if (item == null) { continue; } // this must be set false before removal from the activationGroup. // Otherwise the activationGroup will also try to cancel the Actvation // Also modify won't work properly item.setActivated(false); if (item.getActivationGroupNode() != null) { item.getActivationGroupNode().getActivationGroup().removeActivation(item); } if (item.getActivationNode() != null) { final InternalRuleFlowGroup ruleFlowGroup = (InternalRuleFlowGroup) item.getActivationNode().getParentContainer(); ruleFlowGroup.removeActivation(item); } eventsupport.getAgendaEventSupport().fireActivationCancelled( item, this.workingMemory, ActivationCancelledCause.CLEAR ); } }
public SharedWorkingMemoryContext(FactHandleFactory handleFactory) { this.handleFactory = handleFactory; this.globalResolver = new MapGlobalResolver(); this.workingMemoryEventSupport = new WorkingMemoryEventSupport(); this.agendaEventSupport = new AgendaEventSupport(); this.__ruleBaseEventListeners = new LinkedList(); }
public WorkingMemoryLogger(final KnowledgeRuntimeEventManager session) { if (session instanceof StatefulKnowledgeSessionImpl) { WorkingMemoryEventManager eventManager = ((StatefulKnowledgeSessionImpl) session).session; eventManager.addEventListener( (WorkingMemoryEventListener) this ); eventManager.addEventListener( (AgendaEventListener) this ); eventManager.addEventListener( (RuleBaseEventListener) this ); InternalProcessRuntime processRuntime = ((StatefulKnowledgeSessionImpl) session).session.getProcessRuntime(); if (processRuntime != null) { processRuntime.addEventListener( (ProcessEventListener) this ); } } else if (session instanceof StatelessKnowledgeSessionImpl) { ((StatelessKnowledgeSessionImpl) session).workingMemoryEventSupport.addEventListener( this ); ((StatelessKnowledgeSessionImpl) session).agendaEventSupport.addEventListener( this ); ((StatelessKnowledgeSessionImpl) session).processEventSupport.addEventListener( this ); ((StatelessKnowledgeSessionImpl) session).getRuleBase().addEventListener( this ); } else if (session instanceof CommandBasedStatefulKnowledgeSession) { ReteooWorkingMemoryInterface eventManager = ((StatefulKnowledgeSessionImpl)((KnowledgeCommandContext)((CommandBasedStatefulKnowledgeSession) session).getCommandService().getContext()).getStatefulKnowledgesession()).session; eventManager.addEventListener( (WorkingMemoryEventListener) this ); eventManager.addEventListener( (AgendaEventListener) this ); InternalProcessRuntime processRuntime = eventManager.getProcessRuntime(); eventManager.addEventListener( (RuleBaseEventListener) this ); if (processRuntime != null) { processRuntime.addEventListener( (ProcessEventListener) this ); } } else { throw new IllegalArgumentException("Not supported session in logger: " + session.getClass()); } }