org.drools.reteoo
Class WorkingMemoryImpl

java.lang.Object
  extended by org.drools.reteoo.WorkingMemoryImpl
All Implemented Interfaces:
PropertyChangeListener, Serializable, EventListener, WorkingMemory

 class WorkingMemoryImpl
extends Object
implements WorkingMemory, PropertyChangeListener

Implementation of WorkingMemory.

Author:
bob mcwhirter , Simon Harris

Constructor Summary
WorkingMemoryImpl(RuleBaseImpl ruleBase)
          Construct.
 
Method Summary
 void addEventListener(WorkingMemoryEventListener listener)
          Add an event listener.
 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.
 void clearAgenda()
          Clear the Agenda
 boolean containsObject(FactHandle handle)
          Determine if an object is associated with a FactHandle.
 void dumpMemory()
           
 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
protected  Agenda getAgenda()
          Retrieve the rule-firing Agenda for this WorkingMemory.
 Object getApplicationData(String name)
          Retrieve a specific piece of application data by name
 Map getApplicationDataMap()
          Retrieve all of the set application data in this memory
 List getEventListeners()
          Returns all event listeners.
 WorkingMemoryEventSupport getEventSupport()
           
 FactHandle getFactHandle(Object object)
          Retrieve the FactHandle associated with an Object.
 List getFactHandles()
          Retrieve all known Fact Handles.
 JoinMemory getJoinMemory(JoinNode node)
          Retrieve the JoinMemory for a particular JoinNode.
 Object getObject(FactHandle handle)
          Retrieve the object associated with a FactHandle.
 List getObjects()
          Retrieve all known objects.
 List getObjects(Class objectClass)
          Retrieve all known objects of the specified class.
 RuleBase getRuleBase()
          Retrieve the RuleBase of this working memory.
 void modifyObject(FactHandle handle, Object object)
          Modify a fact.
(package private)  FactHandle newFactHandle()
          Create a new FactHandle.
 void propertyChange(PropertyChangeEvent event)
           
(package private)  Object putObject(FactHandle handle, Object object)
          Associate an object with its handle.
 void removeEventListener(WorkingMemoryEventListener listener)
          Remove an event listener.
(package private)  Object removeObject(FactHandle handle)
           
 void retractObject(FactHandle handle)
          Retract a fact.
 void setApplicationData(String name, Object value)
          Set a specific piece of application data in this working memory
 void setAsyncExceptionHandler(AsyncExceptionHandler handler)
          Sets the AsyncExceptionHandler to handle exceptions thrown by the Agenda Scheduler used for duration rules.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkingMemoryImpl

public WorkingMemoryImpl(RuleBaseImpl ruleBase)
Construct.

Parameters:
ruleBase - The backing rule-base.
Method Detail

addEventListener

public void addEventListener(WorkingMemoryEventListener listener)
Description copied from interface: WorkingMemory
Add an event listener.

Specified by:
addEventListener in interface WorkingMemory
Parameters:
listener - The listener to add.

removeEventListener

public void removeEventListener(WorkingMemoryEventListener listener)
Description copied from interface: WorkingMemory
Remove an event listener.

Specified by:
removeEventListener in interface WorkingMemory
Parameters:
listener - The listener to remove.

getEventListeners

public List getEventListeners()
Description copied from interface: WorkingMemory
Returns all event listeners.

Specified by:
getEventListeners in interface WorkingMemory
Returns:
listeners The listeners.

newFactHandle

FactHandle newFactHandle()
Create a new FactHandle.

Returns:
The new fact handle.

getApplicationDataMap

public Map getApplicationDataMap()
Description copied from interface: WorkingMemory
Retrieve all of the set application data in this memory

Specified by:
getApplicationDataMap in interface WorkingMemory
Returns:
the application data as a Map
See Also:
WorkingMemory

setApplicationData

public void setApplicationData(String name,
                               Object value)
Description copied from interface: WorkingMemory
Set a specific piece of application data in this working memory

Specified by:
setApplicationData in interface WorkingMemory
Parameters:
name - the name under which to populate the data
value - the application data
See Also:
WorkingMemory

getApplicationData

public Object getApplicationData(String name)
Description copied from interface: WorkingMemory
Retrieve a specific piece of application data by name

Specified by:
getApplicationData in interface WorkingMemory
Returns:
application data or null if nothing is set under this name
See Also:
WorkingMemory

getAgenda

protected Agenda getAgenda()
Retrieve the rule-firing Agenda for this WorkingMemory.

Returns:
The Agenda.

clearAgenda

public void clearAgenda()
Clear the Agenda

Specified by:
clearAgenda in interface WorkingMemory

getRuleBase

public RuleBase getRuleBase()
Description copied from interface: WorkingMemory
Retrieve the RuleBase of this working memory.

Specified by:
getRuleBase in interface WorkingMemory
Returns:
The RuleBase.
See Also:
WorkingMemory

fireAllRules

public void fireAllRules(AgendaFilter agendaFilter)
                  throws FactException
Description copied from interface: WorkingMemory
Fire all items on the agenda until empty, using the given AgendaFiler

Specified by:
fireAllRules in interface WorkingMemory
Throws:
FactException - If an error occurs.

fireAllRules

public void fireAllRules()
                  throws FactException
Description copied from interface: WorkingMemory
Fire all items on the agenda until empty.

Specified by:
fireAllRules in interface WorkingMemory
Throws:
FactException - If an error occurs.
See Also:
WorkingMemory

getObject

public Object getObject(FactHandle handle)
                 throws NoSuchFactObjectException
Description copied from interface: WorkingMemory
Retrieve the object associated with a FactHandle.

Specified by:
getObject in interface WorkingMemory
Parameters:
handle - The fact handle.
Returns:
The associated object.
Throws:
NoSuchFactObjectException - If no object is known to be associated with the specified handle.
See Also:
WorkingMemory

getFactHandle

public FactHandle getFactHandle(Object object)
                         throws NoSuchFactHandleException
Description copied from interface: WorkingMemory
Retrieve the FactHandle associated with an Object.

Specified by:
getFactHandle in interface WorkingMemory
Parameters:
object - The object.
Returns:
The associated fact handle.
Throws:
NoSuchFactHandleException - If no handle is known to be associated with the specified object.
See Also:
WorkingMemory

getFactHandles

public List getFactHandles()
Description copied from interface: WorkingMemory
Retrieve all known Fact Handles.

Specified by:
getFactHandles in interface WorkingMemory
Returns:
The list of all known fact handles.

getObjects

public List getObjects()
Description copied from interface: WorkingMemory
Retrieve all known objects.

Specified by:
getObjects in interface WorkingMemory
Returns:
The list of all known objects.
See Also:
WorkingMemory

getObjects

public List getObjects(Class objectClass)
Description copied from interface: WorkingMemory
Retrieve all known objects of the specified class.

Specified by:
getObjects in interface WorkingMemory
Parameters:
objectClass - The class of object to return.
Returns:
The list of all known objects of the specified class.

containsObject

public boolean containsObject(FactHandle handle)
Description copied from interface: WorkingMemory
Determine if an object is associated with a FactHandle.

Specified by:
containsObject in interface WorkingMemory
Parameters:
handle - The fact handle.
Returns:
true if an object is known to be associated with the specified handle, otherwise false.
See Also:
WorkingMemory

assertObject

public FactHandle assertObject(Object object)
                        throws FactException
Description copied from interface: WorkingMemory
Assert a fact.

Specified by:
assertObject in interface WorkingMemory
Parameters:
object - The fact object.
Returns:
The new fact-handle associated with the object.
Throws:
FactException - If an error occurs.
See Also:
WorkingMemory

assertObject

public FactHandle assertObject(Object object,
                               boolean dynamic)
                        throws FactException
Description copied from interface: WorkingMemory
Assert a fact registering JavaBean PropertyChangeListeners on the Object to automatically trigger modifyObject calls if dynamic is true.

Specified by:
assertObject in interface WorkingMemory
Parameters:
object - The fact object.
dynamic - true if Drools should add JavaBean PropertyChangeListeners to the object.
Returns:
The new fact-handle associated with the object.
Throws:
FactException - If an error occurs.

putObject

Object putObject(FactHandle handle,
                 Object object)
Associate an object with its handle.

Parameters:
handle - The handle.
object - The object.

removeObject

Object removeObject(FactHandle handle)

retractObject

public void retractObject(FactHandle handle)
                   throws FactException
Description copied from interface: WorkingMemory
Retract a fact.

Specified by:
retractObject in interface WorkingMemory
Parameters:
handle - The fact-handle associated with the fact to retract.
Throws:
FactException - If an error occurs.
See Also:
WorkingMemory

modifyObject

public void modifyObject(FactHandle handle,
                         Object object)
                  throws FactException
Description copied from interface: WorkingMemory
Modify a fact.

Specified by:
modifyObject in interface WorkingMemory
Parameters:
handle - The fact-handle associated with the fact to modify.
object - The new value of the fact.
Throws:
FactException - If an error occurs.
See Also:
WorkingMemory

getJoinMemory

public JoinMemory getJoinMemory(JoinNode node)
Retrieve the JoinMemory for a particular JoinNode.

Parameters:
node - The JoinNode key.
Returns:
The node's memory.

getEventSupport

public WorkingMemoryEventSupport getEventSupport()

setAsyncExceptionHandler

public void setAsyncExceptionHandler(AsyncExceptionHandler handler)
Sets the AsyncExceptionHandler to handle exceptions thrown by the Agenda Scheduler used for duration rules.

Specified by:
setAsyncExceptionHandler in interface WorkingMemory
Parameters:
handler -

dumpMemory

public void dumpMemory()

propertyChange

public void propertyChange(PropertyChangeEvent event)
Specified by:
propertyChange in interface PropertyChangeListener


Copyright © 2001-2005 The Codehaus. All Rights Reserved.