|
|||||||||
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 JoinNode s. |
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
JoinNode
s.
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 WorkingMemory
listener
- The listener to add.public void removeEventListener(WorkingMemoryEventListener listener)
WorkingMemory
removeEventListener
in interface WorkingMemory
listener
- The listener to remove.public java.util.List getWorkingMemoryEventListeners()
WorkingMemory
getWorkingMemoryEventListeners
in interface EventSupport
getWorkingMemoryEventListeners
in interface WorkingMemory
public void addEventListener(AgendaEventListener listener)
WorkingMemory
addEventListener
in interface WorkingMemory
listener
- The listener to add.public void removeEventListener(AgendaEventListener listener)
WorkingMemory
removeEventListener
in interface WorkingMemory
listener
- The listener to remove.public FactHandleFactory getFactHandleFactory()
public java.util.List getAgendaEventListeners()
WorkingMemory
getAgendaEventListeners
in interface EventSupport
getAgendaEventListeners
in interface WorkingMemory
public java.util.Map getGlobals()
WorkingMemory
getGlobals
in interface WorkingMemory
WorkingMemory
public void setGlobal(java.lang.String name, java.lang.Object value)
WorkingMemory
setGlobal
in interface WorkingMemory
name
- the name under which to populate the datavalue
- the application dataWorkingMemory
public java.lang.Object getGlobal(java.lang.String name)
WorkingMemory
getGlobal
in interface WorkingMemory
WorkingMemory
public Agenda getAgenda()
Agenda
for this
WorkingMemory
.
getAgenda
in interface WorkingMemory
Agenda
.public void clearAgenda()
clearAgenda
in interface WorkingMemory
public void clearAgendaGroup(java.lang.String group)
clearAgendaGroup
in interface WorkingMemory
public RuleBase getRuleBase()
WorkingMemory
RuleBase
of this working memory.
getRuleBase
in interface WorkingMemory
RuleBase
.WorkingMemory
public void fireAllRules() throws FactException
WorkingMemory
fireAllRules
in interface WorkingMemory
FactException
- If an error occurs.WorkingMemory
public void fireAllRules(AgendaFilter agendaFilter) throws FactException
WorkingMemory
fireAllRules
in interface WorkingMemory
FactException
- 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 WorkingMemory
handle
- The FactHandle
reference for the
Object
lookup
WorkingMemory
public FactHandle getFactHandle(java.lang.Object object)
WorkingMemory
FactHandle
associated with an Object.
getFactHandle
in interface WorkingMemory
object
- The object.
WorkingMemory
public java.util.List getFactHandles()
WorkingMemory
getFactHandles
in interface WorkingMemory
public java.util.Map getFactHandleMap()
public java.util.List getObjects()
WorkingMemory
getObjects
in interface WorkingMemory
WorkingMemory
public java.util.List getObjects(java.lang.Class objectClass)
WorkingMemory
getObjects
in interface WorkingMemory
objectClass
- The class of object to return.
public abstract QueryResults getQueryResults(java.lang.String query)
WorkingMemory
getQueryResults
in interface WorkingMemory
query
- The name of the query.
public AgendaGroup getFocus()
getFocus
in interface WorkingMemory
public void setFocus(java.lang.String focus)
setFocus
in interface WorkingMemory
public void setFocus(AgendaGroup focus)
setFocus
in interface WorkingMemory
public TruthMaintenanceSystem getTruthMaintenanceSystem()
public FactHandle assertObject(java.lang.Object object) throws FactException
WorkingMemory
assertObject
in interface WorkingMemory
object
- The fact object.
FactException
- If an error occurs.WorkingMemory
public FactHandle assertLogicalObject(java.lang.Object object) throws FactException
FactException
WorkingMemory
public FactHandle assertObject(java.lang.Object object, boolean dynamic) throws FactException
WorkingMemory
PropertyChangeListeners
on the Object to automatically trigger modifyObject
calls
if dynamic
is true
.
assertObject
in interface WorkingMemory
object
- 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 InternalWorkingMemoryActions
FactException
public FactHandle assertObject(java.lang.Object object, boolean dynamic, boolean logical, Rule rule, Activation activation) throws FactException
assertObject
in interface InternalWorkingMemoryActions
FactException
protected void addPropertyChangeListener(java.lang.Object object)
public abstract void doAssertObject(InternalFactHandle factHandle, java.lang.Object object, PropagationContext propagationContext) throws FactException
FactException
protected void removePropertyChangeListener(FactHandle handle) throws NoSuchFactObjectException
NoSuchFactObjectException
public void retractObject(FactHandle handle) throws FactException
WorkingMemory
retractObject
in interface WorkingMemory
handle
- 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 InternalWorkingMemoryActions
FactException
WorkingMemory
public void modifyObject(FactHandle handle, java.lang.Object object) throws FactException
WorkingMemory
modifyObject
in interface WorkingMemory
handle
- 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 InternalWorkingMemoryActions
FactException
WorkingMemory
public 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 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()
public void dispose()
WorkingMemory
dispose
in interface WorkingMemory
public Lock getLock()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |