org.drools.jsr94.rules
Class AbstractRuleSessionImpl

java.lang.Object
  extended by org.drools.jsr94.rules.AbstractRuleSessionImpl
All Implemented Interfaces:
RuleSession
Direct Known Subclasses:
StatefulRuleSessionImpl, StatelessRuleSessionImpl

abstract class AbstractRuleSessionImpl
extends Object
implements RuleSession

The Drools implementation of the RuleSession interface which is a representation of a client session with a rules engine. A rules engine session serves as an entry point into an underlying rules engine. The RuleSession is bound to a rules engine instance and exposes a vendor-neutral rule processing API for executing Rules within a bound RuleExecutionSet.

Note: the release method must be called to clean up all resources used by the RuleSession. Calling release may make the RuleSession eligible to be returned to a RuleSession pool.

Author:
N. Alex Rupp (n_alex codehaus.org), thomas diesler
See Also:
RuleSession

Constructor Summary
AbstractRuleSessionImpl()
           
 
Method Summary
protected  void applyFilter(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.
protected  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(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
 

Constructor Detail

AbstractRuleSessionImpl

AbstractRuleSessionImpl()
Method Detail

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(Map properties)
Sets additional properties used to create this RuleSession.

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

getProperties

protected 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(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.

Specified by:
getRuleExecutionSetMetadata in interface RuleSession
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.

Specified by:
getType in interface RuleSession
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.

Specified by:
release in interface RuleSession

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.



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