org.drools.common
Class AbstractWorkingMemory

java.lang.Object
  extended by org.drools.common.AbstractWorkingMemory
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, EventSupport, InternalWorkingMemory, InternalWorkingMemoryActions, RuleBaseEventManager, WorkingMemory, WorkingMemoryEventManager
Direct Known Subclasses:
ReteooWorkingMemory

public abstract class AbstractWorkingMemory
extends java.lang.Object
implements InternalWorkingMemoryActions, EventSupport, java.beans.PropertyChangeListener

Implementation of WorkingMemory.

Author:
bob mcwhirter , Mark Proctor, Simon Harris
See Also:
Serialized Form

Nested Class Summary
 class AbstractWorkingMemory.RuleFlowDeactivateEvent
           
 
Field Summary
protected  java.util.List __ruleBaseEventListeners
           
protected  java.util.LinkedList actionQueue
           
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  boolean discardOnLogicalOverride
           
protected  boolean evaluatingActionQueue
           
protected  boolean firing
          Flag to determine if a rule is currently being fired.
protected  GlobalResolver globalResolver
          Global values which are associated with this memory.
protected  boolean halt
           
protected  FactHandleFactory handleFactory
           
protected  long id
           
protected  ReentrantLock lock
           
protected  PrimitiveLongMap nodeMemories
          The actual memory for the JoinNodes.
protected static java.lang.Object NULL
           
protected  long propagationIdCounter
           
protected  java.util.Map queryResults
           
protected  InternalRuleBase ruleBase
          The RuleBase with which this memory is associated.
protected  RuleFlowEventSupport ruleFlowEventSupport
           
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(RuleBaseEventListener listener)
          Add an event listener.
 void addEventListener(RuleFlowEventListener listener)
          Add an event listener.
 void addEventListener(WorkingMemoryEventListener listener)
          Add an event listener.
 void addLIANodePropagation(LIANodePropagation liaNodePropagation)
           
protected  void addPropertyChangeListener(java.lang.Object object)
           
 void clearActivationGroup(java.lang.String group)
          Clears the Activation Group, cancellings all its Activations
 void clearAgenda()
          Clear the Agenda.
 void clearAgendaGroup(java.lang.String group)
          Clear the Agenda Group, cancelling all its Activations.
 void clearNodeMemory(NodeMemory node)
           
 void clearRuleFlowGroup(java.lang.String group)
          Clears the RuleFlow group, cancelling all its Activations
abstract  void doInsert(InternalFactHandle factHandle, java.lang.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
 void fireAllRules(AgendaFilter agendaFilter, int fireLimit)
          Fire all items on the agenda using the given AgendaFiler until empty or at most 'fireLimit' rules have fired
 void fireAllRules(int fireLimit)
          Fire all items on the agenda until empty or at most 'fireLimit' rules have fired
 java.util.Map getActivationParameters(Activation activation)
          Helper method
 java.util.Map.Entry[] getActivationParameters(long activationId)
           
 Agenda getAgenda()
          Returns the Agenda for this WorkingMemory.
 java.util.List getAgendaEventListeners()
          Returns all event listeners.
 AgendaEventSupport getAgendaEventSupport()
           
 ObjectHashMap getAssertMap()
           
 ExecutorService getExecutorService()
           
 FactHandle getFactHandle(java.lang.Object object)
          Retrieve the FactHandle associated with an Object.
 FactHandle getFactHandleByIdentity(java.lang.Object object)
          Looks for the fact handle associated to the given object by looking up the object IDENTITY (==), even if rule base is configured to AssertBehavior.EQUALITY.
 FactHandleFactory getFactHandleFactory()
           
 ObjectHashMap getFactHandleMap()
          This is an internal method, used to avoid java.util.Iterator adaptors
 AgendaGroup getFocus()
          Returns the AgendaGroup which has the current WorkingMemory focus.
 java.lang.Object getGlobal(java.lang.String identifier)
          Retrieve a specific instance of global data by identifier
 GlobalResolver getGlobalResolver()
          Returns the current GlobalResolver
 long getId()
           
 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.
abstract  QueryResults getQueryResults(java.lang.String query)
          Retrieve the QueryResults of the specified query.
 RuleBase getRuleBase()
          Retrieve the RuleBase for this working memory.
 java.util.List getRuleBaseEventListeners()
          Returns all event listeners.
 java.util.List getRuleFlowEventListeners()
          Returns all event listeners.
 RuleFlowEventSupport getRuleFlowEventSupport()
           
 TruthMaintenanceSystem getTruthMaintenanceSystem()
           
 java.util.List getWorkingMemoryEventListeners()
          Returns all event listeners.
 WorkingMemoryEventSupport getWorkingMemoryEventSupport()
           
 void halt()
          Stops rule firing after the currect rule finishes executing
protected  void insert(InternalFactHandle handle, java.lang.Object object, Rule rule, Activation activation)
           
 FactHandle insert(java.lang.Object object)
          Assert a fact.
 FactHandle insert(java.lang.Object object, boolean dynamic)
          Insert a fact registering JavaBean PropertyChangeListeners on the Object to automatically trigger update calls if dynamic is true.
 FactHandle insert(java.lang.Object object, boolean dynamic, boolean logical, Rule rule, Activation activation)
           
 FactHandle insertLogical(java.lang.Object object)
           
 FactHandle insertLogical(java.lang.Object object, boolean dynamic)
           
 boolean isSequential()
           
 java.util.Iterator iterateFactHandles()
          This class is not thread safe, changes to the working memory during iteration may give unexpected results
 java.util.Iterator iterateFactHandles(ObjectFilter filter)
          This class is not thread safe, changes to the working memory during iteration may give unexpected results
 java.util.Iterator iterateObjects()
          This class is not thread safe, changes to the working memory during iteration may give unexpected results
 java.util.Iterator iterateObjects(ObjectFilter filter)
          This class is not thread safe, changes to the working memory during iteration may give unexpected results
 java.util.List iterateObjectsToList()
           
 void modifyInsert(FactHandle factHandle, java.lang.Object object)
           
 void modifyInsert(FactHandle factHandle, java.lang.Object object, Rule rule, Activation activation)
           
 void modifyRetract(FactHandle factHandle)
           
 void modifyRetract(FactHandle factHandle, Rule rule, Activation activation)
           
 void propertyChange(java.beans.PropertyChangeEvent event)
           
 void queueWorkingMemoryAction(WorkingMemoryAction action)
           
 void removeEventListener(AgendaEventListener listener)
          Remove an event listener.
 void removeEventListener(RuleBaseEventListener listener)
          Remove an event listener.
 void removeEventListener(RuleFlowEventListener 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 retract(FactHandle handle)
          Retract a fact.
 void retract(FactHandle factHandle, boolean removeLogical, boolean updateEqualsMap, Rule rule, Activation activation)
           
 void setAgendaEventSupport(AgendaEventSupport agendaEventSupport)
           
 void setAsyncExceptionHandler(AsyncExceptionHandler handler)
          Sets the AsyncExceptionHandler to handle exceptions thrown by the Agenda Scheduler used for duration rules.
 void setExecutorService(ExecutorService executor)
           
 void setFocus(AgendaGroup focus)
          Set the focus to the specified AgendaGroup
 void setFocus(java.lang.String focus)
          Set the focus to the specified AgendaGroup
 void setGlobal(java.lang.String identifier, java.lang.Object value)
          Set a specific instance as a global in this working memory.
 void setGlobalResolver(GlobalResolver globalResolver)
          Sets the GlobalResolver instance to be used when resolving globals, replaces the current GlobalResolver.
 void setId(long id)
           
 void setRuleBase(InternalRuleBase ruleBase)
           
 void setRuleFlowEventSupport(RuleFlowEventSupport ruleFlowEventSupport)
           
 void setWorkingMemoryEventSupport(WorkingMemoryEventSupport workingMemoryEventSupport)
           
 ProcessInstance startProcess(java.lang.String processId)
          Starts a new process instance for the process with the given id.
 void update(FactHandle handle, java.lang.Object object)
          Inform the WorkingMemory that a Fact has been modified and that it should now update the network.
 void update(FactHandle factHandle, java.lang.Object object, Rule rule, Activation activation)
          modify is implemented as half way retract / assert due to the truth maintenance issues.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.drools.WorkingMemory
getQueryResults
 

Field Detail

ADD_REMOVE_PROPERTY_CHANGE_LISTENER_ARG_TYPES

protected static final java.lang.Class[] ADD_REMOVE_PROPERTY_CHANGE_LISTENER_ARG_TYPES

id

protected long id

addRemovePropertyChangeListenerArgs

protected final java.lang.Object[] addRemovePropertyChangeListenerArgs
The arguments used when adding/removing a property change listener.


nodeMemories

protected final PrimitiveLongMap nodeMemories
The actual memory for the JoinNodes.


queryResults

protected java.util.Map queryResults

globalResolver

protected GlobalResolver globalResolver
Global values which are associated with this memory.


NULL

protected static final java.lang.Object NULL

workingMemoryEventSupport

protected WorkingMemoryEventSupport workingMemoryEventSupport
The eventSupport


agendaEventSupport

protected AgendaEventSupport agendaEventSupport

ruleFlowEventSupport

protected RuleFlowEventSupport ruleFlowEventSupport

__ruleBaseEventListeners

protected java.util.List __ruleBaseEventListeners

ruleBase

protected transient InternalRuleBase ruleBase
The RuleBase with which this memory is associated.


handleFactory

protected final FactHandleFactory handleFactory

tms

protected final TruthMaintenanceSystem tms

agenda

protected DefaultAgenda agenda
Rule-firing agenda.


actionQueue

protected final java.util.LinkedList actionQueue

evaluatingActionQueue

protected volatile boolean evaluatingActionQueue

lock

protected final ReentrantLock lock

discardOnLogicalOverride

protected final boolean discardOnLogicalOverride

propagationIdCounter

protected long propagationIdCounter

firing

protected volatile boolean firing
Flag to determine if a rule is currently being fired.


halt

protected volatile boolean halt
Constructor Detail

AbstractWorkingMemory

public AbstractWorkingMemory(int id,
                             InternalRuleBase ruleBase,
                             FactHandleFactory handleFactory)
Construct.

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

setRuleBase

public void setRuleBase(InternalRuleBase ruleBase)
Specified by:
setRuleBase in interface InternalWorkingMemory

setWorkingMemoryEventSupport

public void setWorkingMemoryEventSupport(WorkingMemoryEventSupport workingMemoryEventSupport)
Specified by:
setWorkingMemoryEventSupport in interface InternalWorkingMemory

setAgendaEventSupport

public void setAgendaEventSupport(AgendaEventSupport agendaEventSupport)
Specified by:
setAgendaEventSupport in interface InternalWorkingMemory

setRuleFlowEventSupport

public void setRuleFlowEventSupport(RuleFlowEventSupport ruleFlowEventSupport)
Specified by:
setRuleFlowEventSupport in interface InternalWorkingMemory

isSequential

public boolean isSequential()
Specified by:
isSequential in interface InternalWorkingMemory

addLIANodePropagation

public void addLIANodePropagation(LIANodePropagation liaNodePropagation)
Specified by:
addLIANodePropagation in interface InternalWorkingMemory

addEventListener

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

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

removeEventListener

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

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

getWorkingMemoryEventListeners

public java.util.List getWorkingMemoryEventListeners()
Description copied from interface: WorkingMemoryEventManager
Returns all event listeners.

Specified by:
getWorkingMemoryEventListeners in interface EventSupport
Specified by:
getWorkingMemoryEventListeners in interface WorkingMemoryEventManager
Returns:
listeners The listeners.

addEventListener

public void addEventListener(AgendaEventListener listener)
Description copied from interface: WorkingMemoryEventManager
Add an event listener.

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

removeEventListener

public void removeEventListener(AgendaEventListener listener)
Description copied from interface: WorkingMemoryEventManager
Remove an event listener.

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

getAgendaEventListeners

public java.util.List getAgendaEventListeners()
Description copied from interface: WorkingMemoryEventManager
Returns all event listeners.

Specified by:
getAgendaEventListeners in interface EventSupport
Specified by:
getAgendaEventListeners in interface WorkingMemoryEventManager
Returns:
listeners The listeners.

addEventListener

public void addEventListener(RuleFlowEventListener listener)
Description copied from interface: WorkingMemoryEventManager
Add an event listener.

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

removeEventListener

public void removeEventListener(RuleFlowEventListener listener)
Description copied from interface: WorkingMemoryEventManager
Remove an event listener.

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

getRuleFlowEventListeners

public java.util.List getRuleFlowEventListeners()
Description copied from interface: WorkingMemoryEventManager
Returns all event listeners.

Specified by:
getRuleFlowEventListeners in interface EventSupport
Specified by:
getRuleFlowEventListeners in interface WorkingMemoryEventManager
Returns:
listeners The listeners.

addEventListener

public void addEventListener(RuleBaseEventListener listener)
Description copied from interface: RuleBaseEventManager
Add an event listener.

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

getRuleBaseEventListeners

public java.util.List getRuleBaseEventListeners()
Description copied from interface: RuleBaseEventManager
Returns all event listeners.

Specified by:
getRuleBaseEventListeners in interface RuleBaseEventManager
Returns:
listeners The listeners.

removeEventListener

public void removeEventListener(RuleBaseEventListener listener)
Description copied from interface: RuleBaseEventManager
Remove an event listener.

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

getFactHandleFactory

public FactHandleFactory getFactHandleFactory()
Specified by:
getFactHandleFactory in interface InternalWorkingMemory

setGlobal

public void setGlobal(java.lang.String identifier,
                      java.lang.Object value)
Description copied from interface: WorkingMemory
Set a specific instance as a global in this working memory. Null values will return doing nothing. The global identifier and its type must be declared in the drl.

Specified by:
setGlobal in interface WorkingMemory
Parameters:
identifier - the identifier under which to populate the data
value - the global value, cannot be null

setGlobalResolver

public void setGlobalResolver(GlobalResolver globalResolver)
Description copied from interface: WorkingMemory
Sets the GlobalResolver instance to be used when resolving globals, replaces the current GlobalResolver. Typcicaly a delegating GlobalResolver is created that first gets a reference to the current GlobalResolver, for delegating

Specified by:
setGlobalResolver in interface WorkingMemory

getGlobalResolver

public GlobalResolver getGlobalResolver()
Description copied from interface: WorkingMemory
Returns the current GlobalResolver

Specified by:
getGlobalResolver in interface WorkingMemory
Returns:

getId

public long getId()
Specified by:
getId in interface InternalWorkingMemory

setId

public void setId(long id)
Specified by:
setId in interface InternalWorkingMemory

getGlobal

public java.lang.Object getGlobal(java.lang.String identifier)
Description copied from interface: WorkingMemory
Retrieve a specific instance of global data by identifier

Specified by:
getGlobal in interface WorkingMemory
Returns:
application data or null if nothing is set under this identifier

getAgenda

public Agenda getAgenda()
Description copied from interface: WorkingMemory
Returns the Agenda for this WorkingMemory. While the WorkingMemory interface is considered public, the Agenda interface is more subject to change.

Specified by:
getAgenda in interface WorkingMemory
Returns:
the Agenda

clearAgenda

public void clearAgenda()
Description copied from interface: WorkingMemory
Clear the Agenda. Iterates over each AgendaGroup cancalling all Activations.

Specified by:
clearAgenda in interface WorkingMemory

clearAgendaGroup

public void clearAgendaGroup(java.lang.String group)
Description copied from interface: WorkingMemory
Clear the Agenda Group, cancelling all its Activations.

Specified by:
clearAgendaGroup in interface WorkingMemory

clearActivationGroup

public void clearActivationGroup(java.lang.String group)
Description copied from interface: WorkingMemory
Clears the Activation Group, cancellings all its Activations

Specified by:
clearActivationGroup in interface WorkingMemory

clearRuleFlowGroup

public void clearRuleFlowGroup(java.lang.String group)
Description copied from interface: WorkingMemory
Clears the RuleFlow group, cancelling all its Activations

Specified by:
clearRuleFlowGroup in interface WorkingMemory

getRuleBase

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

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

halt

public void halt()
Description copied from interface: WorkingMemory
Stops rule firing after the currect rule finishes executing

Specified by:
halt in interface WorkingMemory

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 a RuntimeException error occurs.

fireAllRules

public void fireAllRules(int fireLimit)
                  throws FactException
Description copied from interface: WorkingMemory
Fire all items on the agenda until empty or at most 'fireLimit' rules have fired

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

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 a RuntimeException error occurs.

fireAllRules

public void fireAllRules(AgendaFilter agendaFilter,
                         int fireLimit)
                  throws FactException
Description copied from interface: WorkingMemory
Fire all items on the agenda using the given AgendaFiler until empty or at most 'fireLimit' rules have fired

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

getObject

public java.lang.Object getObject(FactHandle handle)
Returns the fact Object for the given FactHandle. It actually attemps to return the value from the handle, before retrieving it from objects map.

Specified by:
getObject in interface WorkingMemory
Parameters:
handle - The FactHandle reference for the Object lookup
Returns:
The associated object.
See Also:
WorkingMemory

getAssertMap

public ObjectHashMap getAssertMap()
Specified by:
getAssertMap in interface InternalWorkingMemory

getFactHandle

public FactHandle getFactHandle(java.lang.Object object)
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.
See Also:
WorkingMemory

getFactHandleByIdentity

public FactHandle getFactHandleByIdentity(java.lang.Object object)
Description copied from interface: InternalWorkingMemory
Looks for the fact handle associated to the given object by looking up the object IDENTITY (==), even if rule base is configured to AssertBehavior.EQUALITY.

Specified by:
getFactHandleByIdentity in interface InternalWorkingMemory
Returns:
null if fact handle not found
See Also:
InternalWorkingMemory

getFactHandleMap

public ObjectHashMap getFactHandleMap()
This is an internal method, used to avoid java.util.Iterator adaptors

Specified by:
getFactHandleMap in interface InternalWorkingMemory

iterateObjects

public java.util.Iterator iterateObjects()
This class is not thread safe, changes to the working memory during iteration may give unexpected results

Specified by:
iterateObjects in interface WorkingMemory
Returns:
the Iterator

iterateObjects

public java.util.Iterator iterateObjects(ObjectFilter filter)
This class is not thread safe, changes to the working memory during iteration may give unexpected results

Specified by:
iterateObjects in interface WorkingMemory
Returns:
the Iterator

iterateFactHandles

public java.util.Iterator iterateFactHandles()
This class is not thread safe, changes to the working memory during iteration may give unexpected results

Specified by:
iterateFactHandles in interface WorkingMemory
Returns:
the Iterator

iterateFactHandles

public java.util.Iterator iterateFactHandles(ObjectFilter filter)
This class is not thread safe, changes to the working memory during iteration may give unexpected results

Specified by:
iterateFactHandles in interface WorkingMemory
Returns:
the Iterator

getQueryResults

public abstract QueryResults getQueryResults(java.lang.String query)
Description copied from interface: WorkingMemory
Retrieve the QueryResults of the specified query.

Specified by:
getQueryResults in interface WorkingMemory
Parameters:
query - The name of the query.
Returns:
The QueryResults of the specified query. If no results match the query it is empty.

getFocus

public AgendaGroup getFocus()
Description copied from interface: WorkingMemory
Returns the AgendaGroup which has the current WorkingMemory focus. The AgendaGroup interface is subject to change.

Specified by:
getFocus in interface WorkingMemory
Returns:
the AgendaGroup

setFocus

public void setFocus(java.lang.String focus)
Description copied from interface: WorkingMemory
Set the focus to the specified AgendaGroup

Specified by:
setFocus in interface WorkingMemory

setFocus

public void setFocus(AgendaGroup focus)
Description copied from interface: WorkingMemory
Set the focus to the specified AgendaGroup

Specified by:
setFocus in interface WorkingMemory

getTruthMaintenanceSystem

public TruthMaintenanceSystem getTruthMaintenanceSystem()
Specified by:
getTruthMaintenanceSystem in interface InternalWorkingMemory

insert

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

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

insertLogical

public FactHandle insertLogical(java.lang.Object object)
                         throws FactException
Throws:
FactException
See Also:
WorkingMemory

insert

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

Specified by:
insert 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 a RuntimeException error occurs.

insertLogical

public FactHandle insertLogical(java.lang.Object object,
                                boolean dynamic)
                         throws FactException
Specified by:
insertLogical in interface InternalWorkingMemoryActions
Throws:
FactException

insert

public FactHandle insert(java.lang.Object object,
                         boolean dynamic,
                         boolean logical,
                         Rule rule,
                         Activation activation)
                  throws FactException
Specified by:
insert in interface InternalWorkingMemoryActions
Throws:
FactException

insert

protected void insert(InternalFactHandle handle,
                      java.lang.Object object,
                      Rule rule,
                      Activation activation)

addPropertyChangeListener

protected void addPropertyChangeListener(java.lang.Object object)

doInsert

public abstract void doInsert(InternalFactHandle factHandle,
                              java.lang.Object object,
                              PropagationContext propagationContext)
                       throws FactException
Throws:
FactException

removePropertyChangeListener

protected void removePropertyChangeListener(FactHandle handle)

retract

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

Specified by:
retract in interface WorkingMemory
Parameters:
handle - The fact-handle associated with the fact to retract.
Throws:
FactException - If a RuntimeException error occurs.

doRetract

public abstract void doRetract(InternalFactHandle factHandle,
                               PropagationContext propagationContext)

retract

public void retract(FactHandle factHandle,
                    boolean removeLogical,
                    boolean updateEqualsMap,
                    Rule rule,
                    Activation activation)
             throws FactException
Specified by:
retract in interface InternalWorkingMemory
Specified by:
retract in interface InternalWorkingMemoryActions
Throws:
FactException
See Also:
WorkingMemory

modifyRetract

public void modifyRetract(FactHandle factHandle)
Specified by:
modifyRetract in interface WorkingMemory

modifyRetract

public void modifyRetract(FactHandle factHandle,
                          Rule rule,
                          Activation activation)
Specified by:
modifyRetract in interface InternalWorkingMemoryActions

modifyInsert

public void modifyInsert(FactHandle factHandle,
                         java.lang.Object object)
Specified by:
modifyInsert in interface WorkingMemory

modifyInsert

public void modifyInsert(FactHandle factHandle,
                         java.lang.Object object,
                         Rule rule,
                         Activation activation)
Specified by:
modifyInsert in interface InternalWorkingMemoryActions

update

public void update(FactHandle handle,
                   java.lang.Object object)
            throws FactException
Description copied from interface: WorkingMemory
Inform the WorkingMemory that a Fact has been modified and that it should now update the network.

Specified by:
update in interface WorkingMemory
Parameters:
handle - The fact-handle associated with the fact to modify.
object - The new value of the fact.
Throws:
FactException - If a RuntimeException error occurs.

update

public void update(FactHandle factHandle,
                   java.lang.Object object,
                   Rule rule,
                   Activation activation)
            throws FactException
modify is implemented as half way retract / assert due to the truth maintenance issues.

Specified by:
update in interface InternalWorkingMemoryActions
Throws:
FactException
See Also:
WorkingMemory

executeQueuedActions

public void executeQueuedActions()
Specified by:
executeQueuedActions in interface InternalWorkingMemory

queueWorkingMemoryAction

public void queueWorkingMemoryAction(WorkingMemoryAction action)
Specified by:
queueWorkingMemoryAction in interface InternalWorkingMemory

removeLogicalDependencies

public void removeLogicalDependencies(Activation activation,
                                      PropagationContext context,
                                      Rule rule)
                               throws FactException
Specified by:
removeLogicalDependencies in interface InternalWorkingMemory
Throws:
FactException

getNodeMemory

public java.lang.Object getNodeMemory(NodeMemory node)
Retrieve the JoinMemory for a particular JoinNode.

Specified by:
getNodeMemory in interface InternalWorkingMemory
Parameters:
node - The JoinNode key.
Returns:
The node's memory.

clearNodeMemory

public void clearNodeMemory(NodeMemory node)
Specified by:
clearNodeMemory in interface InternalWorkingMemory

getWorkingMemoryEventSupport

public WorkingMemoryEventSupport getWorkingMemoryEventSupport()
Specified by:
getWorkingMemoryEventSupport in interface EventSupport

getAgendaEventSupport

public AgendaEventSupport getAgendaEventSupport()
Specified by:
getAgendaEventSupport in interface EventSupport

getRuleFlowEventSupport

public RuleFlowEventSupport getRuleFlowEventSupport()
Specified by:
getRuleFlowEventSupport in interface EventSupport

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 -

propertyChange

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

getNextPropagationIdCounter

public long getNextPropagationIdCounter()
Specified by:
getNextPropagationIdCounter in interface InternalWorkingMemory

getLock

public Lock getLock()
Specified by:
getLock in interface InternalWorkingMemory

startProcess

public ProcessInstance startProcess(java.lang.String processId)
Description copied from interface: WorkingMemory
Starts a new process instance for the process with the given id.

Specified by:
startProcess in interface WorkingMemory

iterateObjectsToList

public java.util.List iterateObjectsToList()

getActivationParameters

public java.util.Map.Entry[] getActivationParameters(long activationId)

getActivationParameters

public java.util.Map getActivationParameters(Activation activation)
Helper method


getExecutorService

public ExecutorService getExecutorService()
Specified by:
getExecutorService in interface InternalWorkingMemory

setExecutorService

public void setExecutorService(ExecutorService executor)
Specified by:
setExecutorService in interface InternalWorkingMemory