public class StatefulRuleSessionImpl extends Object implements javax.rules.StatefulRuleSession
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 Objects added to the rule session
state. This allows multiple instances of equivalent Objects
to be added to the session state and identified, even after serialization.StatefulRuleSession,
Serialized Form| Modifier and Type | Method and Description |
|---|---|
javax.rules.Handle |
addObject(Object object)
Adds a given object to the rule session state of this rule session.
|
List |
addObjects(List objList)
Adds a
List of Objects to the rule session
state of this rule session. |
protected void |
checkRuleSessionValidity()
Ensures this
RuleSession is not
in an illegal rule session state. |
boolean |
containsObject(javax.rules.Handle objectHandle)
Returns
true if the given object is contained within
rulesession state of this rule session. |
void |
executeRules()
Executes the rules in the bound rule execution set using the objects
present in the rule session state.
|
List |
getHandles()
Returns a
List of the Handles being used
for object identity. |
Object |
getObject(javax.rules.Handle handle) |
List |
getObjects()
Returns a List of all objects in the rule session state of this rule
session.
|
List |
getObjects(javax.rules.ObjectFilter filter)
Returns a
List over the objects in rule session state of
this rule session. |
protected Map |
getProperties()
Returns the additional properties used to create this
RuleSession. |
protected RuleExecutionSetImpl |
getRuleExecutionSet()
Returns the Drools
RuleExecutionSet associated
with this RuleSession. |
javax.rules.RuleExecutionSetMetadata |
getRuleExecutionSetMetadata()
Returns the meta data for the rule execution set bound to this rule
session.
|
int |
getType() |
protected void |
initSession(org.drools.core.SessionConfiguration conf)
Initialize this
RuleSession
with a new WorkingMemory. |
void |
release()
Releases all resources used by this rule session.
|
void |
removeObject(javax.rules.Handle handleObject)
Removes a given object from the rule session state of 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. |
void |
updateObject(javax.rules.Handle objectHandle,
Object newObject)
Notifies the rules engine that a given object in the rule session state
has changed.
|
protected void initSession(org.drools.core.SessionConfiguration conf)
RuleSession
with a new WorkingMemory.public boolean containsObject(javax.rules.Handle objectHandle)
true if the given object is contained within
rulesession state of this rule session.containsObject in interface javax.rules.StatefulRuleSessionobjectHandle - the handle to the target object.true if the given object is contained within the
rule session state of this rule session.public javax.rules.Handle addObject(Object object) throws javax.rules.InvalidRuleSessionException
RuleSession is Serializable and it contains
non-serializable fields a runtime exception will be thrown.addObject in interface javax.rules.StatefulRuleSessionobject - the object to be added.javax.rules.InvalidRuleSessionException - on illegal rule session state.public List addObjects(List objList) throws javax.rules.InvalidRuleSessionException
List of Objects to the rule session
state of this rule session.addObjects in interface javax.rules.StatefulRuleSessionobjList - the objects to be added.List of Handles, one for each
added Object. The List must be
ordered in the same order as the input objList.javax.rules.InvalidRuleSessionException - on illegal rule session state.public void updateObject(javax.rules.Handle objectHandle,
Object newObject)
throws javax.rules.InvalidRuleSessionException,
javax.rules.InvalidHandleException
removeObject followed by addObject. The
original Handle is rebound to the new value for the
Object however.updateObject in interface javax.rules.StatefulRuleSessionobjectHandle - the handle to the original object.newObject - the new object to bind to the handle.javax.rules.InvalidRuleSessionException - on illegal rule session state.javax.rules.InvalidHandleException - if the input Handle is no longer validpublic void removeObject(javax.rules.Handle handleObject)
throws javax.rules.InvalidRuleSessionException,
javax.rules.InvalidHandleException
removeObject in interface javax.rules.StatefulRuleSessionhandleObject - the handle to the object to be removed from the rule session
state.javax.rules.InvalidRuleSessionException - on illegal rule session state.javax.rules.InvalidHandleException - if the input Handle is no longer validpublic void executeRules()
throws javax.rules.InvalidRuleSessionException
Objects
bound to Handles.executeRules in interface javax.rules.StatefulRuleSessionjavax.rules.InvalidRuleSessionException - on illegal rule session state.public Object getObject(javax.rules.Handle handle) throws javax.rules.InvalidRuleSessionException, javax.rules.InvalidHandleException
getObject in interface javax.rules.StatefulRuleSessionjavax.rules.InvalidRuleSessionExceptionjavax.rules.InvalidHandleExceptionStatefulRuleSessionImplpublic List getHandles()
List of the Handles being used
for object identity.getHandles in interface javax.rules.StatefulRuleSessionList of Handles present in the
currect state of the rule session.public List getObjects() throws javax.rules.InvalidRuleSessionException
RuleExecutionSet filter (if present). This may not
neccessarily include all objects added by calls to addObject,
and may include Objects 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.getObjects in interface javax.rules.StatefulRuleSessionList of all objects part of the rule session
state.javax.rules.InvalidRuleSessionException - on illegal rule session state.public List getObjects(javax.rules.ObjectFilter filter) throws javax.rules.InvalidRuleSessionException
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 Objects 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.getObjects in interface javax.rules.StatefulRuleSessionfilter - the object filter.List of all the objects in the rule session
state of this rule session based upon the given object filter.javax.rules.InvalidRuleSessionException - on illegal rule session state.public void reset()
RuleExecutionSet.reset in interface javax.rules.StatefulRuleSessionpublic int getType()
throws javax.rules.InvalidRuleSessionException
getType in interface javax.rules.RuleSessionjavax.rules.InvalidRuleSessionExceptionpublic void release()
RuleRuntime.release in interface javax.rules.RuleSessionprotected void checkRuleSessionValidity()
throws javax.rules.InvalidRuleSessionException
RuleSession is not
in an illegal rule session state.javax.rules.InvalidRuleSessionException - on illegal rule session state.protected void setProperties(Map properties)
RuleSession.properties - additional properties used to create the
RuleSession implementation.protected Map getProperties()
RuleSession.RuleSession.protected void setRuleExecutionSet(RuleExecutionSetImpl ruleExecutionSet)
RuleExecutionSet associated
with this RuleSession.ruleExecutionSet - the Drools RuleExecutionSet to associate
with this RuleSession.protected RuleExecutionSetImpl getRuleExecutionSet()
RuleExecutionSet associated
with this RuleSession.RuleExecutionSet associated
with this RuleSession.public javax.rules.RuleExecutionSetMetadata getRuleExecutionSetMetadata()
getRuleExecutionSetMetadata in interface javax.rules.RuleSessionCopyright © 2001–2017 JBoss by Red Hat. All rights reserved.