Drools :: ReteOO 6.0.0.CR2

org.drools.reteoo.common
Class ReteAgenda

java.lang.Object
  extended by org.drools.reteoo.common.ReteAgenda
All Implemented Interfaces:
Externalizable, Serializable, org.drools.core.common.InternalAgenda, org.kie.api.runtime.rule.Agenda

public class ReteAgenda
extends Object
implements Externalizable, org.drools.core.common.InternalAgenda

Rule-firing Agenda.

Since many rules may be matched by a single assertObject(...) all scheduled actions are placed into the Agenda.

While processing a scheduled action, it may update or retract objects in other scheduled actions, which must then be removed from the agenda. Non-invalidated actions are left on the agenda, and are executed in turn.

See Also:
Serialized Form

Field Summary
protected  int activationCounter
           
protected  AtomicBoolean halt
           
protected  org.drools.core.spi.KnowledgeHelper knowledgeHelper
           
protected static org.slf4j.Logger log
           
protected  org.drools.core.common.InternalWorkingMemory workingMemory
          Working memory of this Agenda.
 
Constructor Summary
ReteAgenda()
           
ReteAgenda(org.drools.core.common.InternalRuleBase rb)
          Construct.
ReteAgenda(org.drools.core.common.InternalRuleBase rb, boolean initMain)
          Construct.
 
Method Summary
 void activateRuleFlowGroup(org.drools.core.common.InternalRuleFlowGroup group, long processInstanceId, String nodeInstanceId)
           
 void activateRuleFlowGroup(String name)
           
 void activateRuleFlowGroup(String name, long processInstanceId, String nodeInstanceId)
           
 boolean addActivation(org.drools.core.common.AgendaItem activation)
           
 void addActivation(org.drools.core.common.AgendaItem item, boolean notify)
           
 void addAgendaGroup(org.drools.core.spi.AgendaGroup agendaGroup)
           
 void addAgendaGroupOnStack(org.drools.core.spi.AgendaGroup agendaGroup)
           
 void addAgendaItemToGroup(org.drools.core.common.AgendaItem item)
           
 void addEagerRuleAgendaItem(org.drools.core.phreak.RuleAgendaItem item)
           
 void addItemToActivationGroup(org.drools.core.common.AgendaItem item)
          If the item belongs to an activation group, add it
 int agendaSize()
           
 void cancelActivation(org.drools.core.reteoo.LeftTuple leftTuple, org.drools.core.spi.PropagationContext context, org.drools.core.common.InternalWorkingMemory workingMemory, org.drools.core.spi.Activation activation, org.drools.core.reteoo.TerminalNode rtn)
           
 void clear()
           
 void clearAndCancel()
           
 void clearAndCancelActivationGroup(org.drools.core.spi.ActivationGroup activationGroup)
           
 void clearAndCancelActivationGroup(String name)
           
 void clearAndCancelAgendaGroup(org.drools.core.spi.AgendaGroup agendaGroup)
           
 void clearAndCancelAgendaGroup(String name)
           
 void clearAndCancelAndCancel(org.drools.core.spi.RuleFlowGroup ruleFlowGroup)
           
 void clearAndCancelRuleFlowGroup(String name)
           
 void clearAndCancelStagedActivations()
           
 boolean continueFiring(int fireLimit)
           
 boolean createActivation(org.drools.core.reteoo.LeftTuple tuple, org.drools.core.spi.PropagationContext context, org.drools.core.common.InternalWorkingMemory workingMemory, org.drools.core.reteoo.TerminalNode rtn)
           
 org.drools.core.common.AgendaItem createAgendaItem(org.drools.core.reteoo.LeftTuple tuple, int salience, org.drools.core.spi.PropagationContext context, org.drools.core.reteoo.TerminalNode rtn, org.drools.core.phreak.RuleAgendaItem ruleAgendaItem, org.drools.core.common.InternalAgendaGroup agendaGroup)
           
 boolean createPostponedActivation(org.drools.core.reteoo.LeftTuple tuple, org.drools.core.spi.PropagationContext context, org.drools.core.common.InternalWorkingMemory workingMemory, org.drools.core.reteoo.TerminalNode rtn)
           
 org.drools.core.phreak.RuleAgendaItem createRuleAgendaItem(int salience, org.drools.core.reteoo.PathMemory rs, org.drools.core.reteoo.TerminalNode rtn)
           
 org.drools.core.common.ScheduledAgendaItem createScheduledAgendaItem(org.drools.core.reteoo.LeftTuple tuple, org.drools.core.spi.PropagationContext context, org.drools.core.reteoo.TerminalNode rtn, org.drools.core.common.InternalAgendaGroup agendaGroup)
           
 void deactivateRuleFlowGroup(org.drools.core.common.InternalRuleFlowGroup group)
           
 void deactivateRuleFlowGroup(String name)
           
 void evaluateEagerList()
           
 void fireActivation(org.drools.core.spi.Activation activation)
          Fire this item.
 int fireAllRules(org.drools.core.spi.AgendaFilter agendaFilter, int fireLimit)
           
 int fireNextItem(org.drools.core.spi.AgendaFilter filter, int fireCount, int fireLimit)
          Fire the next scheduled Agenda item, skipping items that are not allowed by the agenda filter.
 boolean fireTimedActivation(org.drools.core.spi.Activation activation, boolean saveForLater)
           
 void fireUntilHalt()
           
 void fireUntilHalt(org.drools.core.spi.AgendaFilter agendaFilter)
           
 int focusStackSize()
           
 org.drools.core.spi.ActivationGroup getActivationGroup(String name)
           
 Map<String,org.drools.core.spi.ActivationGroup> getActivationGroupsMap()
           
 org.drools.core.spi.Activation[] getActivations()
           
 org.drools.core.common.ActivationsFilter getActivationsFilter()
           
 org.drools.core.spi.AgendaGroup getAgendaGroup(String name)
           
 org.drools.core.spi.AgendaGroup getAgendaGroup(String name, org.drools.core.common.InternalRuleBase ruleBase)
           
 org.drools.core.spi.AgendaGroup[] getAgendaGroups()
           
 Map<String,org.drools.core.common.InternalAgendaGroup> getAgendaGroupsMap()
           
 org.drools.core.spi.ConsequenceExceptionHandler getConsequenceExceptionHandler()
           
 org.drools.core.spi.AgendaGroup getCurrentAgendaGroup()
           
 org.drools.core.spi.AgendaGroup getFocus()
           
 String getFocusName()
           
 org.drools.core.common.InternalAgendaGroup getMainAgendaGroup()
           
 long getNextActivationCounter()
           
 org.drools.core.common.InternalAgendaGroup getNextFocus()
           
 org.drools.core.spi.RuleFlowGroup getRuleFlowGroup(String name)
           
 org.drools.core.spi.Activation[] getScheduledActivations()
           
 org.drools.core.util.LinkedList<org.drools.core.common.ScheduledAgendaItem> getScheduledActivationsLinkedList()
           
 org.drools.core.spi.AgendaGroup[] getStack()
           
 LinkedList<org.drools.core.spi.AgendaGroup> getStackList()
           
 org.drools.core.spi.ActivationGroup getStageActivationsGroup()
           
 org.drools.core.WorkingMemory getWorkingMemory()
           
 void halt()
           
 void insertAndStageActivation(org.drools.core.common.AgendaItem activation)
           
 boolean isDeclarativeAgenda()
           
 boolean isFireUntilHalt()
           
 boolean isRuleInstanceAgendaItem(String ruleflowGroupName, String ruleName, long processInstanceId)
           
 void modifyActivation(org.drools.core.common.AgendaItem activation, boolean previouslyActive)
           
 void notifyHalt()
           
 org.drools.core.phreak.RuleAgendaItem peekNextRule()
           
 void readExternal(ObjectInput in)
           
 void removeActivation(org.drools.core.common.AgendaItem activation)
           
 void removeEagerRuleAgendaItem(org.drools.core.phreak.RuleAgendaItem item)
           
 void removeScheduleItem(org.drools.core.common.ScheduledAgendaItem item)
           
 void scheduleItem(org.drools.core.common.ScheduledAgendaItem item, org.drools.core.common.InternalWorkingMemory wm)
          Schedule an agenda item for delayed firing.
 void setActivationsFilter(org.drools.core.common.ActivationsFilter filter)
           
 void setCurrentAgendaGroup(org.drools.core.common.InternalAgendaGroup agendaGroup)
           
 boolean setFocus(org.drools.core.spi.AgendaGroup agendaGroup)
           
 void setFocus(org.drools.core.spi.PropagationContext ctx, String name)
           
 void setFocus(String name)
           
 void setWorkingMemory(org.drools.core.common.InternalWorkingMemory workingMemory)
           
 int sizeOfRuleFlowGroup(String name)
           
 void stageLeftTuple(org.drools.core.phreak.RuleAgendaItem ruleAgendaItem, org.drools.core.common.AgendaItem justified)
           
 int unstageActivations()
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static transient org.slf4j.Logger log

workingMemory

protected org.drools.core.common.InternalWorkingMemory workingMemory
Working memory of this Agenda.


knowledgeHelper

protected org.drools.core.spi.KnowledgeHelper knowledgeHelper

halt

protected volatile AtomicBoolean halt

activationCounter

protected int activationCounter
Constructor Detail

ReteAgenda

public ReteAgenda()

ReteAgenda

public ReteAgenda(org.drools.core.common.InternalRuleBase rb)
Construct.

Parameters:
rb - The InternalRuleBase of this agenda.

ReteAgenda

public ReteAgenda(org.drools.core.common.InternalRuleBase rb,
                  boolean initMain)
Construct.

Parameters:
rb - The InternalRuleBase of this agenda.
initMain - Flag to initialize the MAIN agenda group
Method Detail

createRuleAgendaItem

public org.drools.core.phreak.RuleAgendaItem createRuleAgendaItem(int salience,
                                                                  org.drools.core.reteoo.PathMemory rs,
                                                                  org.drools.core.reteoo.TerminalNode rtn)
Specified by:
createRuleAgendaItem in interface org.drools.core.common.InternalAgenda

getNextActivationCounter

public long getNextActivationCounter()
Specified by:
getNextActivationCounter in interface org.drools.core.common.InternalAgenda

createAgendaItem

public org.drools.core.common.AgendaItem createAgendaItem(org.drools.core.reteoo.LeftTuple tuple,
                                                          int salience,
                                                          org.drools.core.spi.PropagationContext context,
                                                          org.drools.core.reteoo.TerminalNode rtn,
                                                          org.drools.core.phreak.RuleAgendaItem ruleAgendaItem,
                                                          org.drools.core.common.InternalAgendaGroup agendaGroup)
Specified by:
createAgendaItem in interface org.drools.core.common.InternalAgenda

createScheduledAgendaItem

public org.drools.core.common.ScheduledAgendaItem createScheduledAgendaItem(org.drools.core.reteoo.LeftTuple tuple,
                                                                            org.drools.core.spi.PropagationContext context,
                                                                            org.drools.core.reteoo.TerminalNode rtn,
                                                                            org.drools.core.common.InternalAgendaGroup agendaGroup)
Specified by:
createScheduledAgendaItem in interface org.drools.core.common.InternalAgenda

setWorkingMemory

public void setWorkingMemory(org.drools.core.common.InternalWorkingMemory workingMemory)
Specified by:
setWorkingMemory in interface org.drools.core.common.InternalAgenda

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

getWorkingMemory

public org.drools.core.WorkingMemory getWorkingMemory()

addEagerRuleAgendaItem

public void addEagerRuleAgendaItem(org.drools.core.phreak.RuleAgendaItem item)
Specified by:
addEagerRuleAgendaItem in interface org.drools.core.common.InternalAgenda

removeEagerRuleAgendaItem

public void removeEagerRuleAgendaItem(org.drools.core.phreak.RuleAgendaItem item)
Specified by:
removeEagerRuleAgendaItem in interface org.drools.core.common.InternalAgenda

scheduleItem

public void scheduleItem(org.drools.core.common.ScheduledAgendaItem item,
                         org.drools.core.common.InternalWorkingMemory wm)
Schedule an agenda item for delayed firing.

Specified by:
scheduleItem in interface org.drools.core.common.InternalAgenda
Parameters:
item - The item to schedule.

addItemToActivationGroup

public void addItemToActivationGroup(org.drools.core.common.AgendaItem item)
If the item belongs to an activation group, add it

Specified by:
addItemToActivationGroup in interface org.drools.core.common.InternalAgenda
Parameters:
item -

getStageActivationsGroup

public org.drools.core.spi.ActivationGroup getStageActivationsGroup()

insertAndStageActivation

public void insertAndStageActivation(org.drools.core.common.AgendaItem activation)
Specified by:
insertAndStageActivation in interface org.drools.core.common.InternalAgenda

addActivation

public boolean addActivation(org.drools.core.common.AgendaItem activation)
Specified by:
addActivation in interface org.drools.core.common.InternalAgenda

isDeclarativeAgenda

public boolean isDeclarativeAgenda()
Specified by:
isDeclarativeAgenda in interface org.drools.core.common.InternalAgenda

removeActivation

public void removeActivation(org.drools.core.common.AgendaItem activation)
Specified by:
removeActivation in interface org.drools.core.common.InternalAgenda

modifyActivation

public void modifyActivation(org.drools.core.common.AgendaItem activation,
                             boolean previouslyActive)
Specified by:
modifyActivation in interface org.drools.core.common.InternalAgenda

clearAndCancelStagedActivations

public void clearAndCancelStagedActivations()

unstageActivations

public int unstageActivations()

addActivation

public void addActivation(org.drools.core.common.AgendaItem item,
                          boolean notify)

addAgendaItemToGroup

public void addAgendaItemToGroup(org.drools.core.common.AgendaItem item)
Specified by:
addAgendaItemToGroup in interface org.drools.core.common.InternalAgenda

removeScheduleItem

public void removeScheduleItem(org.drools.core.common.ScheduledAgendaItem item)
Specified by:
removeScheduleItem in interface org.drools.core.common.InternalAgenda

addAgendaGroup

public void addAgendaGroup(org.drools.core.spi.AgendaGroup agendaGroup)
Specified by:
addAgendaGroup in interface org.drools.core.common.InternalAgenda

createActivation

public boolean createActivation(org.drools.core.reteoo.LeftTuple tuple,
                                org.drools.core.spi.PropagationContext context,
                                org.drools.core.common.InternalWorkingMemory workingMemory,
                                org.drools.core.reteoo.TerminalNode rtn)
Specified by:
createActivation in interface org.drools.core.common.InternalAgenda

createPostponedActivation

public boolean createPostponedActivation(org.drools.core.reteoo.LeftTuple tuple,
                                         org.drools.core.spi.PropagationContext context,
                                         org.drools.core.common.InternalWorkingMemory workingMemory,
                                         org.drools.core.reteoo.TerminalNode rtn)
Specified by:
createPostponedActivation in interface org.drools.core.common.InternalAgenda

cancelActivation

public void cancelActivation(org.drools.core.reteoo.LeftTuple leftTuple,
                             org.drools.core.spi.PropagationContext context,
                             org.drools.core.common.InternalWorkingMemory workingMemory,
                             org.drools.core.spi.Activation activation,
                             org.drools.core.reteoo.TerminalNode rtn)
Specified by:
cancelActivation in interface org.drools.core.common.InternalAgenda

setFocus

public boolean setFocus(org.drools.core.spi.AgendaGroup agendaGroup)
Specified by:
setFocus in interface org.drools.core.common.InternalAgenda

setFocus

public void setFocus(String name)

setFocus

public void setFocus(org.drools.core.spi.PropagationContext ctx,
                     String name)

getFocus

public org.drools.core.spi.AgendaGroup getFocus()
Specified by:
getFocus in interface org.drools.core.common.InternalAgenda

getNextFocus

public org.drools.core.common.InternalAgendaGroup getNextFocus()
Specified by:
getNextFocus in interface org.drools.core.common.InternalAgenda

peekNextRule

public org.drools.core.phreak.RuleAgendaItem peekNextRule()
Specified by:
peekNextRule in interface org.drools.core.common.InternalAgenda

setCurrentAgendaGroup

public void setCurrentAgendaGroup(org.drools.core.common.InternalAgendaGroup agendaGroup)

getCurrentAgendaGroup

public org.drools.core.spi.AgendaGroup getCurrentAgendaGroup()

getAgendaGroup

public org.drools.core.spi.AgendaGroup getAgendaGroup(String name)
Specified by:
getAgendaGroup in interface org.drools.core.common.InternalAgenda
Specified by:
getAgendaGroup in interface org.kie.api.runtime.rule.Agenda

getAgendaGroup

public org.drools.core.spi.AgendaGroup getAgendaGroup(String name,
                                                      org.drools.core.common.InternalRuleBase ruleBase)
Specified by:
getAgendaGroup in interface org.drools.core.common.InternalAgenda

getAgendaGroups

public org.drools.core.spi.AgendaGroup[] getAgendaGroups()

getAgendaGroupsMap

public Map<String,org.drools.core.common.InternalAgendaGroup> getAgendaGroupsMap()
Specified by:
getAgendaGroupsMap in interface org.drools.core.common.InternalAgenda

getMainAgendaGroup

public org.drools.core.common.InternalAgendaGroup getMainAgendaGroup()

getStack

public org.drools.core.spi.AgendaGroup[] getStack()

getStackList

public LinkedList<org.drools.core.spi.AgendaGroup> getStackList()
Specified by:
getStackList in interface org.drools.core.common.InternalAgenda

addAgendaGroupOnStack

public void addAgendaGroupOnStack(org.drools.core.spi.AgendaGroup agendaGroup)
Specified by:
addAgendaGroupOnStack in interface org.drools.core.common.InternalAgenda

getActivationGroupsMap

public Map<String,org.drools.core.spi.ActivationGroup> getActivationGroupsMap()
Specified by:
getActivationGroupsMap in interface org.drools.core.common.InternalAgenda

getActivationGroup

public org.drools.core.spi.ActivationGroup getActivationGroup(String name)
Specified by:
getActivationGroup in interface org.drools.core.common.InternalAgenda
Specified by:
getActivationGroup in interface org.kie.api.runtime.rule.Agenda

getRuleFlowGroup

public org.drools.core.spi.RuleFlowGroup getRuleFlowGroup(String name)
Specified by:
getRuleFlowGroup in interface org.drools.core.common.InternalAgenda
Specified by:
getRuleFlowGroup in interface org.kie.api.runtime.rule.Agenda

activateRuleFlowGroup

public void activateRuleFlowGroup(String name)

activateRuleFlowGroup

public void activateRuleFlowGroup(String name,
                                  long processInstanceId,
                                  String nodeInstanceId)

activateRuleFlowGroup

public void activateRuleFlowGroup(org.drools.core.common.InternalRuleFlowGroup group,
                                  long processInstanceId,
                                  String nodeInstanceId)

deactivateRuleFlowGroup

public void deactivateRuleFlowGroup(String name)

deactivateRuleFlowGroup

public void deactivateRuleFlowGroup(org.drools.core.common.InternalRuleFlowGroup group)

focusStackSize

public int focusStackSize()

agendaSize

public int agendaSize()

getActivations

public org.drools.core.spi.Activation[] getActivations()

getScheduledActivations

public org.drools.core.spi.Activation[] getScheduledActivations()

getScheduledActivationsLinkedList

public org.drools.core.util.LinkedList<org.drools.core.common.ScheduledAgendaItem> getScheduledActivationsLinkedList()
Specified by:
getScheduledActivationsLinkedList in interface org.drools.core.common.InternalAgenda

clear

public void clear()
Specified by:
clear in interface org.drools.core.common.InternalAgenda
Specified by:
clear in interface org.kie.api.runtime.rule.Agenda

clearAndCancel

public void clearAndCancel()

clearAndCancelAgendaGroup

public void clearAndCancelAgendaGroup(String name)

clearAndCancelAgendaGroup

public void clearAndCancelAgendaGroup(org.drools.core.spi.AgendaGroup agendaGroup)

clearAndCancelActivationGroup

public void clearAndCancelActivationGroup(String name)

clearAndCancelActivationGroup

public void clearAndCancelActivationGroup(org.drools.core.spi.ActivationGroup activationGroup)

clearAndCancelRuleFlowGroup

public void clearAndCancelRuleFlowGroup(String name)

clearAndCancelAndCancel

public void clearAndCancelAndCancel(org.drools.core.spi.RuleFlowGroup ruleFlowGroup)

fireNextItem

public int fireNextItem(org.drools.core.spi.AgendaFilter filter,
                        int fireCount,
                        int fireLimit)
                 throws org.drools.core.spi.ConsequenceException
Fire the next scheduled Agenda item, skipping items that are not allowed by the agenda filter.

Specified by:
fireNextItem in interface org.drools.core.common.InternalAgenda
Returns:
true if an activation was fired. false if no more activations to fire
Throws:
org.drools.core.spi.ConsequenceException - If an error occurs while firing an agenda item.

evaluateEagerList

public void evaluateEagerList()
Specified by:
evaluateEagerList in interface org.drools.core.common.InternalAgenda

sizeOfRuleFlowGroup

public int sizeOfRuleFlowGroup(String name)
Specified by:
sizeOfRuleFlowGroup in interface org.drools.core.common.InternalAgenda

fireActivation

public void fireActivation(org.drools.core.spi.Activation activation)
                    throws org.drools.core.spi.ConsequenceException
Fire this item.

Specified by:
fireActivation in interface org.drools.core.common.InternalAgenda
Parameters:
activation - The activation to fire
Throws:
org.drools.core.spi.ConsequenceException - If an error occurs while attempting to fire the consequence.

fireTimedActivation

public boolean fireTimedActivation(org.drools.core.spi.Activation activation,
                                   boolean saveForLater)
                            throws org.drools.core.spi.ConsequenceException
Specified by:
fireTimedActivation in interface org.drools.core.common.InternalAgenda
Throws:
org.drools.core.spi.ConsequenceException

isRuleInstanceAgendaItem

public boolean isRuleInstanceAgendaItem(String ruleflowGroupName,
                                        String ruleName,
                                        long processInstanceId)
Specified by:
isRuleInstanceAgendaItem in interface org.drools.core.common.InternalAgenda

getFocusName

public String getFocusName()

isFireUntilHalt

public boolean isFireUntilHalt()
Specified by:
isFireUntilHalt in interface org.drools.core.common.InternalAgenda

stageLeftTuple

public void stageLeftTuple(org.drools.core.phreak.RuleAgendaItem ruleAgendaItem,
                           org.drools.core.common.AgendaItem justified)
Specified by:
stageLeftTuple in interface org.drools.core.common.InternalAgenda

fireUntilHalt

public void fireUntilHalt()
Specified by:
fireUntilHalt in interface org.drools.core.common.InternalAgenda

fireUntilHalt

public void fireUntilHalt(org.drools.core.spi.AgendaFilter agendaFilter)
Specified by:
fireUntilHalt in interface org.drools.core.common.InternalAgenda

fireAllRules

public int fireAllRules(org.drools.core.spi.AgendaFilter agendaFilter,
                        int fireLimit)
Specified by:
fireAllRules in interface org.drools.core.common.InternalAgenda

continueFiring

public boolean continueFiring(int fireLimit)
Specified by:
continueFiring in interface org.drools.core.common.InternalAgenda

notifyHalt

public void notifyHalt()
Specified by:
notifyHalt in interface org.drools.core.common.InternalAgenda

halt

public void halt()
Specified by:
halt in interface org.drools.core.common.InternalAgenda

getConsequenceExceptionHandler

public org.drools.core.spi.ConsequenceExceptionHandler getConsequenceExceptionHandler()

setActivationsFilter

public void setActivationsFilter(org.drools.core.common.ActivationsFilter filter)
Specified by:
setActivationsFilter in interface org.drools.core.common.InternalAgenda

getActivationsFilter

public org.drools.core.common.ActivationsFilter getActivationsFilter()
Specified by:
getActivationsFilter in interface org.drools.core.common.InternalAgenda

Drools :: ReteOO 6.0.0.CR2

Copyright © 2001-2013 JBoss by Red Hat. All Rights Reserved.