|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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 JoinNode s. |
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
JoinNode
s.
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 WorkingMemory
listener
- The listener to add.public void removeEventListener(WorkingMemoryEventListener listener)
WorkingMemory
removeEventListener
in interface WorkingMemory
listener
- The listener to remove.public 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 List getAgendaEventListeners()
WorkingMemory
getAgendaEventListeners
in interface EventSupport
getAgendaEventListeners
in interface WorkingMemory
public FactHandleFactory getFactHandleFactory()
getFactHandleFactory
in interface InternalWorkingMemory
public Map getGlobals()
WorkingMemory
getGlobals
in interface WorkingMemory
WorkingMemory
public void setGlobal(String name, Object value)
WorkingMemory
setGlobal
in interface WorkingMemory
name
- the name under which to populate the datavalue
- the global value, cannot be nullWorkingMemory
public void setGlobalResolver(GlobalResolver globalResolver)
WorkingMemory
setGlobalResolver
in interface WorkingMemory
public long getId()
getId
in interface InternalWorkingMemory
public Object getGlobal(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(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 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(Object object)
WorkingMemory
FactHandle
associated with an Object.
getFactHandle
in interface WorkingMemory
object
- The object.
WorkingMemory
public ObjectHashMap getFactHandleMap()
getFactHandleMap
in interface InternalWorkingMemory
public Iterator iterateObjects()
iterateObjects
in interface WorkingMemory
public Iterator iterateObjects(ObjectFilter filter)
iterateObjects
in interface WorkingMemory
public Iterator iterateFactHandles()
iterateFactHandles
in interface WorkingMemory
public Iterator iterateFactHandles(ObjectFilter filter)
iterateFactHandles
in interface WorkingMemory
public abstract QueryResults getQueryResults(String query)
WorkingMemory
getQueryResults
in interface WorkingMemory
query
- The name of the query.
public AgendaGroup getFocus()
getFocus
in interface WorkingMemory
public void setFocus(String focus)
setFocus
in interface WorkingMemory
public void setFocus(AgendaGroup focus)
setFocus
in interface WorkingMemory
public TruthMaintenanceSystem getTruthMaintenanceSystem()
getTruthMaintenanceSystem
in interface InternalWorkingMemory
public FactHandle assertObject(Object object) throws FactException
WorkingMemory
assertObject
in interface WorkingMemory
object
- The fact object.
FactException
- If an error occurs.WorkingMemory
public FactHandle assertLogicalObject(Object object) throws FactException
FactException
WorkingMemory
public FactHandle assertObject(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(Object object, boolean dynamic) throws FactException
assertLogicalObject
in interface InternalWorkingMemoryActions
FactException
public FactHandle assertObject(Object object, boolean dynamic, boolean logical, Rule rule, Activation activation) throws FactException
assertObject
in interface InternalWorkingMemoryActions
FactException
protected void addPropertyChangeListener(Object object)
public abstract void doAssertObject(InternalFactHandle factHandle, 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 InternalWorkingMemory
retractObject
in interface InternalWorkingMemoryActions
FactException
WorkingMemory
public void modifyObject(FactHandle handle, 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 void modifyObject(FactHandle factHandle, Object object, Rule rule, Activation activation) throws FactException
modifyObject
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 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()
public AgendaEventSupport getAgendaEventSupport()
getAgendaEventSupport
in interface EventSupport
getAgendaEventSupport
in interface InternalWorkingMemory
public void setAsyncExceptionHandler(AsyncExceptionHandler handler)
setAsyncExceptionHandler
in interface WorkingMemory
handler
- public void propertyChange(PropertyChangeEvent event)
propertyChange
in interface PropertyChangeListener
public long getNextPropagationIdCounter()
getNextPropagationIdCounter
in interface InternalWorkingMemory
public Lock getLock()
getLock
in interface InternalWorkingMemory
public IProcessInstance startProcess(String processId)
WorkingMemory
startProcess
in interface WorkingMemory
public List iterateObjectsToList()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |