org.drools
Interface WorkingMemory

All Superinterfaces:
java.io.Serializable
All Known Subinterfaces:
InternalWorkingMemoryActions
All Known Implementing Classes:
AbstractWorkingMemory, SynchronizedWorkingMemory

public interface WorkingMemory
extends java.io.Serializable

A knowledge session for a RuleBase. While this object can be serialised out, it cannot be serialised in. This is because the RuleBase reference is transient. Please see the RuleBase interface for serializing in WorkingMemories from an InputStream.

 

Method Summary
 void addEventListener(AgendaEventListener listener)
          Add an event listener.
 void addEventListener(WorkingMemoryEventListener listener)
          Add an event listener.
 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.
 void clearAgenda()
          Clear the Agenda
 void clearAgendaGroup(java.lang.String group)
          Clear the Agenda Group
 void dispose()
          Forces the workingMemory to be derefenced from
 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()
           
 java.util.List getAgendaEventListeners()
          Returns all event listeners.
 FactHandle getFactHandle(java.lang.Object object)
          Retrieve the FactHandle associated with an Object.
 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
 java.lang.Object getObject(FactHandle handle)
          Retrieve the object associated with a 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.
 QueryResults getQueryResults(java.lang.String query)
           
 RuleBase getRuleBase()
          Retrieve the RuleBase of this working memory.
 java.util.List getWorkingMemoryEventListeners()
          Returns all event listeners.
 void modifyObject(FactHandle handle, java.lang.Object object)
          Modify a fact.
 void removeEventListener(AgendaEventListener listener)
          Remove an event listener.
 void removeEventListener(WorkingMemoryEventListener listener)
          Remove an event listener.
 void retractObject(FactHandle handle)
          Retract a fact.
 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.
 

Method Detail

addEventListener

public void addEventListener(WorkingMemoryEventListener listener)
Add an event listener.

Parameters:
listener - The listener to add.

removeEventListener

public void removeEventListener(WorkingMemoryEventListener listener)
Remove an event listener.

Parameters:
listener - The listener to remove.

getWorkingMemoryEventListeners

public java.util.List getWorkingMemoryEventListeners()
Returns all event listeners.

Returns:
listeners The listeners.

addEventListener

public void addEventListener(AgendaEventListener listener)
Add an event listener.

Parameters:
listener - The listener to add.

removeEventListener

public void removeEventListener(AgendaEventListener listener)
Remove an event listener.

Parameters:
listener - The listener to remove.

getAgendaEventListeners

public java.util.List getAgendaEventListeners()
Returns all event listeners.

Returns:
listeners The listeners.

getAgenda

public Agenda getAgenda()

getGlobals

public java.util.Map getGlobals()
Retrieve all of the set application data in this memory

Returns:
the application data as a Map

setGlobal

public void setGlobal(java.lang.String name,
                      java.lang.Object value)
Set a specific piece of global in this working memory.

Parameters:
name - the name under which to populate the data
value - the application data

getGlobal

public java.lang.Object getGlobal(java.lang.String name)
Retrieve a specific piece of global data by name

Returns:
application data or null if nothing is set under this name

getRuleBase

public RuleBase getRuleBase()
Retrieve the RuleBase of this working memory.

Returns:
The RuleBase.

fireAllRules

public void fireAllRules()
                  throws FactException
Fire all items on the agenda until empty.

Throws:
FactException - If an error occurs.

fireAllRules

public void fireAllRules(AgendaFilter agendaFilter)
                  throws FactException
Fire all items on the agenda until empty, using the given AgendaFiler

Throws:
FactException - If an error occurs.

getObject

public java.lang.Object getObject(FactHandle handle)
                           throws NoSuchFactObjectException
Retrieve the object associated with a FactHandle.

Throws:
NoSuchFactObjectException - If no object is known to be associated with the specified handle.
Parameters:
handle - The fact handle.
Returns:
The associated object.
See Also:
#containsObject

getFactHandle

public FactHandle getFactHandle(java.lang.Object object)
                         throws NoSuchFactHandleException
Retrieve the FactHandle associated with an Object.

Throws:
NoSuchFactHandleException - If no handle is known to be associated with the specified object.
Parameters:
object - The object.
Returns:
The associated fact handle.
See Also:
#containsObject

getObjects

public java.util.List getObjects()
Retrieve all known objects.

Returns:
The list of all known objects.

getFocus

public AgendaGroup getFocus()

setFocus

public void setFocus(java.lang.String focus)

setFocus

public void setFocus(AgendaGroup focus)

getObjects

public java.util.List getObjects(java.lang.Class objectClass)
Retrieve all known objects of the specified class.

Parameters:
objectClass - The class of object to return.
Returns:
The list of all known objects of the specified class.

getFactHandles

public java.util.List getFactHandles()
Retrieve all known Fact Handles.

Returns:
The list of all known fact handles.

assertObject

public FactHandle assertObject(java.lang.Object object)
                        throws FactException
Assert a fact.

Throws:
FactException - If an error occurs.
Parameters:
object - The fact object.
Returns:
The new fact-handle associated with the object.

getQueryResults

public QueryResults getQueryResults(java.lang.String query)

assertObject

public FactHandle assertObject(java.lang.Object object,
                               boolean dynamic)
                        throws FactException
Assert a fact registering JavaBean PropertyChangeListeners on the Object to automatically trigger modifyObject calls if dynamic is true.

Throws:
FactException - If an error occurs.
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.

retractObject

public void retractObject(FactHandle handle)
                   throws FactException
Retract a fact.

Throws:
FactException - If an error occurs.
Parameters:
handle - The fact-handle associated with the fact to retract.

modifyObject

public void modifyObject(FactHandle handle,
                         java.lang.Object object)
                  throws FactException
Modify a fact.

Throws:
FactException - If an error occurs.
Parameters:
handle - The fact-handle associated with the fact to modify.
object - The new value of the fact.

setAsyncExceptionHandler

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

Parameters:
handler -

clearAgenda

public void clearAgenda()
Clear the Agenda


clearAgendaGroup

public void clearAgendaGroup(java.lang.String group)
Clear the Agenda Group


dispose

public void dispose()
Forces the workingMemory to be derefenced from