|
|||||||||
| 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 | |
|---|---|
static interface |
AbstractWorkingMemory.WorkingMemoryAction
|
class |
AbstractWorkingMemory.WorkingMemoryRetractAction
|
| Field Summary | |
|---|---|
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 java.util.Map |
assertMap
Object-to-handle mapping. |
protected boolean |
discardOnLogicalOverride
|
protected java.util.List |
factQueue
|
protected boolean |
firing
Flag to determine if a rule is currently being fired. |
protected java.util.Map |
globals
Global values which are associated with this memory. |
protected FactHandleFactory |
handleFactory
|
protected ReentrantLock |
lock
|
protected PrimitiveLongMap |
nodeMemories
The actual memory for the JoinNodes. |
protected long |
propagationIdCounter
|
protected java.util.Map |
queryResults
|
protected InternalRuleBase |
ruleBase
The RuleBase with which this memory is associated. |
protected TruthMaintenanceSystem |
tms
|
protected WorkingMemoryEventSupport |
workingMemoryEventSupport
The eventSupport |
| Constructor Summary | |
|---|---|
AbstractWorkingMemory(InternalRuleBase ruleBase,
FactHandleFactory handleFactory)
Construct. |
|
| Method Summary | |
|---|---|
void |
addEventListener(AgendaEventListener listener)
Add an event listener. |
void |
addEventListener(WorkingMemoryEventListener listener)
Add an event listener. |
protected void |
addPropertyChangeListener(java.lang.Object object)
|
FactHandle |
assertLogicalObject(java.lang.Object object)
|
FactHandle |
assertLogicalObject(java.lang.Object object,
boolean dynamic)
|
FactHandle |
assertObject(java.lang.Object object)
Assert a fact. |
FactHandle |
assertObject(java.lang.Object object,
boolean dynamic)
Assert a fact registering JavaBean PropertyChangeListeners
on the Object to automatically trigger modifyObject calls
if dynamic is true. |
FactHandle |
assertObject(java.lang.Object object,
boolean dynamic,
boolean logical,
Rule rule,
Activation activation)
|
void |
clearAgenda()
Clear the Agenda |
void |
clearAgendaGroup(java.lang.String group)
Clear the Agenda Group |
void |
clearNodeMemory(NodeMemory node)
|
void |
dispose()
Forces the workingMemory to be derefenced from |
abstract void |
doAssertObject(InternalFactHandle factHandle,
java.lang.Object object,
PropagationContext propagationContext)
|
abstract void |
doRetract(InternalFactHandle factHandle,
PropagationContext propagationContext)
|
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 |
Agenda |
getAgenda()
Retrieve the rule-firing Agenda for this
WorkingMemory. |
java.util.List |
getAgendaEventListeners()
Returns all event listeners. |
AgendaEventSupport |
getAgendaEventSupport()
|
FactHandle |
getFactHandle(java.lang.Object object)
Retrieve the FactHandle associated with an Object. |
FactHandleFactory |
getFactHandleFactory()
|
java.util.Map |
getFactHandleMap()
A helper method used to avoid lookups when iterating over facthandles and objects at once. |
java.util.List |
getFactHandles()
Retrieve all known Fact Handles. |
AgendaGroup |
getFocus()
|
java.lang.Object |
getGlobal(java.lang.String name)
Retrieve a specific piece of global data by name |
java.util.Map |
getGlobals()
Retrieve all of the set application data in this memory |
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. |
java.util.List |
getObjects()
Retrieve all known objects. |
java.util.List |
getObjects(java.lang.Class objectClass)
Retrieve all known objects of the specified class. |
abstract QueryResults |
getQueryResults(java.lang.String query)
Retrieve the QueryResults of the specified query. |
RuleBase |
getRuleBase()
Retrieve the RuleBase of this working memory. |
TruthMaintenanceSystem |
getTruthMaintenanceSystem()
|
java.util.List |
getWorkingMemoryEventListeners()
Returns all event listeners. |
WorkingMemoryEventSupport |
getWorkingMemoryEventSupport()
|
void |
modifyObject(FactHandle handle,
java.lang.Object object)
Modify a fact. |
abstract void |
modifyObject(FactHandle factHandle,
java.lang.Object object,
Rule rule,
Activation activation)
|
void |
propagateQueuedActions()
|
void |
propertyChange(java.beans.PropertyChangeEvent event)
|
void |
queueRetractAction(InternalFactHandle factHandle,
boolean removeLogical,
boolean updateEqualsMap,
Rule ruleOrigin,
Activation activationOrigin)
|
void |
removeEventListener(AgendaEventListener listener)
Remove an event listener. |
void |
removeEventListener(WorkingMemoryEventListener listener)
Remove an event listener. |
protected void |
removePropertyChangeListener(FactHandle handle)
|
void |
retractObject(FactHandle handle)
Retract a fact. |
void |
retractObject(FactHandle factHandle,
boolean removeLogical,
boolean updateEqualsMap,
Rule rule,
Activation activation)
|
void |
setAsyncExceptionHandler(AsyncExceptionHandler handler)
Sets the AsyncExceptionHandler to handle exceptions thrown by the Agenda Scheduler used for duration rules. |
void |
setFocus(AgendaGroup focus)
|
void |
setFocus(java.lang.String focus)
|
void |
setGlobal(java.lang.String name,
java.lang.Object value)
Set a specific piece of global in this working memory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final java.lang.Class[] ADD_REMOVE_PROPERTY_CHANGE_LISTENER_ARG_TYPES
protected final java.lang.Object[] addRemovePropertyChangeListenerArgs
protected final PrimitiveLongMap nodeMemories
JoinNodes.
protected final java.util.Map globals
protected final java.util.Map assertMap
protected java.util.Map queryResults
protected final WorkingMemoryEventSupport workingMemoryEventSupport
protected final AgendaEventSupport agendaEventSupport
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.List factQueue
protected final ReentrantLock lock
protected final boolean discardOnLogicalOverride
protected long propagationIdCounter
protected boolean firing
| Constructor Detail |
|---|
public AbstractWorkingMemory(InternalRuleBase ruleBase, FactHandleFactory handleFactory)
ruleBase - The backing rule-base.| Method Detail |
|---|
public void addEventListener(WorkingMemoryEventListener listener)
WorkingMemory
addEventListener in interface WorkingMemorylistener - The listener to add.public void removeEventListener(WorkingMemoryEventListener listener)
WorkingMemory
removeEventListener in interface WorkingMemorylistener - The listener to remove.public java.util.List getWorkingMemoryEventListeners()
WorkingMemory
getWorkingMemoryEventListeners in interface EventSupportgetWorkingMemoryEventListeners in interface WorkingMemorypublic void addEventListener(AgendaEventListener listener)
WorkingMemory
addEventListener in interface WorkingMemorylistener - The listener to add.public void removeEventListener(AgendaEventListener listener)
WorkingMemory
removeEventListener in interface WorkingMemorylistener - The listener to remove.public FactHandleFactory getFactHandleFactory()
public java.util.List getAgendaEventListeners()
WorkingMemory
getAgendaEventListeners in interface EventSupportgetAgendaEventListeners in interface WorkingMemorypublic java.util.Map getGlobals()
WorkingMemory
getGlobals in interface WorkingMemoryWorkingMemory
public void setGlobal(java.lang.String name,
java.lang.Object value)
WorkingMemory
setGlobal in interface WorkingMemoryname - the name under which to populate the datavalue - the application dataWorkingMemorypublic java.lang.Object getGlobal(java.lang.String name)
WorkingMemory
getGlobal in interface WorkingMemoryWorkingMemorypublic Agenda getAgenda()
Agenda for this
WorkingMemory.
getAgenda in interface WorkingMemoryAgenda.public void clearAgenda()
clearAgenda in interface WorkingMemorypublic void clearAgendaGroup(java.lang.String group)
clearAgendaGroup in interface WorkingMemorypublic RuleBase getRuleBase()
WorkingMemoryRuleBase of this working memory.
getRuleBase in interface WorkingMemoryRuleBase.WorkingMemory
public void fireAllRules()
throws FactException
WorkingMemory
fireAllRules in interface WorkingMemoryFactException - If an error occurs.WorkingMemorypublic void fireAllRules(AgendaFilter agendaFilter) throws FactException
WorkingMemory
fireAllRules in interface WorkingMemoryFactException - If an 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 WorkingMemoryhandle - The FactHandle reference for the
Object lookup
WorkingMemorypublic FactHandle getFactHandle(java.lang.Object object)
WorkingMemoryFactHandle associated with an Object.
getFactHandle in interface WorkingMemoryobject - The object.
WorkingMemorypublic java.util.List getFactHandles()
WorkingMemory
getFactHandles in interface WorkingMemorypublic java.util.Map getFactHandleMap()
public java.util.List getObjects()
WorkingMemory
getObjects in interface WorkingMemoryWorkingMemorypublic java.util.List getObjects(java.lang.Class objectClass)
WorkingMemory
getObjects in interface WorkingMemoryobjectClass - The class of object to return.
public abstract QueryResults getQueryResults(java.lang.String query)
WorkingMemory
getQueryResults in interface WorkingMemoryquery - The name of the query.
public AgendaGroup getFocus()
getFocus in interface WorkingMemorypublic void setFocus(java.lang.String focus)
setFocus in interface WorkingMemorypublic void setFocus(AgendaGroup focus)
setFocus in interface WorkingMemorypublic TruthMaintenanceSystem getTruthMaintenanceSystem()
public FactHandle assertObject(java.lang.Object object) throws FactException
WorkingMemory
assertObject in interface WorkingMemoryobject - The fact object.
FactException - If an error occurs.WorkingMemorypublic FactHandle assertLogicalObject(java.lang.Object object) throws FactException
FactExceptionWorkingMemorypublic FactHandle assertObject(java.lang.Object object, boolean dynamic) throws FactException
WorkingMemoryPropertyChangeListeners
on the Object to automatically trigger modifyObject calls
if dynamic is true.
assertObject in interface WorkingMemoryobject - The fact object.dynamic - true if Drools should add JavaBean
PropertyChangeListeners to the object.
FactException - If an error occurs.public FactHandle assertLogicalObject(java.lang.Object object, boolean dynamic) throws FactException
assertLogicalObject in interface InternalWorkingMemoryActionsFactExceptionpublic FactHandle assertObject(java.lang.Object object, boolean dynamic, boolean logical, Rule rule, Activation activation) throws FactException
assertObject in interface InternalWorkingMemoryActionsFactExceptionprotected void addPropertyChangeListener(java.lang.Object object)
public abstract void doAssertObject(InternalFactHandle factHandle, java.lang.Object object, PropagationContext propagationContext) throws FactException
FactExceptionprotected void removePropertyChangeListener(FactHandle handle) throws NoSuchFactObjectException
NoSuchFactObjectExceptionpublic void retractObject(FactHandle handle) throws FactException
WorkingMemory
retractObject in interface WorkingMemoryhandle - The fact-handle associated with the fact to retract.
FactException - If an error occurs.public abstract void doRetract(InternalFactHandle factHandle, PropagationContext propagationContext)
public void retractObject(FactHandle factHandle, boolean removeLogical, boolean updateEqualsMap, Rule rule, Activation activation) throws FactException
retractObject in interface InternalWorkingMemoryActionsFactExceptionWorkingMemorypublic void modifyObject(FactHandle handle, java.lang.Object object) throws FactException
WorkingMemory
modifyObject in interface WorkingMemoryhandle - The fact-handle associated with the fact to modify.object - The new value of the fact.
FactException - If an error occurs.public abstract void modifyObject(FactHandle factHandle, java.lang.Object object, Rule rule, Activation activation) throws FactException
modifyObject in interface InternalWorkingMemoryActionsFactExceptionWorkingMemorypublic void propagateQueuedActions()
public void queueRetractAction(InternalFactHandle factHandle, boolean removeLogical, boolean updateEqualsMap, Rule ruleOrigin, Activation activationOrigin)
public java.lang.Object getNodeMemory(NodeMemory node)
JoinMemory for a particular
JoinNode.
node - The JoinNode key.
public void clearNodeMemory(NodeMemory node)
public WorkingMemoryEventSupport getWorkingMemoryEventSupport()
public AgendaEventSupport getAgendaEventSupport()
getAgendaEventSupport in interface EventSupportpublic void setAsyncExceptionHandler(AsyncExceptionHandler handler)
setAsyncExceptionHandler in interface WorkingMemoryhandler - public void propertyChange(java.beans.PropertyChangeEvent event)
propertyChange in interface java.beans.PropertyChangeListenerpublic long getNextPropagationIdCounter()
public void dispose()
WorkingMemory
dispose in interface WorkingMemorypublic Lock getLock()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||