public class DefaultAgenda extends Object implements Externalizable, InternalAgenda
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.
| Modifier and Type | Field and Description |
|---|---|
protected int |
activationCounter |
protected static org.slf4j.Logger |
log |
static String |
ON_AFTER_ALL_FIRES_CONSEQUENCE_NAME |
static String |
ON_BEFORE_ALL_FIRES_CONSEQUENCE_NAME |
static String |
ON_DELETE_MATCH_CONSEQUENCE_NAME |
protected InternalWorkingMemory |
workingMemory
Working memory of this Agenda.
|
| Constructor and Description |
|---|
DefaultAgenda() |
DefaultAgenda(InternalKnowledgeBase kBase) |
DefaultAgenda(InternalKnowledgeBase kBase,
boolean initMain) |
| Modifier and Type | Method and Description |
|---|---|
void |
activate() |
void |
activateRuleFlowGroup(InternalRuleFlowGroup group,
long processInstanceId,
String nodeInstanceId) |
void |
activateRuleFlowGroup(String name)
Activates the
RuleFlowGroup with the given name. |
void |
activateRuleFlowGroup(String name,
long processInstanceId,
String nodeInstanceId)
Activates the
RuleFlowGroup with the given name. |
void |
addAgendaGroup(AgendaGroup agendaGroup) |
void |
addAgendaGroupOnStack(AgendaGroup agendaGroup) |
void |
addEagerRuleAgendaItem(RuleAgendaItem item) |
void |
addItemToActivationGroup(AgendaItem item)
If the item belongs to an activation group, add it
|
void |
addPropagation(PropagationEntry propagationEntry) |
void |
addQueryAgendaItem(RuleAgendaItem item) |
int |
agendaSize()
Iterates all the modules in the focus stack returning the total number of
Activations |
void |
cancelActivation(Tuple leftTuple,
PropagationContext context,
Activation activation,
TerminalNode rtn) |
void |
clear() |
void |
clearAndCancel()
Clears all Activations from the Agenda
|
void |
clearAndCancelActivationGroup(InternalActivationGroup activationGroup)
Clears all Activations from an Activation Group.
|
void |
clearAndCancelActivationGroup(String name)
Clears all Activations from an Activation-Group.
|
void |
clearAndCancelAgendaGroup(InternalAgendaGroup agendaGroup)
Clears all Activations from an Agenda Group.
|
void |
clearAndCancelAgendaGroup(String name)
Clears all Activations from an Agenda Group.
|
void |
clearAndCancelRuleFlowGroup(String name) |
AgendaItem |
createAgendaItem(RuleTerminalNodeLeftTuple rtnLeftTuple,
int salience,
PropagationContext context,
RuleAgendaItem ruleAgendaItem,
InternalAgendaGroup agendaGroup) |
RuleAgendaItem |
createRuleAgendaItem(int salience,
PathMemory rs,
TerminalNode rtn) |
void |
deactivate() |
void |
deactivateRuleFlowGroup(InternalRuleFlowGroup group) |
void |
deactivateRuleFlowGroup(String name)
Deactivates the
RuleFlowGroup with the given name. |
boolean |
dispose(InternalWorkingMemory wm) |
protected void |
doRetract(PropagationContext ectx) |
void |
evaluateEagerList() |
void |
evaluateQueriesForRule(RuleAgendaItem item) |
void |
executeFlush() |
void |
executeTask(ExecutableEntry executable) |
int |
fireAllRules(org.kie.api.runtime.rule.AgendaFilter agendaFilter,
int fireLimit)
Fires all activations currently in agenda that match the given agendaFilter
until the fireLimit is reached or no more activations exist.
|
int |
fireNextItem(org.kie.api.runtime.rule.AgendaFilter filter,
int fireCount,
int fireLimit)
Fire the next scheduled
Agenda item, skipping items
that are not allowed by the agenda filter. |
void |
fireUntilHalt()
Keeps firing activations until a halt is called.
|
void |
fireUntilHalt(org.kie.api.runtime.rule.AgendaFilter agendaFilter)
Keeps firing activations until a halt is called.
|
void |
flushPropagations() |
int |
focusStackSize()
Iterates all the
AgendGroup |
Iterator<PropagationEntry> |
getActionsIterator() |
InternalActivationGroup |
getActivationGroup(String name) |
Map<String,InternalActivationGroup> |
getActivationGroupsMap() |
Activation[] |
getActivations() |
ActivationsFilter |
getActivationsFilter()
Returns the current activations filter or null if none is set
|
AgendaGroup |
getAgendaGroup(String name) |
AgendaGroup |
getAgendaGroup(String name,
InternalKnowledgeBase kBase) |
AgendaGroup[] |
getAgendaGroups() |
Map<String,InternalAgendaGroup> |
getAgendaGroupsMap() |
AgendaGroup |
getFocus() |
String |
getFocusName()
Returns the name of the agenda group that currently
has the focus
|
KnowledgeHelper |
getKnowledgeHelper() |
InternalAgendaGroup |
getNextFocus() |
PropagationList |
getPropagationList() |
RuleFlowGroup |
getRuleFlowGroup(String name) |
AgendaGroup[] |
getStack() |
LinkedList<AgendaGroup> |
getStackList() |
InternalWorkingMemory |
getWorkingMemory()
Returns the WorkignMemory for this Agenda
|
void |
halt()
Stop agenda from firing any other rule.
|
void |
handleException(InternalWorkingMemory wm,
Activation activation,
Exception e) |
boolean |
hasPendingPropagations() |
void |
insertAndStageActivation(AgendaItem activation) |
void |
internalHalt() |
boolean |
isAlive() |
boolean |
isDeclarativeAgenda() |
boolean |
isFiring() |
boolean |
isParallelAgenda() |
boolean |
isRuleActiveInRuleFlowGroup(String ruleflowGroupName,
String ruleName,
long processInstanceId) |
boolean |
isRuleInstanceAgendaItem(String ruleflowGroupName,
String ruleName,
long processInstanceId)
Returns true if there is at least one activation of the given rule name
in the given ruleflow group name
|
void |
modifyActivation(AgendaItem activation,
boolean previouslyActive)
Adds the activation to the agenda.
|
void |
notifyWaitOnRest() |
RuleAgendaItem |
peekNextRule() |
void |
readExternal(ObjectInput in) |
void |
registerExpiration(PropagationContext ectx) |
void |
removeEagerRuleAgendaItem(RuleAgendaItem item) |
void |
removeQueryAgendaItem(RuleAgendaItem item) |
void |
reset() |
void |
setActivationsFilter(ActivationsFilter filter)
Sets a filter that prevents activations from being added to
the agenda.
|
boolean |
setFocus(AgendaGroup agendaGroup) |
void |
setFocus(PropagationContext ctx,
String name) |
void |
setFocus(String name)
Sets the Agenda's focus to the specified AgendaGroup
|
void |
setWorkingMemory(InternalWorkingMemory workingMemory) |
int |
sizeOfRuleFlowGroup(String name) |
void |
stageLeftTuple(RuleAgendaItem ruleAgendaItem,
AgendaItem justified) |
boolean |
tryDeactivate() |
void |
writeExternal(ObjectOutput out) |
public static final String ON_BEFORE_ALL_FIRES_CONSEQUENCE_NAME
public static final String ON_AFTER_ALL_FIRES_CONSEQUENCE_NAME
public static final String ON_DELETE_MATCH_CONSEQUENCE_NAME
protected static final transient org.slf4j.Logger log
protected InternalWorkingMemory workingMemory
protected int activationCounter
public DefaultAgenda()
public DefaultAgenda(InternalKnowledgeBase kBase)
public DefaultAgenda(InternalKnowledgeBase kBase, boolean initMain)
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic RuleAgendaItem createRuleAgendaItem(int salience, PathMemory rs, TerminalNode rtn)
createRuleAgendaItem in interface InternalAgendapublic AgendaItem createAgendaItem(RuleTerminalNodeLeftTuple rtnLeftTuple, int salience, PropagationContext context, RuleAgendaItem ruleAgendaItem, InternalAgendaGroup agendaGroup)
createAgendaItem in interface InternalAgendapublic void setWorkingMemory(InternalWorkingMemory workingMemory)
setWorkingMemory in interface InternalAgendapublic PropagationList getPropagationList()
getPropagationList in interface InternalAgendapublic InternalWorkingMemory getWorkingMemory()
InternalAgendagetWorkingMemory in interface InternalAgendapublic void addEagerRuleAgendaItem(RuleAgendaItem item)
addEagerRuleAgendaItem in interface InternalAgendapublic void removeEagerRuleAgendaItem(RuleAgendaItem item)
removeEagerRuleAgendaItem in interface InternalAgendapublic void addQueryAgendaItem(RuleAgendaItem item)
addQueryAgendaItem in interface InternalAgendapublic void removeQueryAgendaItem(RuleAgendaItem item)
removeQueryAgendaItem in interface InternalAgendapublic void addItemToActivationGroup(AgendaItem item)
addItemToActivationGroup in interface InternalAgendaitem - public void insertAndStageActivation(AgendaItem activation)
insertAndStageActivation in interface InternalAgendapublic boolean isDeclarativeAgenda()
isDeclarativeAgenda in interface InternalAgendapublic void modifyActivation(AgendaItem activation, boolean previouslyActive)
InternalAgendamodifyActivation in interface InternalAgendapublic void addAgendaGroup(AgendaGroup agendaGroup)
addAgendaGroup in interface InternalAgendapublic boolean isRuleActiveInRuleFlowGroup(String ruleflowGroupName, String ruleName, long processInstanceId)
isRuleActiveInRuleFlowGroup in interface InternalAgendapublic void cancelActivation(Tuple leftTuple, PropagationContext context, Activation activation, TerminalNode rtn)
cancelActivation in interface InternalAgendapublic boolean setFocus(AgendaGroup agendaGroup)
setFocus in interface InternalAgendapublic void setFocus(String name)
InternalAgendasetFocus in interface InternalAgendapublic void setFocus(PropagationContext ctx, String name)
public AgendaGroup getFocus()
getFocus in interface InternalAgendapublic InternalAgendaGroup getNextFocus()
getNextFocus in interface InternalAgendapublic RuleAgendaItem peekNextRule()
peekNextRule in interface InternalAgendapublic AgendaGroup getAgendaGroup(String name)
getAgendaGroup in interface InternalAgendagetAgendaGroup in interface org.kie.api.runtime.rule.Agendapublic AgendaGroup getAgendaGroup(String name, InternalKnowledgeBase kBase)
getAgendaGroup in interface InternalAgendapublic AgendaGroup[] getAgendaGroups()
getAgendaGroups in interface InternalAgendapublic Map<String,InternalAgendaGroup> getAgendaGroupsMap()
getAgendaGroupsMap in interface InternalAgendapublic AgendaGroup[] getStack()
getStack in interface InternalAgendapublic LinkedList<AgendaGroup> getStackList()
getStackList in interface InternalAgendapublic void addAgendaGroupOnStack(AgendaGroup agendaGroup)
addAgendaGroupOnStack in interface InternalAgendapublic Map<String,InternalActivationGroup> getActivationGroupsMap()
getActivationGroupsMap in interface InternalAgendapublic InternalActivationGroup getActivationGroup(String name)
getActivationGroup in interface InternalAgendagetActivationGroup in interface org.kie.api.runtime.rule.Agendapublic RuleFlowGroup getRuleFlowGroup(String name)
getRuleFlowGroup in interface InternalAgendagetRuleFlowGroup in interface org.kie.api.runtime.rule.Agendapublic void activateRuleFlowGroup(String name)
InternalAgendaRuleFlowGroup with the given name.
All activations in the given RuleFlowGroup are added to the agenda.
As long as the RuleFlowGroup remains active,
its activations are automatically added to the agenda.activateRuleFlowGroup in interface InternalAgendapublic void activateRuleFlowGroup(String name, long processInstanceId, String nodeInstanceId)
InternalAgendaRuleFlowGroup with the given name.
All activations in the given RuleFlowGroup are added to the agenda.
As long as the RuleFlowGroup remains active,
its activations are automatically added to the agenda.
The given processInstanceId and nodeInstanceId define the process context
in which this RuleFlowGroup is used.activateRuleFlowGroup in interface InternalAgendapublic void activateRuleFlowGroup(InternalRuleFlowGroup group, long processInstanceId, String nodeInstanceId)
public void deactivateRuleFlowGroup(String name)
InternalAgendaRuleFlowGroup with the given name.
All activations in the given RuleFlowGroup are removed from the agenda.
As long as the RuleFlowGroup remains deactive,
its activations are not added to the agendadeactivateRuleFlowGroup in interface InternalAgendapublic void deactivateRuleFlowGroup(InternalRuleFlowGroup group)
public int focusStackSize()
InternalAgendaAgendGroups in the focus stack returning the total number of ActivationsfocusStackSize in interface InternalAgendaActivations on the focus stackpublic int agendaSize()
InternalAgendaActivationsagendaSize in interface InternalAgendapublic Activation[] getActivations()
getActivations in interface InternalAgendapublic void clear()
clear in interface org.kie.api.runtime.rule.Agendapublic void reset()
reset in interface InternalAgendapublic void clearAndCancel()
InternalAgendaclearAndCancel in interface InternalAgendapublic void clearAndCancelAgendaGroup(String name)
InternalAgendaclearAndCancelAgendaGroup in interface InternalAgendapublic void clearAndCancelAgendaGroup(InternalAgendaGroup agendaGroup)
InternalAgendaclearAndCancelAgendaGroup in interface InternalAgendapublic void clearAndCancelActivationGroup(String name)
InternalAgendaclearAndCancelActivationGroup in interface InternalAgendapublic void clearAndCancelActivationGroup(InternalActivationGroup activationGroup)
InternalAgendaclearAndCancelActivationGroup in interface InternalAgendapublic void clearAndCancelRuleFlowGroup(String name)
clearAndCancelRuleFlowGroup in interface InternalAgendapublic int fireNextItem(org.kie.api.runtime.rule.AgendaFilter filter,
int fireCount,
int fireLimit)
throws ConsequenceException
Agenda item, skipping items
that are not allowed by the agenda filter.fireNextItem in interface InternalAgendaConsequenceException - If an error occurs while firing an agenda item.public void evaluateEagerList()
evaluateEagerList in interface InternalAgendapublic void evaluateQueriesForRule(RuleAgendaItem item)
public int sizeOfRuleFlowGroup(String name)
sizeOfRuleFlowGroup in interface InternalAgendapublic boolean isRuleInstanceAgendaItem(String ruleflowGroupName, String ruleName, long processInstanceId)
InternalAgendaisRuleInstanceAgendaItem in interface InternalAgendapublic String getFocusName()
InternalAgendagetFocusName in interface InternalAgendapublic void stageLeftTuple(RuleAgendaItem ruleAgendaItem, AgendaItem justified)
stageLeftTuple in interface InternalAgendapublic void fireUntilHalt()
InternalAgendafireUntilHalt in interface InternalAgendapublic void fireUntilHalt(org.kie.api.runtime.rule.AgendaFilter agendaFilter)
InternalAgendafireUntilHalt in interface InternalAgendaagendaFilter - filters the activations that may firepublic int fireAllRules(org.kie.api.runtime.rule.AgendaFilter agendaFilter,
int fireLimit)
InternalAgendafireAllRules in interface InternalAgendaagendaFilter - the filter on which activations may fire.fireLimit - the maximum number of activations that may fire. If -1, then it will
fire until no more activations exist.public boolean isFiring()
isFiring in interface InternalAgendapublic void executeTask(ExecutableEntry executable)
executeTask in interface InternalAgendapublic void executeFlush()
executeFlush in interface InternalAgendapublic void activate()
activate in interface InternalAgendapublic void deactivate()
deactivate in interface InternalAgendapublic boolean tryDeactivate()
tryDeactivate in interface InternalAgendapublic void halt()
InternalAgendahalt in interface InternalAgendapublic boolean dispose(InternalWorkingMemory wm)
dispose in interface InternalAgendapublic boolean isAlive()
isAlive in interface InternalAgendapublic void internalHalt()
public void setActivationsFilter(ActivationsFilter filter)
InternalAgendasetActivationsFilter in interface InternalAgendapublic ActivationsFilter getActivationsFilter()
InternalAgendagetActivationsFilter in interface InternalAgendapublic void handleException(InternalWorkingMemory wm, Activation activation, Exception e)
handleException in interface InternalAgendapublic KnowledgeHelper getKnowledgeHelper()
getKnowledgeHelper in interface InternalAgendapublic void addPropagation(PropagationEntry propagationEntry)
addPropagation in interface InternalAgendapublic void flushPropagations()
flushPropagations in interface InternalAgendapublic void notifyWaitOnRest()
notifyWaitOnRest in interface InternalAgendapublic Iterator<PropagationEntry> getActionsIterator()
getActionsIterator in interface InternalAgendapublic boolean hasPendingPropagations()
hasPendingPropagations in interface InternalAgendapublic void registerExpiration(PropagationContext ectx)
registerExpiration in interface InternalAgendaprotected void doRetract(PropagationContext ectx)
public boolean isParallelAgenda()
isParallelAgenda in interface InternalAgendaCopyright © 2001–2018 JBoss by Red Hat. All rights reserved.