|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.drools.jsr94.rules.AbstractRuleSessionImpl
org.drools.jsr94.rules.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
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.
StatefulRuleSession
,
Serialized Form
![]() |
![]() |
![]() |
![]() |
Method Summary | |
javax.rules.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 Object s to the rule session
state of this rule session. |
protected void |
applyFilter(java.util.List objects,
javax.rules.ObjectFilter objectFilter)
Applies the given ObjectFilter to the List of
Object s, removing all Object s 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(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. |
java.util.List |
getHandles()
Returns a List of the Handle s
being used for object identity. |
java.lang.Object |
getObject(javax.rules.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(javax.rules.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 . |
javax.rules.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(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(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(javax.rules.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 |
Methods inherited from interface javax.rules.StatefulRuleSession |
reset |
Methods inherited from interface javax.rules.RuleSession |
getRuleExecutionSetMetadata, getType, release |
Method Detail |
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.StatefulRuleSession
objectHandle
- 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(java.lang.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.StatefulRuleSession
javax.rules.InvalidRuleSessionException
- on illegal rule session state.object
- the object to be added.
public java.util.List addObjects(java.util.List objList) throws javax.rules.InvalidRuleSessionException
List
of Object
s to the rule session
state of this rule session.
addObjects
in interface javax.rules.StatefulRuleSession
javax.rules.InvalidRuleSessionException
- on illegal rule session state.objList
- the objects to be added.
List
of Handle
s, one for each added
Object
. The List
must be ordered in
the same order as the input objList
.public void updateObject(javax.rules.Handle objectHandle, java.lang.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.StatefulRuleSession
javax.rules.InvalidRuleSessionException
- on illegal rule session state.
javax.rules.InvalidHandleException
- if the input Handle
is no longer validobjectHandle
- the handle to the original object.newObject
- the new object to bind to the handle.public void removeObject(javax.rules.Handle handleObject) throws javax.rules.InvalidRuleSessionException, javax.rules.InvalidHandleException
removeObject
in interface javax.rules.StatefulRuleSession
javax.rules.InvalidRuleSessionException
- on illegal rule session state.
javax.rules.InvalidHandleException
- if the input Handle
is no longer validhandleObject
- the handle to the object to be removed
from the rule session state.public java.util.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 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.
getObjects
in interface javax.rules.StatefulRuleSession
javax.rules.InvalidRuleSessionException
- on illegal rule session state.
List
of all objects part of the rule session state.public java.util.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 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.
getObjects
in interface javax.rules.StatefulRuleSession
javax.rules.InvalidRuleSessionException
- on illegal rule session state.filter
- the object filter.
List
of all the objects in the rule session state
of this rule session based upon the given object filter.public void executeRules() throws javax.rules.InvalidRuleSessionException
Object
s bound
to Handle
s.
executeRules
in interface javax.rules.StatefulRuleSession
javax.rules.InvalidRuleSessionException
- on illegal rule session state.public java.lang.Object getObject(javax.rules.Handle handle) throws javax.rules.InvalidRuleSessionException, javax.rules.InvalidHandleException
getObject
in interface javax.rules.StatefulRuleSession
javax.rules.InvalidRuleSessionException
javax.rules.InvalidHandleException
StatefulRuleSessionImpl
public java.util.List getHandles()
List
of the Handle
s
being used for object identity.
getHandles
in interface javax.rules.StatefulRuleSession
List
of Handle
s present
in the currect state of the rule session.protected void initWorkingMemory()
RuleSession
with a new WorkingMemory
.
AbstractRuleSessionImpl.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
.AbstractRuleSessionImpl.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 javax.rules.InvalidRuleSessionException
RuleSession
is not
in an illegal rule session state.
javax.rules.InvalidRuleSessionException
- on illegal rule session state.protected void applyFilter(java.util.List objects, javax.rules.ObjectFilter objectFilter)
ObjectFilter
to the List
of
Object
s, removing all Object
s from the given
List
that do not pass the filter.
objects
- List
of Object
s to be filteredobjectFilter
- the ObjectFilter
to be appliedpublic javax.rules.RuleExecutionSetMetadata getRuleExecutionSetMetadata()
getRuleExecutionSetMetadata
in interface javax.rules.RuleSession
public int getType() throws javax.rules.InvalidRuleSessionException
RuleSession
. The
type identifiers are defined in the RuleRuntime
interface.
getType
in interface javax.rules.RuleSession
javax.rules.InvalidRuleSessionException
- on illegal rule session state.
RuleSession
RuleRuntime.STATEFUL_SESSION_TYPE
,
RuleRuntime.STATELESS_SESSION_TYPE
public void release()
RuleRuntime
.
release
in interface javax.rules.RuleSession
public void reset()
RuleExecutionSet
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |