org.drools.common
Class AbstractWorkingMemory

java.lang.Object
  extended by org.drools.common.AbstractWorkingMemory
All Implemented Interfaces:
EventSupport, InternalWorkingMemory, InternalWorkingMemoryActions, InternalWorkingMemoryEntryPoint, org.drools.event.process.ProcessEventManager, RuleBaseEventManager, org.drools.runtime.rule.WorkingMemoryEntryPoint, WorkingMemory, WorkingMemoryEventManager
Direct Known Subclasses:
ReteooWorkingMemory

public abstract class AbstractWorkingMemory
extends Object
implements InternalWorkingMemoryActions, EventSupport, org.drools.event.process.ProcessEventManager

Implementation of WorkingMemory.


Nested Class Summary
static class AbstractWorkingMemory.GlobalsAdapter
           
 class AbstractWorkingMemory.RuleFlowDeactivateEvent
           
 
Field Summary
protected  List __ruleBaseEventListeners
           
protected  InternalAgenda agenda
          Rule-firing agenda.
protected  AgendaEventSupport agendaEventSupport
           
protected  org.drools.runtime.Calendars calendars
           
protected  SessionConfiguration config
           
protected  DateFormats dateFormats
           
protected  NamedEntryPoint defaultEntryPoint
           
protected  boolean discardOnLogicalOverride
           
protected  Map<String,WorkingMemoryEntryPoint> entryPoints
           
protected  AtomicBoolean evaluatingActionQueue
           
protected  AtomicBoolean firing
          Flag to determine if a rule is currently being fired.
protected  GlobalResolver globalResolver
          Global values which are associated with this memory.
protected  FactHandleFactory handleFactory
           
protected  int id
           
protected  InternalFactHandle initialFactHandle
           
protected  ReentrantLock lock
           
protected  PartitionManager partitionManager
           
protected  AtomicLong propagationIdCounter
          This must be thread safe as it is incremented and read via different EntryPoints
protected  InternalRuleBase ruleBase
          The RuleBase with which this memory is associated.
protected  AtomicReference<ExternalExecutorService> threadPool
           
protected  WorkingMemoryEventSupport workingMemoryEventSupport
          The eventSupport
 
Constructor Summary
AbstractWorkingMemory()
           
AbstractWorkingMemory(int id, InternalRuleBase ruleBase, FactHandleFactory handleFactory, InternalFactHandle initialFactHandle, long propagationContext, SessionConfiguration config, org.drools.runtime.Environment environment)
           
AbstractWorkingMemory(int id, InternalRuleBase ruleBase, FactHandleFactory handleFactory, InternalFactHandle initialFactHandle, long propagationContext, SessionConfiguration config, org.drools.runtime.Environment environment, WorkingMemoryEventSupport workingMemoryEventSupport, AgendaEventSupport agendaEventSupport)
           
AbstractWorkingMemory(int id, InternalRuleBase ruleBase, FactHandleFactory handleFactory, SessionConfiguration config, org.drools.runtime.Environment environment)
          Construct.
AbstractWorkingMemory(int id, InternalRuleBase ruleBase, FactHandleFactory handleFactory, SessionConfiguration config, org.drools.runtime.Environment environment, WorkingMemoryEventSupport workingMemoryEventSupport, AgendaEventSupport agendaEventSupport)
           
 
Method Summary
 void activationFired()
          This method is called by the agenda right after an activation was fired to allow the working memory to resume any activities blocked during activation firing.
 void addEventListener(AgendaEventListener listener)
          Add an event listener.
 void addEventListener(org.drools.event.process.ProcessEventListener listener)
           
 void addEventListener(RuleBaseEventListener listener)
          Add an event listener.
 void addEventListener(WorkingMemoryEventListener listener)
          Add an event listener.
 void addLIANodePropagation(LIANodePropagation liaNodePropagation)
           
 void clearActivationGroup(String group)
          Clears the Activation Group, cancellings all its Activations
 void clearAgenda()
          Clear the Agenda.
 void clearAgendaGroup(String group)
          Clear the Agenda Group, cancelling all its Activations.
 void clearNodeMemory(NodeMemory node)
           
 void clearRuleFlowGroup(String group)
          Clears the RuleFlow group, cancelling all its Activations
 org.drools.runtime.process.ProcessInstance createProcessInstance(String processId, Map<String,Object> parameters)
           
 void dispose()
          Internal method called by the engine when the session is being disposed, so that the entry point can proceed with the necessary clean ups.
 void endBatchExecution()
           
 void endOperation()
          This method must be called after finishing any work in the engine, like inserting a new fact or firing a new rule.
 void executeQueuedActions()
           
 int fireAllRules()
          Fire all items on the agenda until empty.
 int fireAllRules(AgendaFilter agendaFilter)
          Fire all items on the agenda until empty, using the given AgendaFiler
 int fireAllRules(AgendaFilter agendaFilter, int fireLimit)
          Fire all items on the agenda using the given AgendaFiler until empty or at most 'fireLimit' rules have fired
 int fireAllRules(int fireLimit)
          Fire all items on the agenda until empty or at most 'fireLimit' rules have fired
 void fireUntilHalt()
          Keeps firing activations until a halt is called.
 void fireUntilHalt(AgendaFilter agendaFilter)
          Keeps firing activations until a halt is called.
 Queue<WorkingMemoryAction> getActionQueue()
           
 Map getActivationParameters(Activation activation)
          Helper method
 Map.Entry[] getActivationParameters(long activationId)
           
 Agenda getAgenda()
          Returns the Agenda for this WorkingMemory.
 List getAgendaEventListeners()
          Returns all event listeners.
 AgendaEventSupport getAgendaEventSupport()
           
 org.drools.runtime.Calendars getCalendars()
           
 Map<String,org.drools.runtime.Channel> getChannels()
          Returns a map of channel Id->Channel of all channels in this working memory
 DateFormats getDateFormats()
           
 String getEntryPointId()
           
 EntryPointNode getEntryPointNode()
           
 Map<String,WorkingMemoryEntryPoint> getEntryPoints()
           
 org.drools.runtime.Environment getEnvironment()
           
 ExecutionResultImpl getExecutionResult()
           
 Map<String,org.drools.runtime.ExitPoint> getExitPoints()
          Deprecated. Use getChannels() instead.
 long getFactCount()
           
 FactHandle getFactHandle(Object object)
          Retrieve the FactHandle associated with an Object.
 FactHandle getFactHandleByIdentity(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()
           
 Object getGlobal(String identifier)
          Retrieve a specific instance of global data by identifier
 GlobalResolver getGlobalResolver()
          Returns the current GlobalResolver
 int getId()
           
 long getIdleTime()
          Returns the number of time units (usually ms) that the engine is idle according to the session clock or -1 if it is not idle.
 InternalFactHandle getInitialFactHandle()
           
 InternalKnowledgeRuntime getKnowledgeRuntime()
           
 long getLastIdleTimestamp()
           
 Lock getLock()
           
 long getNextPropagationIdCounter()
           
 NodeMemories getNodeMemories()
           
 Memory getNodeMemory(NodeMemory node)
          Retrieve the JoinMemory for a particular JoinNode.
 Object getObject(org.drools.runtime.rule.FactHandle handle)
          Returns the fact Object for the given FactHandle.
 org.drools.marshalling.ObjectMarshallingStrategyStore getObjectMarshallingStrategyStore()
           
 ObjectStore getObjectStore()
           
 ObjectTypeConfigurationRegistry getObjectTypeConfigurationRegistry()
           
 PartitionTaskManager getPartitionTaskManager(RuleBasePartitionId partitionId)
          Returns the PartitionTaskManager for the given partition ID in case the rulebase has partitions enabled
 Collection<org.drools.event.process.ProcessEventListener> getProcessEventListeners()
           
 org.drools.runtime.process.ProcessInstance getProcessInstance(long processInstanceId)
          Returns the process instance with the given id.
 Collection<org.drools.runtime.process.ProcessInstance> getProcessInstances()
          Returns the list of process instances of this working memory.
 InternalProcessRuntime getProcessRuntime()
           
 long getPropagationIdCounter()
           
abstract  QueryResults getQueryResults(String query)
           
 RuleBase getRuleBase()
          Retrieve the RuleBase for this working memory.
 List getRuleBaseEventListeners()
          Returns all event listeners.
 org.drools.time.SessionClock getSessionClock()
          Returns the session clock instance associated with this session
 SessionConfiguration getSessionConfiguration()
           
 TimerService getTimerService()
          Returns the TimerService instance (session clock) for this session.
 long getTimeToNextJob()
          Returns the number of time units (usually ms) to the next scheduled job
 long getTotalFactCount()
          Returns the total number of facts in the working memory, i.e., counting all facts from all entry points.
 TruthMaintenanceSystem getTruthMaintenanceSystem()
           
 WorkingMemoryEntryPoint getWorkingMemoryEntryPoint(String name)
          Returns the interface instance for a given entry point, so that the application can manage entry-point-scoped facts.
 Collection<WorkingMemoryEntryPoint> getWorkingMemoryEntryPoints()
           
 List getWorkingMemoryEventListeners()
          Returns all event listeners.
 WorkingMemoryEventSupport getWorkingMemoryEventSupport()
           
 org.drools.runtime.process.WorkItemManager getWorkItemManager()
           
 void halt()
          Stops rule firing after the current rule finishes executing
 void insert(InternalFactHandle handle, Object object, Rule rule, Activation activation, ObjectTypeConf typeConf)
           
 FactHandle insert(Object object)
          Assert a fact.
 FactHandle insert(Object object, boolean dynamic)
          Insert a fact registering JavaBean PropertyChangeListeners on the Object to automatically trigger update calls if dynamic is true.
 FactHandle insert(Object object, boolean dynamic, boolean logical, Rule rule, Activation activation)
           
 FactHandle insertLogical(Object object)
           
 FactHandle insertLogical(Object object, boolean dynamic)
           
 boolean isPartitionManagersActive()
           
 boolean isSequential()
           
 Iterator iterateFactHandles()
          This class is not thread safe, changes to the working memory during iteration may give unexpected results
 Iterator iterateFactHandles(org.drools.runtime.ObjectFilter filter)
          This class is not thread safe, changes to the working memory during iteration may give unexpected results
 List iterateNonDefaultEntryPointObjectsToList()
           
 Iterator iterateObjects()
          This class is not thread safe, changes to the working memory during iteration may give unexpected results
 Iterator iterateObjects(org.drools.runtime.ObjectFilter filter)
          This class is not thread safe, changes to the working memory during iteration may give unexpected results
 List iterateObjectsToList()
           
 void prepareToFireActivation()
          This method is called by the agenda before firing a new activation to ensure the working memory is in a safe state to fire the activation.
 void queueWorkingMemoryAction(WorkingMemoryAction action)
           
 void registerChannel(String name, org.drools.runtime.Channel channel)
           
 void registerExitPoint(String name, org.drools.runtime.ExitPoint exitPoint)
          Deprecated. Use registerChannel(String, Channel) instead.
 void removeEventListener(AgendaEventListener listener)
          Remove an event listener.
 void removeEventListener(org.drools.event.process.ProcessEventListener listener)
           
 void removeEventListener(RuleBaseEventListener listener)
          Remove an event listener.
 void removeEventListener(WorkingMemoryEventListener listener)
          Remove an event listener.
 void reset()
           
 void reset(int handleId, long handleCounter, long propagationCounter)
           
 void retract(org.drools.runtime.rule.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 setEndOperationListener(EndOperationListener listener)
           
 void setFocus(String focus)
          Set the focus to the specified AgendaGroup
 void setGlobal(String identifier, 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(int id)
           
 void setInitialFactHandle(InternalFactHandle initialFactHandle)
           
 void setKnowledgeRuntime(InternalKnowledgeRuntime kruntime)
           
 void setWorkingMemoryEventSupport(WorkingMemoryEventSupport workingMemoryEventSupport)
           
 void startBatchExecution(ExecutionResultImpl results)
           
 void startOperation()
          This method must be called before starting any new work in the engine, like inserting a new fact or firing a new rule.
 void startPartitionManagers()
          This method is called to start the multiple partition threads when running in multi-thread mode
 org.drools.runtime.process.ProcessInstance startProcess(String processId)
          Starts a new process instance for the process with the given id.
 org.drools.runtime.process.ProcessInstance startProcess(String processId, Map<String,Object> parameters)
          Starts a new process instance for the process with the given id.
 org.drools.runtime.process.ProcessInstance startProcessInstance(long processInstanceId)
           
 void stopPartitionManagers()
           
 void unregisterChannel(String name)
           
 void unregisterExitPoint(String name)
          Deprecated. Use unregisterChannel(String) instead.
 void update(org.drools.runtime.rule.FactHandle handle, Object object)
          Inform the WorkingMemory that a Fact has been modified and that it should now update the network.
 void update(org.drools.runtime.rule.FactHandle factHandle, Object object, Rule rule, Activation activation)
           
 void update(FactHandle factHandle, Object object, Rule rule, Activation activation)
          modify is implemented as half way retract / assert due to the truth maintenance issues.
 void updateEntryPointsCache()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.drools.common.InternalWorkingMemory
getEntryPoint
 
Methods inherited from interface org.drools.WorkingMemory
getQueryResults
 
Methods inherited from interface org.drools.runtime.rule.WorkingMemoryEntryPoint
getFactHandles, getFactHandles, getObjects, getObjects
 
Methods inherited from interface org.drools.common.InternalWorkingMemoryEntryPoint
getEntryPoint, getInternalWorkingMemory
 

Field Detail

id

protected int id

defaultEntryPoint

protected NamedEntryPoint defaultEntryPoint

globalResolver

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


calendars

protected org.drools.runtime.Calendars calendars

dateFormats

protected DateFormats dateFormats

workingMemoryEventSupport

protected WorkingMemoryEventSupport workingMemoryEventSupport
The eventSupport


agendaEventSupport

protected AgendaEventSupport agendaEventSupport

__ruleBaseEventListeners

protected List __ruleBaseEventListeners

ruleBase

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


handleFactory

protected FactHandleFactory handleFactory

agenda

protected InternalAgenda agenda
Rule-firing agenda.


evaluatingActionQueue

protected AtomicBoolean evaluatingActionQueue

lock

protected ReentrantLock lock

discardOnLogicalOverride

protected boolean discardOnLogicalOverride

propagationIdCounter

protected AtomicLong propagationIdCounter
This must be thread safe as it is incremented and read via different EntryPoints


firing

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


entryPoints

protected Map<String,WorkingMemoryEntryPoint> entryPoints

initialFactHandle

protected InternalFactHandle initialFactHandle

config

protected SessionConfiguration config

partitionManager

protected PartitionManager partitionManager

threadPool

protected transient AtomicReference<ExternalExecutorService> threadPool
Constructor Detail

AbstractWorkingMemory

public AbstractWorkingMemory()

AbstractWorkingMemory

public AbstractWorkingMemory(int id,
                             InternalRuleBase ruleBase,
                             FactHandleFactory handleFactory,
                             SessionConfiguration config,
                             org.drools.runtime.Environment environment)
Construct.

Parameters:
ruleBase - The backing rule-base.

AbstractWorkingMemory

public AbstractWorkingMemory(int id,
                             InternalRuleBase ruleBase,
                             FactHandleFactory handleFactory,
                             SessionConfiguration config,
                             org.drools.runtime.Environment environment,
                             WorkingMemoryEventSupport workingMemoryEventSupport,
                             AgendaEventSupport agendaEventSupport)

AbstractWorkingMemory

public AbstractWorkingMemory(int id,
                             InternalRuleBase ruleBase,
                             FactHandleFactory handleFactory,
                             InternalFactHandle initialFactHandle,
                             long propagationContext,
                             SessionConfiguration config,
                             org.drools.runtime.Environment environment)

AbstractWorkingMemory

public AbstractWorkingMemory(int id,
                             InternalRuleBase ruleBase,
                             FactHandleFactory handleFactory,
                             InternalFactHandle initialFactHandle,
                             long propagationContext,
                             SessionConfiguration config,
                             org.drools.runtime.Environment environment,
                             WorkingMemoryEventSupport workingMemoryEventSupport,
                             AgendaEventSupport agendaEventSupport)
Method Detail

getEntryPointId

public String getEntryPointId()
Specified by:
getEntryPointId in interface org.drools.runtime.rule.WorkingMemoryEntryPoint

updateEntryPointsCache

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

startPartitionManagers

public void startPartitionManagers()
This method is called to start the multiple partition threads when running in multi-thread mode


stopPartitionManagers

public void stopPartitionManagers()

isPartitionManagersActive

public boolean isPartitionManagersActive()

getSessionConfiguration

public SessionConfiguration getSessionConfiguration()
Specified by:
getSessionConfiguration in interface InternalWorkingMemory

reset

public void reset()
Specified by:
reset in interface InternalWorkingMemoryEntryPoint

reset

public void reset(int handleId,
                  long handleCounter,
                  long propagationCounter)

setWorkingMemoryEventSupport

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

setAgendaEventSupport

public void setAgendaEventSupport(AgendaEventSupport agendaEventSupport)
Specified by:
setAgendaEventSupport 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 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 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(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 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.

addEventListener

public void addEventListener(org.drools.event.process.ProcessEventListener listener)
Specified by:
addEventListener in interface org.drools.event.process.ProcessEventManager

getProcessEventListeners

public Collection<org.drools.event.process.ProcessEventListener> getProcessEventListeners()
Specified by:
getProcessEventListeners in interface org.drools.event.process.ProcessEventManager

removeEventListener

public void removeEventListener(org.drools.event.process.ProcessEventListener listener)
Specified by:
removeEventListener in interface org.drools.event.process.ProcessEventManager

getFactHandleFactory

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

setGlobal

public void setGlobal(String identifier,
                      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:

getCalendars

public org.drools.runtime.Calendars getCalendars()
Specified by:
getCalendars in interface InternalWorkingMemory

getDateFormats

public DateFormats getDateFormats()
Specified by:
getDateFormats in interface InternalWorkingMemory

getId

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

setId

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

getGlobal

public Object getGlobal(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

getEnvironment

public org.drools.runtime.Environment getEnvironment()
Specified by:
getEnvironment in interface WorkingMemory

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(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(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(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 InternalWorkingMemoryEntryPoint
Specified by:
getRuleBase in interface WorkingMemory
Returns:
The RuleBase.

halt

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

Specified by:
halt in interface WorkingMemory

fireAllRules

public int 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 int 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 int 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 int 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.

fireUntilHalt

public void fireUntilHalt()
Keeps firing activations until a halt is called. If in a given moment, there is no activation to fire, it will wait for an activation to be added to an active agenda group or rule flow group.

Throws:
IllegalStateException - if this method is called when running in sequential mode

fireUntilHalt

public void fireUntilHalt(AgendaFilter agendaFilter)
Keeps firing activations until a halt is called. If in a given moment, there is no activation to fire, it will wait for an activation to be added to an active agenda group or rule flow group.

Parameters:
agendaFilter - filters the activations that may fire
Throws:
IllegalStateException - if this method is called when running in sequential mode

getObject

public Object getObject(org.drools.runtime.rule.FactHandle handle)
Returns the fact Object for the given FactHandle. It actually attempts to return the value from the handle, before retrieving it from objects map.

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

getObjectStore

public ObjectStore getObjectStore()
Specified by:
getObjectStore in interface InternalWorkingMemory
Specified by:
getObjectStore in interface InternalWorkingMemoryEntryPoint

getFactHandle

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

Specified by:
getFactHandle in interface org.drools.runtime.rule.WorkingMemoryEntryPoint
Specified by:
getFactHandle in interface WorkingMemory
Parameters:
object - The object.
Returns:
The associated fact handle.
See Also:
WorkingMemory

getFactHandleByIdentity

public FactHandle getFactHandleByIdentity(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
Specified by:
getFactHandleByIdentity in interface InternalWorkingMemoryEntryPoint
Specified by:
getFactHandleByIdentity in interface WorkingMemory
Returns:
null if fact handle not found
See Also:
WorkingMemory

iterateObjects

public 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 Iterator iterateObjects(org.drools.runtime.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 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 Iterator iterateFactHandles(org.drools.runtime.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(String query)

setFocus

public void setFocus(String 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(Object object)
                  throws FactException
Description copied from interface: WorkingMemoryEntryPoint
Assert a fact.

Specified by:
insert in interface org.drools.runtime.rule.WorkingMemoryEntryPoint
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(Object object)
                         throws FactException
Throws:
FactException
See Also:
WorkingMemory

insert

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

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(Object object,
                                boolean dynamic)
                         throws FactException
Specified by:
insertLogical in interface InternalWorkingMemoryActions
Throws:
FactException

insert

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

insert

public void insert(InternalFactHandle handle,
                   Object object,
                   Rule rule,
                   Activation activation,
                   ObjectTypeConf typeConf)
Specified by:
insert in interface InternalWorkingMemory

retract

public void retract(org.drools.runtime.rule.FactHandle handle)
             throws FactException
Description copied from interface: WorkingMemoryEntryPoint
Retract a fact.

Specified by:
retract in interface org.drools.runtime.rule.WorkingMemoryEntryPoint
Parameters:
handle - The fact-handle associated with the fact to retract.
Throws:
FactException - If a RuntimeException error occurs.

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
Specified by:
retract in interface InternalWorkingMemoryEntryPoint
Throws:
FactException

getEntryPointNode

public EntryPointNode getEntryPointNode()
Specified by:
getEntryPointNode in interface InternalWorkingMemory
Specified by:
getEntryPointNode in interface InternalWorkingMemoryEntryPoint

update

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

Specified by:
update in interface org.drools.runtime.rule.WorkingMemoryEntryPoint
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(org.drools.runtime.rule.FactHandle factHandle,
                   Object object,
                   Rule rule,
                   Activation activation)
            throws FactException
Specified by:
update in interface InternalWorkingMemoryEntryPoint
Throws:
FactException

update

public void update(FactHandle factHandle,
                   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

getActionQueue

public Queue<WorkingMemoryAction> getActionQueue()

queueWorkingMemoryAction

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

getNodeMemory

public Memory 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

getNodeMemories

public NodeMemories getNodeMemories()
Specified by:
getNodeMemories in interface InternalWorkingMemory

getWorkingMemoryEventSupport

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

getAgendaEventSupport

public AgendaEventSupport getAgendaEventSupport()
Specified by:
getAgendaEventSupport 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 -

getNextPropagationIdCounter

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

getPropagationIdCounter

public long getPropagationIdCounter()

getLock

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

getProcessRuntime

public InternalProcessRuntime getProcessRuntime()
Specified by:
getProcessRuntime in interface InternalWorkingMemory

startProcess

public org.drools.runtime.process.ProcessInstance startProcess(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

startProcess

public org.drools.runtime.process.ProcessInstance startProcess(String processId,
                                                               Map<String,Object> parameters)
Description copied from interface: WorkingMemory
Starts a new process instance for the process with the given id.

Specified by:
startProcess in interface WorkingMemory

createProcessInstance

public org.drools.runtime.process.ProcessInstance createProcessInstance(String processId,
                                                                        Map<String,Object> parameters)

startProcessInstance

public org.drools.runtime.process.ProcessInstance startProcessInstance(long processInstanceId)

getProcessInstances

public Collection<org.drools.runtime.process.ProcessInstance> getProcessInstances()
Description copied from interface: WorkingMemory
Returns the list of process instances of this working memory. This list is unmodifiable.

Specified by:
getProcessInstances in interface WorkingMemory
Returns:
the list of process instances

getProcessInstance

public org.drools.runtime.process.ProcessInstance getProcessInstance(long processInstanceId)
Description copied from interface: WorkingMemory
Returns the process instance with the given id.

Specified by:
getProcessInstance in interface WorkingMemory
Returns:
the process instance with the given id

getWorkItemManager

public org.drools.runtime.process.WorkItemManager getWorkItemManager()
Specified by:
getWorkItemManager in interface WorkingMemory

iterateObjectsToList

public List iterateObjectsToList()

iterateNonDefaultEntryPointObjectsToList

public List iterateNonDefaultEntryPointObjectsToList()

getActivationParameters

public Map.Entry[] getActivationParameters(long activationId)

getActivationParameters

public Map getActivationParameters(Activation activation)
Helper method


getWorkingMemoryEntryPoint

public WorkingMemoryEntryPoint getWorkingMemoryEntryPoint(String name)
Description copied from interface: WorkingMemory
Returns the interface instance for a given entry point, so that the application can manage entry-point-scoped facts.

Specified by:
getWorkingMemoryEntryPoint in interface WorkingMemory
Parameters:
name - the id of the entry point, as defined in the rules file

getWorkingMemoryEntryPoints

public Collection<WorkingMemoryEntryPoint> getWorkingMemoryEntryPoints()

getObjectTypeConfigurationRegistry

public ObjectTypeConfigurationRegistry getObjectTypeConfigurationRegistry()
Specified by:
getObjectTypeConfigurationRegistry in interface InternalWorkingMemory
Specified by:
getObjectTypeConfigurationRegistry in interface InternalWorkingMemoryEntryPoint

getInitialFactHandle

public InternalFactHandle getInitialFactHandle()
Specified by:
getInitialFactHandle in interface InternalWorkingMemory

setInitialFactHandle

public void setInitialFactHandle(InternalFactHandle initialFactHandle)

getTimerService

public TimerService getTimerService()
Description copied from interface: InternalWorkingMemory
Returns the TimerService instance (session clock) for this session.

Specified by:
getTimerService in interface InternalWorkingMemory
Returns:

getSessionClock

public org.drools.time.SessionClock getSessionClock()
Description copied from interface: WorkingMemory
Returns the session clock instance associated with this session

Specified by:
getSessionClock in interface WorkingMemory
Returns:

getPartitionTaskManager

public PartitionTaskManager getPartitionTaskManager(RuleBasePartitionId partitionId)
Description copied from interface: InternalWorkingMemory
Returns the PartitionTaskManager for the given partition ID in case the rulebase has partitions enabled

Specified by:
getPartitionTaskManager in interface InternalWorkingMemory
Parameters:
partitionId - the ID of the partition for which the task manager is assigned
Returns:
the PartitionTaskManager

startBatchExecution

public void startBatchExecution(ExecutionResultImpl results)
Specified by:
startBatchExecution in interface InternalWorkingMemory

getExecutionResult

public ExecutionResultImpl getExecutionResult()
Specified by:
getExecutionResult in interface InternalWorkingMemory

endBatchExecution

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

dispose

public void dispose()
Description copied from interface: WorkingMemoryEntryPoint
Internal method called by the engine when the session is being disposed, so that the entry point can proceed with the necessary clean ups.


setKnowledgeRuntime

public void setKnowledgeRuntime(InternalKnowledgeRuntime kruntime)
Specified by:
setKnowledgeRuntime in interface InternalWorkingMemory

getKnowledgeRuntime

public InternalKnowledgeRuntime getKnowledgeRuntime()
Specified by:
getKnowledgeRuntime in interface InternalWorkingMemory

registerExitPoint

@Deprecated
public void registerExitPoint(String name,
                                         org.drools.runtime.ExitPoint exitPoint)
Deprecated. Use registerChannel(String, Channel) instead.


unregisterExitPoint

@Deprecated
public void unregisterExitPoint(String name)
Deprecated. Use unregisterChannel(String) instead.


getExitPoints

@Deprecated
public Map<String,org.drools.runtime.ExitPoint> getExitPoints()
Deprecated. Use getChannels() instead.

Specified by:
getExitPoints in interface InternalWorkingMemory

registerChannel

public void registerChannel(String name,
                            org.drools.runtime.Channel channel)

unregisterChannel

public void unregisterChannel(String name)

getChannels

public Map<String,org.drools.runtime.Channel> getChannels()
Description copied from interface: InternalWorkingMemory
Returns a map of channel Id->Channel of all channels in this working memory

Specified by:
getChannels in interface InternalWorkingMemory
Returns:

getEntryPoints

public Map<String,WorkingMemoryEntryPoint> getEntryPoints()
Specified by:
getEntryPoints in interface InternalWorkingMemory

getFactCount

public long getFactCount()
Specified by:
getFactCount in interface org.drools.runtime.rule.WorkingMemoryEntryPoint

getTotalFactCount

public long getTotalFactCount()
Description copied from interface: InternalWorkingMemory
Returns the total number of facts in the working memory, i.e., counting all facts from all entry points. This is an approximate value and may not be accurate due to the concurrent nature of the entry points.

Specified by:
getTotalFactCount in interface InternalWorkingMemory
Returns:

startOperation

public void startOperation()
This method must be called before starting any new work in the engine, like inserting a new fact or firing a new rule. It will reset the engine idle time counter. This method must be extremely light to avoid contentions when called by multiple threads/entry-points

Specified by:
startOperation in interface InternalWorkingMemory

setEndOperationListener

public void setEndOperationListener(EndOperationListener listener)

endOperation

public void endOperation()
This method must be called after finishing any work in the engine, like inserting a new fact or firing a new rule. It will reset the engine idle time counter. This method must be extremely light to avoid contentions when called by multiple threads/entry-points

Specified by:
endOperation in interface InternalWorkingMemory

getIdleTime

public long getIdleTime()
Returns the number of time units (usually ms) that the engine is idle according to the session clock or -1 if it is not idle. This method is not synchronised and might return an approximate value.

Specified by:
getIdleTime in interface InternalWorkingMemory
Returns:

getLastIdleTimestamp

public long getLastIdleTimestamp()

getTimeToNextJob

public long getTimeToNextJob()
Returns the number of time units (usually ms) to the next scheduled job

Specified by:
getTimeToNextJob in interface InternalWorkingMemory
Returns:
the number of time units until the next scheduled job or -1 if there is no job scheduled

prepareToFireActivation

public void prepareToFireActivation()
Description copied from interface: InternalWorkingMemory
This method is called by the agenda before firing a new activation to ensure the working memory is in a safe state to fire the activation.

Specified by:
prepareToFireActivation in interface InternalWorkingMemory

activationFired

public void activationFired()
Description copied from interface: InternalWorkingMemory
This method is called by the agenda right after an activation was fired to allow the working memory to resume any activities blocked during activation firing.

Specified by:
activationFired in interface InternalWorkingMemory

getObjectMarshallingStrategyStore

public org.drools.marshalling.ObjectMarshallingStrategyStore getObjectMarshallingStrategyStore()


Copyright © 2001-2012 JBoss by Red Hat. All Rights Reserved.