|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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 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 FormMethod Summary | |
---|---|
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 Object s 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 Handle s 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(boolean keepReference)
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.rules.RuleSession |
---|
getRuleExecutionSetMetadata |
Method Detail |
---|
protected void initSession(boolean keepReference)
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.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(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
object
- the object to be added.
javax.rules.InvalidRuleSessionException
- on illegal rule session state.public List addObjects(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
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
.
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.StatefulRuleSession
objectHandle
- 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.StatefulRuleSession
handleObject
- 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
Object
s
bound to Handle
s.
executeRules
in interface javax.rules.StatefulRuleSession
javax.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.StatefulRuleSession
javax.rules.InvalidRuleSessionException
javax.rules.InvalidHandleException
StatefulRuleSessionImpl
public 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.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 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
List
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 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
filter
- 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.StatefulRuleSession
public int getType() throws javax.rules.InvalidRuleSessionException
getType
in interface javax.rules.RuleSession
javax.rules.InvalidRuleSessionException
public void release()
RuleRuntime
.
release
in interface javax.rules.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 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.RuleSession
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |