|
||||||||||
| 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 List |
actionQueue
|
protected static Class[] |
ADD_REMOVE_PROPERTY_CHANGE_LISTENER_ARG_TYPES
|
protected 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 |
firing
Flag to determine if a rule is currently being fired. |
protected GlobalResolver |
globalResolver
|
protected Map |
globals
Global values which are associated with this memory. |
protected FactHandleFactory |
handleFactory
|
protected long |
id
|
protected ReentrantLock |
lock
|
protected PrimitiveLongMap |
nodeMemories
The actual memory for the JoinNodes. |
protected static Object |
NULL
|
protected long |
propagationIdCounter
|
protected Map |
queryResults
|
protected InternalRuleBase |
ruleBase
The RuleBase with which this memory is associated. |
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(WorkingMemoryEventListener listener)
Add an event listener. |
protected void |
addPropertyChangeListener(Object object)
|
FactHandle |
assertLogicalObject(Object object)
|
FactHandle |
assertLogicalObject(Object object,
boolean dynamic)
|
FactHandle |
assertObject(Object object)
Assert a fact. |
FactHandle |
assertObject(Object object,
boolean dynamic)
Assert a fact registering JavaBean PropertyChangeListeners
on the Object to automatically trigger modifyObject calls
if dynamic is true. |
FactHandle |
assertObject(Object object,
boolean dynamic,
boolean logical,
Rule rule,
Activation activation)
|
void |
clearAgenda()
Clear the Agenda |
void |
clearAgendaGroup(String group)
Clear the Agenda Group |
void |
clearNodeMemory(NodeMemory node)
|
abstract void |
doAssertObject(InternalFactHandle factHandle,
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 |
Agenda |
getAgenda()
Retrieve the rule-firing Agenda for this
WorkingMemory. |
List |
getAgendaEventListeners()
Returns all event listeners. |
AgendaEventSupport |
getAgendaEventSupport()
|
FactHandle |
getFactHandle(Object object)
Retrieve the FactHandle associated with an Object. |
FactHandleFactory |
getFactHandleFactory()
|
ObjectHashMap |
getFactHandleMap()
This is an internal method, used to avoid java.util.Iterator adaptors |
AgendaGroup |
getFocus()
|
Object |
getGlobal(String name)
Retrieve a specific piece of global data by name |
Map |
getGlobals()
Retrieve all of the set application data in this memory |
long |
getId()
|
Lock |
getLock()
|
long |
getNextPropagationIdCounter()
|
Object |
getNodeMemory(NodeMemory node)
Retrieve the JoinMemory for a particular
JoinNode. |
Object |
getObject(FactHandle handle)
Returns the fact Object for the given FactHandle. |
abstract QueryResults |
getQueryResults(String query)
Retrieve the QueryResults of the specified query. |
RuleBase |
getRuleBase()
Retrieve the RuleBase of this working memory. |
TruthMaintenanceSystem |
getTruthMaintenanceSystem()
|
List |
getWorkingMemoryEventListeners()
Returns all event listeners. |
WorkingMemoryEventSupport |
getWorkingMemoryEventSupport()
|
Iterator |
iterateFactHandles()
This class is not thread safe, changes to the working memory during iteration may give unexpected results |
Iterator |
iterateFactHandles(ObjectFilter filter)
This class is not thread safe, changes to the working memory during iteration may give unexpected results |
Iterator |
iterateObjects()
This class is not thread safe, changes to the working memory during iteration may give unexpected results |
Iterator |
iterateObjects(ObjectFilter filter)
This class is not thread safe, changes to the working memory during iteration may give unexpected results |
List |
iterateObjectsToList()
|
void |
modifyObject(FactHandle handle,
Object object)
Modify a fact. |
void |
modifyObject(FactHandle factHandle,
Object object,
Rule rule,
Activation activation)
modify is implemented as half way retract / assert due to the truth maintenance issues. |
void |
propertyChange(PropertyChangeEvent event)
|
void |
queueWorkingMemoryAction(WorkingMemoryAction action)
|
void |
removeEventListener(AgendaEventListener 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 |
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(String focus)
|
void |
setGlobal(String name,
Object value)
Set a specific piece of global in this working memory. |
void |
setGlobalResolver(GlobalResolver globalResolver)
Delegate used to resolve any global names not found in the global map. |
IProcessInstance |
startProcess(String processId)
Starts a new process instance for the process with the given id. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final Class[] ADD_REMOVE_PROPERTY_CHANGE_LISTENER_ARG_TYPES
protected final long id
protected final Object[] addRemovePropertyChangeListenerArgs
protected final PrimitiveLongMap nodeMemories
JoinNodes.
protected final Map globals
protected Map queryResults
protected GlobalResolver globalResolver
protected static final Object NULL
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 List actionQueue
protected final ReentrantLock lock
protected final boolean discardOnLogicalOverride
protected long propagationIdCounter
protected boolean firing
| Constructor Detail |
|---|
public AbstractWorkingMemory(int id,
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 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 List getAgendaEventListeners()
WorkingMemory
getAgendaEventListeners in interface EventSupportgetAgendaEventListeners in interface WorkingMemorypublic FactHandleFactory getFactHandleFactory()
getFactHandleFactory in interface InternalWorkingMemorypublic Map getGlobals()
WorkingMemory
getGlobals in interface WorkingMemoryWorkingMemorypublic void setGlobal(String name, Object value)
WorkingMemory
setGlobal in interface WorkingMemoryname - the name under which to populate the datavalue - the global value, cannot be nullWorkingMemorypublic void setGlobalResolver(GlobalResolver globalResolver)
WorkingMemory
setGlobalResolver in interface WorkingMemorypublic long getId()
getId in interface InternalWorkingMemorypublic Object getGlobal(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(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 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(Object object)
WorkingMemoryFactHandle associated with an Object.
getFactHandle in interface WorkingMemoryobject - The object.
WorkingMemorypublic ObjectHashMap getFactHandleMap()
getFactHandleMap in interface InternalWorkingMemorypublic Iterator iterateObjects()
iterateObjects in interface WorkingMemorypublic Iterator iterateObjects(ObjectFilter filter)
iterateObjects in interface WorkingMemorypublic Iterator iterateFactHandles()
iterateFactHandles in interface WorkingMemorypublic Iterator iterateFactHandles(ObjectFilter filter)
iterateFactHandles in interface WorkingMemorypublic abstract QueryResults getQueryResults(String query)
WorkingMemory
getQueryResults in interface WorkingMemoryquery - The name of the query.
public AgendaGroup getFocus()
getFocus in interface WorkingMemorypublic void setFocus(String focus)
setFocus in interface WorkingMemorypublic void setFocus(AgendaGroup focus)
setFocus in interface WorkingMemorypublic TruthMaintenanceSystem getTruthMaintenanceSystem()
getTruthMaintenanceSystem in interface InternalWorkingMemorypublic FactHandle assertObject(Object object) throws FactException
WorkingMemory
assertObject in interface WorkingMemoryobject - The fact object.
FactException - If an error occurs.WorkingMemorypublic FactHandle assertLogicalObject(Object object) throws FactException
FactExceptionWorkingMemorypublic FactHandle assertObject(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(Object object, boolean dynamic) throws FactException
assertLogicalObject in interface InternalWorkingMemoryActionsFactExceptionpublic FactHandle assertObject(Object object, boolean dynamic, boolean logical, Rule rule, Activation activation) throws FactException
assertObject in interface InternalWorkingMemoryActionsFactExceptionprotected void addPropertyChangeListener(Object object)
public abstract void doAssertObject(InternalFactHandle factHandle, 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 InternalWorkingMemoryretractObject in interface InternalWorkingMemoryActionsFactExceptionWorkingMemorypublic void modifyObject(FactHandle handle, 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 void modifyObject(FactHandle factHandle, Object object, Rule rule, Activation activation) throws FactException
modifyObject in interface InternalWorkingMemoryActionsFactExceptionWorkingMemorypublic void executeQueuedActions()
executeQueuedActions in interface InternalWorkingMemorypublic void queueWorkingMemoryAction(WorkingMemoryAction action)
queueWorkingMemoryAction in interface InternalWorkingMemorypublic void removeLogicalDependencies(Activation activation, PropagationContext context, Rule rule) throws FactException
removeLogicalDependencies in interface InternalWorkingMemoryFactExceptionpublic Object getNodeMemory(NodeMemory node)
JoinMemory for a particular
JoinNode.
getNodeMemory in interface InternalWorkingMemorynode - The JoinNode key.
public void clearNodeMemory(NodeMemory node)
clearNodeMemory in interface InternalWorkingMemorypublic WorkingMemoryEventSupport getWorkingMemoryEventSupport()
public AgendaEventSupport getAgendaEventSupport()
getAgendaEventSupport in interface EventSupportgetAgendaEventSupport in interface InternalWorkingMemorypublic void setAsyncExceptionHandler(AsyncExceptionHandler handler)
setAsyncExceptionHandler in interface WorkingMemoryhandler - public void propertyChange(PropertyChangeEvent event)
propertyChange in interface PropertyChangeListenerpublic long getNextPropagationIdCounter()
getNextPropagationIdCounter in interface InternalWorkingMemorypublic Lock getLock()
getLock in interface InternalWorkingMemorypublic IProcessInstance startProcess(String processId)
WorkingMemory
startProcess in interface WorkingMemorypublic List iterateObjectsToList()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||