|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.drools.common.AbstractWorkingMemory
public abstract class AbstractWorkingMemory
Implementation of WorkingMemory
.
Nested Class Summary | |
---|---|
class |
AbstractWorkingMemory.RuleFlowDeactivateEvent
|
Field Summary | |
---|---|
protected java.util.List |
__ruleBaseEventListeners
|
protected java.util.LinkedList |
actionQueue
|
protected static java.lang.Class[] |
ADD_REMOVE_PROPERTY_CHANGE_LISTENER_ARG_TYPES
|
protected java.lang.Object[] |
addRemovePropertyChangeListenerArgs
The arguments used when adding/removing a property change listener. |
protected DefaultAgenda |
agenda
Rule-firing agenda. |
protected AgendaEventSupport |
agendaEventSupport
|
protected boolean |
discardOnLogicalOverride
|
protected boolean |
evaluatingActionQueue
|
protected boolean |
firing
Flag to determine if a rule is currently being fired. |
protected GlobalResolver |
globalResolver
Global values which are associated with this memory. |
protected boolean |
halt
|
protected FactHandleFactory |
handleFactory
|
protected long |
id
|
protected ReentrantLock |
lock
|
protected PrimitiveLongMap |
nodeMemories
The actual memory for the JoinNode s. |
protected static java.lang.Object |
NULL
|
protected long |
propagationIdCounter
|
protected java.util.Map |
queryResults
|
protected InternalRuleBase |
ruleBase
The RuleBase with which this memory is associated. |
protected RuleFlowEventSupport |
ruleFlowEventSupport
|
protected TruthMaintenanceSystem |
tms
|
protected WorkingMemoryEventSupport |
workingMemoryEventSupport
The eventSupport |
Constructor Summary | |
---|---|
AbstractWorkingMemory(int id,
InternalRuleBase ruleBase,
FactHandleFactory handleFactory)
Construct. |
Method Summary | |
---|---|
void |
addEventListener(AgendaEventListener listener)
Add an event listener. |
void |
addEventListener(RuleBaseEventListener listener)
Add an event listener. |
void |
addEventListener(RuleFlowEventListener listener)
Add an event listener. |
void |
addEventListener(WorkingMemoryEventListener listener)
Add an event listener. |
void |
addLIANodePropagation(LIANodePropagation liaNodePropagation)
|
protected void |
addPropertyChangeListener(java.lang.Object object)
|
void |
clearActivationGroup(java.lang.String group)
Clears the Activation Group, cancellings all its Activations |
void |
clearAgenda()
Clear the Agenda. |
void |
clearAgendaGroup(java.lang.String group)
Clear the Agenda Group, cancelling all its Activations. |
void |
clearNodeMemory(NodeMemory node)
|
void |
clearRuleFlowGroup(java.lang.String group)
Clears the RuleFlow group, cancelling all its Activations |
abstract void |
doInsert(InternalFactHandle factHandle,
java.lang.Object object,
PropagationContext propagationContext)
|
abstract void |
doRetract(InternalFactHandle factHandle,
PropagationContext propagationContext)
|
void |
executeQueuedActions()
|
void |
fireAllRules()
Fire all items on the agenda until empty. |
void |
fireAllRules(AgendaFilter agendaFilter)
Fire all items on the agenda until empty, using the given AgendaFiler |
void |
fireAllRules(AgendaFilter agendaFilter,
int fireLimit)
Fire all items on the agenda using the given AgendaFiler until empty or at most 'fireLimit' rules have fired |
void |
fireAllRules(int fireLimit)
Fire all items on the agenda until empty or at most 'fireLimit' rules have fired |
java.util.Map |
getActivationParameters(Activation activation)
Helper method |
java.util.Map.Entry[] |
getActivationParameters(long activationId)
|
Agenda |
getAgenda()
Returns the Agenda for this WorkingMemory. |
java.util.List |
getAgendaEventListeners()
Returns all event listeners. |
AgendaEventSupport |
getAgendaEventSupport()
|
ObjectHashMap |
getAssertMap()
|
ExecutorService |
getExecutorService()
|
FactHandle |
getFactHandle(java.lang.Object object)
Retrieve the FactHandle associated with an Object. |
FactHandle |
getFactHandleByIdentity(java.lang.Object object)
Looks for the fact handle associated to the given object by looking up the object IDENTITY (==), even if rule base is configured to AssertBehavior.EQUALITY. |
FactHandleFactory |
getFactHandleFactory()
|
ObjectHashMap |
getFactHandleMap()
This is an internal method, used to avoid java.util.Iterator adaptors |
AgendaGroup |
getFocus()
Returns the AgendaGroup which has the current WorkingMemory focus. |
java.lang.Object |
getGlobal(java.lang.String identifier)
Retrieve a specific instance of global data by identifier |
GlobalResolver |
getGlobalResolver()
Returns the current GlobalResolver |
long |
getId()
|
Lock |
getLock()
|
long |
getNextPropagationIdCounter()
|
java.lang.Object |
getNodeMemory(NodeMemory node)
Retrieve the JoinMemory for a particular
JoinNode . |
java.lang.Object |
getObject(FactHandle handle)
Returns the fact Object for the given FactHandle . |
abstract QueryResults |
getQueryResults(java.lang.String query)
Retrieve the QueryResults of the specified query. |
RuleBase |
getRuleBase()
Retrieve the RuleBase for this working memory. |
java.util.List |
getRuleBaseEventListeners()
Returns all event listeners. |
java.util.List |
getRuleFlowEventListeners()
Returns all event listeners. |
RuleFlowEventSupport |
getRuleFlowEventSupport()
|
TruthMaintenanceSystem |
getTruthMaintenanceSystem()
|
java.util.List |
getWorkingMemoryEventListeners()
Returns all event listeners. |
WorkingMemoryEventSupport |
getWorkingMemoryEventSupport()
|
void |
halt()
Stops rule firing after the currect rule finishes executing |
protected void |
insert(InternalFactHandle handle,
java.lang.Object object,
Rule rule,
Activation activation)
|
FactHandle |
insert(java.lang.Object object)
Assert a fact. |
FactHandle |
insert(java.lang.Object object,
boolean dynamic)
Insert a fact registering JavaBean PropertyChangeListeners
on the Object to automatically trigger update calls
if dynamic is true . |
FactHandle |
insert(java.lang.Object object,
boolean dynamic,
boolean logical,
Rule rule,
Activation activation)
|
FactHandle |
insertLogical(java.lang.Object object)
|
FactHandle |
insertLogical(java.lang.Object object,
boolean dynamic)
|
boolean |
isSequential()
|
java.util.Iterator |
iterateFactHandles()
This class is not thread safe, changes to the working memory during iteration may give unexpected results |
java.util.Iterator |
iterateFactHandles(ObjectFilter filter)
This class is not thread safe, changes to the working memory during iteration may give unexpected results |
java.util.Iterator |
iterateObjects()
This class is not thread safe, changes to the working memory during iteration may give unexpected results |
java.util.Iterator |
iterateObjects(ObjectFilter filter)
This class is not thread safe, changes to the working memory during iteration may give unexpected results |
java.util.List |
iterateObjectsToList()
|
void |
modifyInsert(FactHandle factHandle,
java.lang.Object object)
|
void |
modifyInsert(FactHandle factHandle,
java.lang.Object object,
Rule rule,
Activation activation)
|
void |
modifyRetract(FactHandle factHandle)
|
void |
modifyRetract(FactHandle factHandle,
Rule rule,
Activation activation)
|
void |
propertyChange(java.beans.PropertyChangeEvent event)
|
void |
queueWorkingMemoryAction(WorkingMemoryAction action)
|
void |
removeEventListener(AgendaEventListener listener)
Remove an event listener. |
void |
removeEventListener(RuleBaseEventListener listener)
Remove an event listener. |
void |
removeEventListener(RuleFlowEventListener listener)
Remove an event listener. |
void |
removeEventListener(WorkingMemoryEventListener listener)
Remove an event listener. |
void |
removeLogicalDependencies(Activation activation,
PropagationContext context,
Rule rule)
|
protected void |
removePropertyChangeListener(FactHandle handle)
|
void |
retract(FactHandle handle)
Retract a fact. |
void |
retract(FactHandle factHandle,
boolean removeLogical,
boolean updateEqualsMap,
Rule rule,
Activation activation)
|
void |
setAgendaEventSupport(AgendaEventSupport agendaEventSupport)
|
void |
setAsyncExceptionHandler(AsyncExceptionHandler handler)
Sets the AsyncExceptionHandler to handle exceptions thrown by the Agenda Scheduler used for duration rules. |
void |
setExecutorService(ExecutorService executor)
|
void |
setFocus(AgendaGroup focus)
Set the focus to the specified AgendaGroup |
void |
setFocus(java.lang.String focus)
Set the focus to the specified AgendaGroup |
void |
setGlobal(java.lang.String identifier,
java.lang.Object value)
Set a specific instance as a global in this working memory. |
void |
setGlobalResolver(GlobalResolver globalResolver)
Sets the GlobalResolver instance to be used when resolving globals, replaces the current GlobalResolver. |
void |
setId(long id)
|
void |
setRuleBase(InternalRuleBase ruleBase)
|
void |
setRuleFlowEventSupport(RuleFlowEventSupport ruleFlowEventSupport)
|
void |
setWorkingMemoryEventSupport(WorkingMemoryEventSupport workingMemoryEventSupport)
|
ProcessInstance |
startProcess(java.lang.String processId)
Starts a new process instance for the process with the given id. |
void |
update(FactHandle handle,
java.lang.Object object)
Inform the WorkingMemory that a Fact has been modified and that it should now update the network. |
void |
update(FactHandle factHandle,
java.lang.Object object,
Rule rule,
Activation activation)
modify is implemented as half way retract / assert due to the truth maintenance issues. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.drools.WorkingMemory |
---|
getQueryResults |
Field Detail |
---|
protected static final java.lang.Class[] ADD_REMOVE_PROPERTY_CHANGE_LISTENER_ARG_TYPES
protected long id
protected final java.lang.Object[] addRemovePropertyChangeListenerArgs
protected final PrimitiveLongMap nodeMemories
JoinNode
s.
protected java.util.Map queryResults
protected GlobalResolver globalResolver
protected static final java.lang.Object NULL
protected WorkingMemoryEventSupport workingMemoryEventSupport
protected AgendaEventSupport agendaEventSupport
protected RuleFlowEventSupport ruleFlowEventSupport
protected java.util.List __ruleBaseEventListeners
protected transient InternalRuleBase ruleBase
RuleBase
with which this memory is associated.
protected final FactHandleFactory handleFactory
protected final TruthMaintenanceSystem tms
protected DefaultAgenda agenda
protected final java.util.LinkedList actionQueue
protected volatile boolean evaluatingActionQueue
protected final ReentrantLock lock
protected final boolean discardOnLogicalOverride
protected long propagationIdCounter
protected volatile boolean firing
protected volatile boolean halt
Constructor Detail |
---|
public AbstractWorkingMemory(int id, InternalRuleBase ruleBase, FactHandleFactory handleFactory)
ruleBase
- The backing rule-base.Method Detail |
---|
public void setRuleBase(InternalRuleBase ruleBase)
setRuleBase
in interface InternalWorkingMemory
public void setWorkingMemoryEventSupport(WorkingMemoryEventSupport workingMemoryEventSupport)
setWorkingMemoryEventSupport
in interface InternalWorkingMemory
public void setAgendaEventSupport(AgendaEventSupport agendaEventSupport)
setAgendaEventSupport
in interface InternalWorkingMemory
public void setRuleFlowEventSupport(RuleFlowEventSupport ruleFlowEventSupport)
setRuleFlowEventSupport
in interface InternalWorkingMemory
public boolean isSequential()
isSequential
in interface InternalWorkingMemory
public void addLIANodePropagation(LIANodePropagation liaNodePropagation)
addLIANodePropagation
in interface InternalWorkingMemory
public void addEventListener(WorkingMemoryEventListener listener)
WorkingMemoryEventManager
addEventListener
in interface WorkingMemoryEventManager
listener
- The listener to add.public void removeEventListener(WorkingMemoryEventListener listener)
WorkingMemoryEventManager
removeEventListener
in interface WorkingMemoryEventManager
listener
- The listener to remove.public java.util.List getWorkingMemoryEventListeners()
WorkingMemoryEventManager
getWorkingMemoryEventListeners
in interface EventSupport
getWorkingMemoryEventListeners
in interface WorkingMemoryEventManager
public void addEventListener(AgendaEventListener listener)
WorkingMemoryEventManager
addEventListener
in interface WorkingMemoryEventManager
listener
- The listener to add.public void removeEventListener(AgendaEventListener listener)
WorkingMemoryEventManager
removeEventListener
in interface WorkingMemoryEventManager
listener
- The listener to remove.public java.util.List getAgendaEventListeners()
WorkingMemoryEventManager
getAgendaEventListeners
in interface EventSupport
getAgendaEventListeners
in interface WorkingMemoryEventManager
public void addEventListener(RuleFlowEventListener listener)
WorkingMemoryEventManager
addEventListener
in interface WorkingMemoryEventManager
listener
- The listener to add.public void removeEventListener(RuleFlowEventListener listener)
WorkingMemoryEventManager
removeEventListener
in interface WorkingMemoryEventManager
listener
- The listener to remove.public java.util.List getRuleFlowEventListeners()
WorkingMemoryEventManager
getRuleFlowEventListeners
in interface EventSupport
getRuleFlowEventListeners
in interface WorkingMemoryEventManager
public void addEventListener(RuleBaseEventListener listener)
RuleBaseEventManager
addEventListener
in interface RuleBaseEventManager
listener
- The listener to add.public java.util.List getRuleBaseEventListeners()
RuleBaseEventManager
getRuleBaseEventListeners
in interface RuleBaseEventManager
public void removeEventListener(RuleBaseEventListener listener)
RuleBaseEventManager
removeEventListener
in interface RuleBaseEventManager
listener
- The listener to remove.public FactHandleFactory getFactHandleFactory()
getFactHandleFactory
in interface InternalWorkingMemory
public void setGlobal(java.lang.String identifier, java.lang.Object value)
WorkingMemory
setGlobal
in interface WorkingMemory
identifier
- the identifier under which to populate the datavalue
- the global value, cannot be nullpublic void setGlobalResolver(GlobalResolver globalResolver)
WorkingMemory
setGlobalResolver
in interface WorkingMemory
public GlobalResolver getGlobalResolver()
WorkingMemory
getGlobalResolver
in interface WorkingMemory
public long getId()
getId
in interface InternalWorkingMemory
public void setId(long id)
setId
in interface InternalWorkingMemory
public java.lang.Object getGlobal(java.lang.String identifier)
WorkingMemory
getGlobal
in interface WorkingMemory
public Agenda getAgenda()
WorkingMemory
getAgenda
in interface WorkingMemory
public void clearAgenda()
WorkingMemory
clearAgenda
in interface WorkingMemory
public void clearAgendaGroup(java.lang.String group)
WorkingMemory
clearAgendaGroup
in interface WorkingMemory
public void clearActivationGroup(java.lang.String group)
WorkingMemory
clearActivationGroup
in interface WorkingMemory
public void clearRuleFlowGroup(java.lang.String group)
WorkingMemory
clearRuleFlowGroup
in interface WorkingMemory
public RuleBase getRuleBase()
WorkingMemory
RuleBase
for this working memory.
getRuleBase
in interface WorkingMemory
RuleBase
.public void halt()
WorkingMemory
halt
in interface WorkingMemory
public void fireAllRules() throws FactException
WorkingMemory
fireAllRules
in interface WorkingMemory
FactException
- If a RuntimeException error occurs.public void fireAllRules(int fireLimit) throws FactException
WorkingMemory
fireAllRules
in interface WorkingMemory
FactException
- If a RuntimeException error occurs.public void fireAllRules(AgendaFilter agendaFilter) throws FactException
WorkingMemory
fireAllRules
in interface WorkingMemory
FactException
- If a RuntimeException error occurs.public void fireAllRules(AgendaFilter agendaFilter, int fireLimit) throws FactException
WorkingMemory
fireAllRules
in interface WorkingMemory
FactException
- If a RuntimeException error occurs.public java.lang.Object getObject(FactHandle handle)
FactHandle
. It
actually attemps to return the value from the handle, before retrieving
it from objects map.
getObject
in interface WorkingMemory
handle
- The FactHandle
reference for the
Object
lookup
WorkingMemory
public ObjectHashMap getAssertMap()
getAssertMap
in interface InternalWorkingMemory
public FactHandle getFactHandle(java.lang.Object object)
WorkingMemory
FactHandle
associated with an Object.
getFactHandle
in interface WorkingMemory
object
- The object.
WorkingMemory
public FactHandle getFactHandleByIdentity(java.lang.Object object)
InternalWorkingMemory
getFactHandleByIdentity
in interface InternalWorkingMemory
InternalWorkingMemory
public ObjectHashMap getFactHandleMap()
getFactHandleMap
in interface InternalWorkingMemory
public java.util.Iterator iterateObjects()
iterateObjects
in interface WorkingMemory
public java.util.Iterator iterateObjects(ObjectFilter filter)
iterateObjects
in interface WorkingMemory
public java.util.Iterator iterateFactHandles()
iterateFactHandles
in interface WorkingMemory
public java.util.Iterator iterateFactHandles(ObjectFilter filter)
iterateFactHandles
in interface WorkingMemory
public abstract QueryResults getQueryResults(java.lang.String query)
WorkingMemory
getQueryResults
in interface WorkingMemory
query
- The name of the query.
public AgendaGroup getFocus()
WorkingMemory
getFocus
in interface WorkingMemory
public void setFocus(java.lang.String focus)
WorkingMemory
setFocus
in interface WorkingMemory
public void setFocus(AgendaGroup focus)
WorkingMemory
setFocus
in interface WorkingMemory
public TruthMaintenanceSystem getTruthMaintenanceSystem()
getTruthMaintenanceSystem
in interface InternalWorkingMemory
public FactHandle insert(java.lang.Object object) throws FactException
WorkingMemory
insert
in interface WorkingMemory
object
- The fact object.
FactException
- If a RuntimeException error occurs.WorkingMemory
public FactHandle insertLogical(java.lang.Object object) throws FactException
FactException
WorkingMemory
public FactHandle insert(java.lang.Object object, boolean dynamic) throws FactException
WorkingMemory
PropertyChangeListeners
on the Object to automatically trigger update
calls
if dynamic
is true
.
insert
in interface WorkingMemory
object
- The fact object.dynamic
- true if Drools should add JavaBean
PropertyChangeListeners
to the object.
FactException
- If a RuntimeException error occurs.public FactHandle insertLogical(java.lang.Object object, boolean dynamic) throws FactException
insertLogical
in interface InternalWorkingMemoryActions
FactException
public FactHandle insert(java.lang.Object object, boolean dynamic, boolean logical, Rule rule, Activation activation) throws FactException
insert
in interface InternalWorkingMemoryActions
FactException
protected void insert(InternalFactHandle handle, java.lang.Object object, Rule rule, Activation activation)
protected void addPropertyChangeListener(java.lang.Object object)
public abstract void doInsert(InternalFactHandle factHandle, java.lang.Object object, PropagationContext propagationContext) throws FactException
FactException
protected void removePropertyChangeListener(FactHandle handle)
public void retract(FactHandle handle) throws FactException
WorkingMemory
retract
in interface WorkingMemory
handle
- The fact-handle associated with the fact to retract.
FactException
- If a RuntimeException error occurs.public abstract void doRetract(InternalFactHandle factHandle, PropagationContext propagationContext)
public void retract(FactHandle factHandle, boolean removeLogical, boolean updateEqualsMap, Rule rule, Activation activation) throws FactException
retract
in interface InternalWorkingMemory
retract
in interface InternalWorkingMemoryActions
FactException
WorkingMemory
public void modifyRetract(FactHandle factHandle)
modifyRetract
in interface WorkingMemory
public void modifyRetract(FactHandle factHandle, Rule rule, Activation activation)
modifyRetract
in interface InternalWorkingMemoryActions
public void modifyInsert(FactHandle factHandle, java.lang.Object object)
modifyInsert
in interface WorkingMemory
public void modifyInsert(FactHandle factHandle, java.lang.Object object, Rule rule, Activation activation)
modifyInsert
in interface InternalWorkingMemoryActions
public void update(FactHandle handle, java.lang.Object object) throws FactException
WorkingMemory
update
in interface WorkingMemory
handle
- The fact-handle associated with the fact to modify.object
- The new value of the fact.
FactException
- If a RuntimeException error occurs.public void update(FactHandle factHandle, java.lang.Object object, Rule rule, Activation activation) throws FactException
update
in interface InternalWorkingMemoryActions
FactException
WorkingMemory
public void executeQueuedActions()
executeQueuedActions
in interface InternalWorkingMemory
public void queueWorkingMemoryAction(WorkingMemoryAction action)
queueWorkingMemoryAction
in interface InternalWorkingMemory
public void removeLogicalDependencies(Activation activation, PropagationContext context, Rule rule) throws FactException
removeLogicalDependencies
in interface InternalWorkingMemory
FactException
public java.lang.Object getNodeMemory(NodeMemory node)
JoinMemory
for a particular
JoinNode
.
getNodeMemory
in interface InternalWorkingMemory
node
- The JoinNode
key.
public void clearNodeMemory(NodeMemory node)
clearNodeMemory
in interface InternalWorkingMemory
public WorkingMemoryEventSupport getWorkingMemoryEventSupport()
getWorkingMemoryEventSupport
in interface EventSupport
public AgendaEventSupport getAgendaEventSupport()
getAgendaEventSupport
in interface EventSupport
public RuleFlowEventSupport getRuleFlowEventSupport()
getRuleFlowEventSupport
in interface EventSupport
public void setAsyncExceptionHandler(AsyncExceptionHandler handler)
setAsyncExceptionHandler
in interface WorkingMemory
handler
- public void propertyChange(java.beans.PropertyChangeEvent event)
propertyChange
in interface java.beans.PropertyChangeListener
public long getNextPropagationIdCounter()
getNextPropagationIdCounter
in interface InternalWorkingMemory
public Lock getLock()
getLock
in interface InternalWorkingMemory
public ProcessInstance startProcess(java.lang.String processId)
WorkingMemory
startProcess
in interface WorkingMemory
public java.util.List iterateObjectsToList()
public java.util.Map.Entry[] getActivationParameters(long activationId)
public java.util.Map getActivationParameters(Activation activation)
public ExecutorService getExecutorService()
getExecutorService
in interface InternalWorkingMemory
public void setExecutorService(ExecutorService executor)
setExecutorService
in interface InternalWorkingMemory
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |