org.drools.jsr94.rules
Class StatelessRuleSessionImpl

java.lang.Object
  extended by org.drools.jsr94.rules.StatelessRuleSessionImpl

public class StatelessRuleSessionImpl
extends java.lang.Object

The Drools implementation of the StatelessRuleSession interface which is a representation of a stateless rules engine session. A stateless rules engine session exposes a stateless rule execution API to an underlying rules engine.

See Also:
StatelessRuleSession

Method Summary
protected  void applyFilter(java.util.List objects, ObjectFilter objectFilter)
          Applies the given ObjectFilter to the List of Objects, removing all Objects from the given List that do not pass the filter.
protected  void checkRuleSessionValidity()
          Ensures this RuleSession is not in an illegal rule session state.
 java.util.List executeRules(java.util.List objects)
          Executes the rules in the bound rule execution set using the supplied list of objects.
 java.util.List executeRules(java.util.List objects, ObjectFilter filter)
          Executes the rules in the bound rule execution set using the supplied list of objects.
protected  java.util.Map getProperties()
          Returns the additional properties used to create this RuleSession.
protected  RuleExecutionSetImpl getRuleExecutionSet()
          Returns the Drools RuleExecutionSet associated with this RuleSession.
 RuleExecutionSetMetadata getRuleExecutionSetMetadata()
          Returns the meta data for the rule execution set bound to this rule session.
 int getType()
          Returns the type identifier for this RuleSession.
protected  WorkingMemory getWorkingMemory()
          Returns the Drools WorkingMemory associated with this RuleSession.
protected  void initWorkingMemory()
          Initialize this RuleSession with a new WorkingMemory.
protected  WorkingMemory newWorkingMemory()
          Creates a new WorkingMemory for this RuleSession.
 void release()
          Releases all resources used by this rule session.
 void reset()
          Resets this rule session.
protected  void setProperties(java.util.Map properties)
          Sets additional properties used to create this RuleSession.
protected  void setRuleExecutionSet(RuleExecutionSetImpl ruleExecutionSet)
          Sets the Drools RuleExecutionSet associated with this RuleSession.
protected  void setWorkingMemory(WorkingMemory workingMemory)
          Sets the Drools WorkingMemory associated with this RuleSession.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

executeRules

public java.util.List executeRules(java.util.List objects)
                            throws InvalidRuleSessionException
Executes the rules in the bound rule execution set using the supplied list of objects. A List is returned containing the objects created by (or passed into the rule session) the executed rules that pass the filter test of the default RuleExecutionSet ObjectFilter (if present).

The returned list may not neccessarily include all objects passed, and may include Objects created by side-effects. The execution of a RuleExecutionSet can add, remove and update objects. Therefore the returned object list is dependent on the rules that are part of the executed RuleExecutionSet as well as Drools specific rule engine behavior.

Parameters:
objects - the objects used to execute rules.
Returns:
a List containing the objects as a result of executing the rules.
Throws:
InvalidRuleSessionException - on illegal rule session state.

executeRules

public java.util.List executeRules(java.util.List objects,
                                   ObjectFilter filter)
                            throws InvalidRuleSessionException
Executes the rules in the bound rule execution set using the supplied list of objects. A List is returned containing the objects created by (or passed into the rule engine) the executed rules and filtered with the supplied object filter.

The returned list may not neccessarily include all objects passed, and may include Objects created by side-effects. The execution of a RuleExecutionSet can add, remove and update objects. Therefore the returned object list is dependent on the rules that are part of the executed RuleExecutionSet as well as Drools specific rule engine behavior.

Parameters:
objects - the objects used to execute rules.
filter - the object filter.
Returns:
a List containing the objects as a result of executing rules, after passing through the supplied object filter.
Throws:
InvalidRuleSessionException - on illegal rule session state.

initWorkingMemory

protected void initWorkingMemory()
Initialize this RuleSession with a new WorkingMemory.

See Also:
newWorkingMemory()

newWorkingMemory

protected WorkingMemory newWorkingMemory()
Creates a new WorkingMemory for this RuleSession. All properties set prior to calling this method are added as application data to the new WorkingMemory. The created WorkingMemory uses the default conflict resolution strategy.

Returns:
the new WorkingMemory.
See Also:
setProperties(Map), WorkingMemory.setApplicationData(String, Object)

setProperties

protected void setProperties(java.util.Map properties)
Sets additional properties used to create this RuleSession.

Parameters:
properties - additional properties used to create the RuleSession implementation.

getProperties

protected java.util.Map getProperties()
Returns the additional properties used to create this RuleSession.

Returns:
the additional properties used to create this RuleSession.

setWorkingMemory

protected void setWorkingMemory(WorkingMemory workingMemory)
Sets the Drools WorkingMemory associated with this RuleSession.

Parameters:
workingMemory - the WorkingMemory to associate with this RuleSession.

getWorkingMemory

protected WorkingMemory getWorkingMemory()
Returns the Drools WorkingMemory associated with this RuleSession.

Returns:
the Drools WorkingMemory to associate with this RuleSession.

setRuleExecutionSet

protected void setRuleExecutionSet(RuleExecutionSetImpl ruleExecutionSet)
Sets the Drools RuleExecutionSet associated with this RuleSession.

Parameters:
ruleExecutionSet - the Drools RuleExecutionSet to associate with this RuleSession.

getRuleExecutionSet

protected RuleExecutionSetImpl getRuleExecutionSet()
Returns the Drools RuleExecutionSet associated with this RuleSession.

Returns:
the Drools RuleExecutionSet associated with this RuleSession.

checkRuleSessionValidity

protected void checkRuleSessionValidity()
                                 throws InvalidRuleSessionException
Ensures this RuleSession is not in an illegal rule session state.

Throws:
InvalidRuleSessionException - on illegal rule session state.

applyFilter

protected void applyFilter(java.util.List objects,
                           ObjectFilter objectFilter)
Applies the given ObjectFilter to the List of Objects, removing all Objects from the given List that do not pass the filter.

Parameters:
objects - List of Objects to be filtered
objectFilter - the ObjectFilter to be applied

getRuleExecutionSetMetadata

public RuleExecutionSetMetadata getRuleExecutionSetMetadata()
Returns the meta data for the rule execution set bound to this rule session.

Returns:
the RuleExecutionSetMetaData bound to this rule session.

getType

public int getType()
            throws InvalidRuleSessionException
Returns the type identifier for this RuleSession. The type identifiers are defined in the RuleRuntime interface.

Returns:
the type identifier for this RuleSession
Throws:
InvalidRuleSessionException - on illegal rule session state.
See Also:
RuleRuntime#STATEFUL_SESSION_TYPE, RuleRuntime#STATELESS_SESSION_TYPE

release

public void release()
Releases all resources used by this rule session. This method renders this rule session unusable until it is reacquired through the RuleRuntime.


reset

public void reset()
Resets this rule session. Calling this method will bring the rule session state to its initial state for this rule session and will reset any other state associated with this rule session.

A reset will not reset the state on the default object filter for a RuleExecutionSet.