|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.drools.jsr94.rules.StatefulRuleSessionImpl
public class StatefulRuleSessionImpl
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.
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| Method Summary | |
|---|---|
Handle |
addObject(java.lang.Object object)
Adds a given object to the rule session state of this rule session. |
java.util.List |
addObjects(java.util.List objList)
Adds a List of Objects to the rule session
state of this rule session. |
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. |
boolean |
containsObject(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. |
java.util.List |
getHandles()
Returns a List of the Handles being used
for object identity. |
java.lang.Object |
getObject(Handle handle)
|
java.util.List |
getObjects()
Returns a List of all objects in the rule session state of this rule session. |
java.util.List |
getObjects(ObjectFilter filter)
Returns a List over the objects in rule session state of
this rule session. |
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 |
removeObject(Handle handleObject)
Removes a given object from the rule session state of 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. |
void |
updateObject(Handle objectHandle,
java.lang.Object newObject)
Notifies the rules engine that a given object in the rule session state has changed. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public boolean containsObject(Handle objectHandle)
true if the given object is contained within
rulesession state of this rule session.
objectHandle - the handle to the target object.
true if the given object is contained within the
rule session state of this rule session.
public Handle addObject(java.lang.Object object)
throws InvalidRuleSessionException
RuleSession is Serializable and it contains
non-serializable fields a runtime exception will be thrown.
object - the object to be added.
InvalidRuleSessionException - on illegal rule session state.
public java.util.List addObjects(java.util.List objList)
throws InvalidRuleSessionException
List of Objects to the rule session
state of this rule session.
objList - 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.
InvalidRuleSessionException - on illegal rule session state.
public void updateObject(Handle objectHandle,
java.lang.Object newObject)
throws InvalidRuleSessionException,
InvalidHandleException
removeObject followed by addObject. The
original Handle is rebound to the new value for the
Object however.
objectHandle - the handle to the original object.newObject - the new object to bind to the handle.
InvalidRuleSessionException - on illegal rule session state.
InvalidHandleException - if the input Handle is no longer valid
public void removeObject(Handle handleObject)
throws InvalidRuleSessionException,
InvalidHandleException
handleObject - the handle to the object to be removed from the rule session
state.
InvalidRuleSessionException - on illegal rule session state.
InvalidHandleException - if the input Handle is no longer valid
public java.util.List getObjects()
throws 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.
List of all objects part of the rule session
state.
InvalidRuleSessionException - on illegal rule session state.
public java.util.List getObjects(ObjectFilter filter)
throws 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.
filter - the object filter.
List of all the objects in the rule session
state of this rule session based upon the given object filter.
InvalidRuleSessionException - on illegal rule session state.
public void executeRules()
throws InvalidRuleSessionException
Objects
bound to Handles.
InvalidRuleSessionException - on illegal rule session state.
public java.lang.Object getObject(Handle handle)
throws InvalidRuleSessionException,
InvalidHandleException
InvalidRuleSessionException
InvalidHandleExceptionStatefulRuleSessionImplpublic java.util.List getHandles()
List of the Handles being used
for object identity.
List of Handles present in the
currect state of the rule session.protected void initWorkingMemory()
RuleSession
with a new WorkingMemory.
newWorkingMemory()protected WorkingMemory newWorkingMemory()
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.
WorkingMemory.setProperties(Map),
WorkingMemory.setApplicationData(String, Object)protected void setProperties(java.util.Map properties)
RuleSession.
properties - additional properties used to create the
RuleSession implementation.protected java.util.Map getProperties()
RuleSession.
RuleSession.protected void setWorkingMemory(WorkingMemory workingMemory)
WorkingMemory associated
with this RuleSession.
workingMemory - the WorkingMemory to associate
with this RuleSession.protected WorkingMemory getWorkingMemory()
WorkingMemory associated
with this RuleSession.
WorkingMemory to associate
with this 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.
protected void checkRuleSessionValidity()
throws InvalidRuleSessionException
RuleSession is not
in an illegal rule session state.
InvalidRuleSessionException - on illegal rule session state.
protected void applyFilter(java.util.List objects,
ObjectFilter objectFilter)
ObjectFilter to the List of
Objects, removing all Objects from the given
List that do not pass the filter.
objects - List of Objects to be filteredobjectFilter - the ObjectFilter to be appliedpublic RuleExecutionSetMetadata getRuleExecutionSetMetadata()
public int getType()
throws InvalidRuleSessionException
RuleSession. The
type identifiers are defined in the RuleRuntime interface.
RuleSession
InvalidRuleSessionException - on illegal rule session state.RuleRuntime#STATEFUL_SESSION_TYPE,
RuleRuntime#STATELESS_SESSION_TYPEpublic void release()
RuleRuntime.
public void reset()
RuleExecutionSet.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||