| |
|
| java.lang.Object org.drools.jsr94.rules.AbstractRuleSessionImpl org.drools.jsr94.rules.StatefulRuleSessionImpl
StatefulRuleSessionImpl | public class StatefulRuleSessionImpl extends AbstractRuleSessionImpl implements StatefulRuleSession(Code) | | The Drools implementation of the StatefulRuleSession interface
which is a representation of a stateful rules engine session. A stateful
rules engine session exposes a stateful rule execution API to an underlying
rules engine. The session allows arbitrary objects to be added and removed to
and from the rule session state. Additionally, objects currently part of the
rule session state may be updated. There are inherently side-effects to
adding objects to the rule session state. The execution of a RuleExecutionSet
can add, remove and update objects in the rule session state. The objects in
the rule session state are therefore dependent on the rules within the
RuleExecutionSet as well as the rule engine vendor's specific
rule engine behavior. Handle instances are used by the
rule engine vendor to track Object s added to the rule session
state. This allows multiple instances of equivalent Object s
to be added to the session state and identified, even after serialization.
See Also: StatefulRuleSession author: N. Alex Rupp (n_alex codehaus.org) author: thomas diesler |
Method Summary | |
public Handle | addObject(Object object) Adds a given object to the rule session state of this rule session. | public List | addObjects(List objList) Adds a List of Object s to the rule session
state of this rule session.
Parameters: objList - the objects to be added. | protected void | checkRuleSessionValidity() Ensures this RuleSession is not
in an illegal rule session state. | public boolean | containsObject(Handle objectHandle) Returns true if the given object is contained within
rulesession state of this rule session.
Parameters: objectHandle - the handle to the target object. | public void | executeRules() Executes the rules in the bound rule execution set using the objects
present in the rule session state. | public List | getHandles() Returns a List of the Handle s being used
for object identity. | public Object | getObject(Handle handle) | public List | getObjects() Returns a List of all objects in the rule session state of this rule
session. | public List | getObjects(ObjectFilter filter) Returns a List over the objects in rule session state of
this rule session. | public int | getType() | protected void | initSession(boolean keepReference) Initialize this RuleSession
with a new WorkingMemory . | public void | release() Releases all resources used by this rule session. | public void | removeObject(Handle handleObject) Removes a given object from the rule session state of this rule session. | public void | reset() Resets this rule session. | public void | updateObject(Handle objectHandle, Object newObject) Notifies the rules engine that a given object in the rule session state
has changed. |
StatefulRuleSessionImpl | StatefulRuleSessionImpl(String bindUri, Map properties, RuleExecutionSetRepository repository) throws RuleExecutionSetNotFoundException(Code) | | Gets the RuleExecutionSet for this URI and associates it
with a RuleBase.
Parameters: bindUri - the URI the RuleExecutionSet has been bound to Parameters: properties - additional properties used to create theRuleSession implementation. throws: RuleExecutionSetNotFoundException - if there is no rule set under the given URI |
addObject | public Handle addObject(Object object) throws InvalidRuleSessionException(Code) | | Adds a given object to the rule session state of this rule session. The
argument to this method is Object because in the non-managed env. not all
objects should have to implement Serializable. If the
RuleSession is Serializable and it contains
non-serializable fields a runtime exception will be thrown.
Parameters: object - the object to be added. the Handle for the newly added Object throws: InvalidRuleSessionException - on illegal rule session state. |
addObjects | public List addObjects(List objList) throws InvalidRuleSessionException(Code) | | Adds a List of Object s to the rule session
state of this rule session.
Parameters: objList - the objects to be added. a List of Handle s, one for eachadded Object . The List must beordered in the same order as the input objList . throws: InvalidRuleSessionException - on illegal rule session state. |
checkRuleSessionValidity | protected void checkRuleSessionValidity() throws InvalidRuleSessionException(Code) | | Ensures this RuleSession is not
in an illegal rule session state.
throws: InvalidRuleSessionException - on illegal rule session state. |
containsObject | public boolean containsObject(Handle objectHandle)(Code) | | Returns true if the given object is contained within
rulesession state of this rule session.
Parameters: objectHandle - the handle to the target object. true if the given object is contained within therule session state of this rule session. |
executeRules | public void executeRules() throws InvalidRuleSessionException(Code) | | Executes the rules in the bound rule execution set using the objects
present in the rule session state. This will typically modify the rule
session state - and may add, remove or update Object s
bound to Handle s.
throws: InvalidRuleSessionException - on illegal rule session state. |
getHandles | public List getHandles()(Code) | | Returns a List of the Handle s being used
for object identity.
a List of Handle s present in thecurrect state of the rule session. |
getObjects | public List getObjects() throws InvalidRuleSessionException(Code) | | Returns a List of all objects in the rule session state of this rule
session. The objects should pass the default filter test of the default
RuleExecutionSet filter (if present). This may not
neccessarily include all objects added by calls to addObject ,
and may include Object s created by side-effects. The
execution of a RuleExecutionSet can add, remove and update
objects as part of the rule session state. Therefore the rule session
state is dependent on the rules that are part of the executed
RuleExecutionSet as well as the rule vendor's specific
rule engine behavior.
a List of all objects part of the rule sessionstate. throws: InvalidRuleSessionException - on illegal rule session state. |
getObjects | public List getObjects(ObjectFilter filter) throws InvalidRuleSessionException(Code) | | Returns a List over the objects in rule session state of
this rule session. The objects should pass the filter test on the
specified ObjectFilter . This may not neccessarily
include all objects added by calls to addObject , and may
include Object s created by side-effects. The execution of
a RuleExecutionSet can add, remove and update objects as
part of the rule session state. Therefore the rule session state is
dependent on the rules that are part of the executed
RuleExecutionSet as well as the rule vendor's specific
rule engine behavior.
Parameters: filter - the object filter. a List of all the objects in the rule sessionstate of this rule session based upon the given object filter. throws: InvalidRuleSessionException - on illegal rule session state. |
getType | public int getType() throws InvalidRuleSessionException(Code) | | |
initSession | protected void initSession(boolean keepReference)(Code) | | Initialize this RuleSession
with a new WorkingMemory .
|
release | public void release()(Code) | | Releases all resources used by this rule session.
This method renders this rule session unusable until
it is reacquired through the RuleRuntime .
|
removeObject | public void removeObject(Handle handleObject) throws InvalidRuleSessionException, InvalidHandleException(Code) | | Removes a given object from the rule session state of this rule session.
Parameters: handleObject - the handle to the object to be removed from the rule sessionstate. throws: InvalidRuleSessionException - on illegal rule session state. throws: InvalidHandleException - if the input Handle is no longer valid |
reset | public void reset()(Code) | | 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 .
|
updateObject | public void updateObject(Handle objectHandle, Object newObject) throws InvalidRuleSessionException, InvalidHandleException(Code) | | Notifies the rules engine that a given object in the rule session state
has changed. The semantics of this call are equivalent to calling
removeObject followed by addObject . The
original Handle is rebound to the new value for the
Object however.
Parameters: objectHandle - the handle to the original object. Parameters: newObject - the new object to bind to the handle. throws: InvalidRuleSessionException - on illegal rule session state. throws: InvalidHandleException - if the input Handle is no longer valid |
|
|
|