org.drools.jsr94.rules
Class StatefulRuleSessionImpl

java.lang.Object
  |
  +--org.drools.jsr94.rules.RuleSessionImpl
        |
        +--org.drools.jsr94.rules.StatefulRuleSessionImpl
All Implemented Interfaces:
javax.rules.RuleSession, java.io.Serializable, javax.rules.StatefulRuleSession

public class StatefulRuleSessionImpl
extends org.drools.jsr94.rules.RuleSessionImpl
implements javax.rules.StatefulRuleSession

This interface 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 working memory of the associated rules engine. Additionally, objects currently in the working memory may be updated, and the working memory itself can be iterated.

Author:
thomas diesler
See Also:
StatefulRuleSession, Serialized Form

Method Summary
 javax.rules.Handle addObject(java.lang.Object object)
          Adds a given object to the working memory of this rule session.
 java.util.List addObjects(java.util.List list)
          Adds a List of Objects to the working memory of this rule session.
 boolean containsObject(javax.rules.Handle handle)
          Returns true if the given object is contained within the working memory of this rule session.
 void executeRules()
          Executes the rules in the bound rule execution set using the objects present in working memory until no rule is executable anymore.
 java.lang.Object getObject(javax.rules.Handle handle)
          Returns the Object within the StatefulRuleSession associated with a Handle.
 java.util.List getObjects()
          Returns a List of all objects in the working memory of this rule session that pass the default RuleExecutionSet filter (if present).
 java.util.List getObjects(javax.rules.ObjectFilter objectFilter)
          Returns a List over the objects in the working memory of this rule session based upon a given object filter.
 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.
 void release()
          Releases all resources used by this rule session.
 void removeObject(javax.rules.Handle handle)
          Removes a given object from the working memory of this rule session.
 void reset()
          Resets this rule session.
 void updateObject(javax.rules.Handle handle, java.lang.Object object)
          Notifies the rules engine that a given object in working memory 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, getType
 

Method Detail

containsObject

public boolean containsObject(javax.rules.Handle handle)
Returns true if the given object is contained within the working memory of this rule session.
Specified by:
containsObject in interface javax.rules.StatefulRuleSession
See Also:
containsObject(javax.rules.Handle)

addObject

public javax.rules.Handle addObject(java.lang.Object object)
                             throws javax.rules.InvalidRuleSessionException
Adds a given object to the working memory of this rule session. The argument to this method is Object because in the non-managed env. not all objects should have to implement Serialzable. If the RuleSession is Serializable and it contains non-serializable fields a runtime exception will be thrown.
Specified by:
addObject in interface javax.rules.StatefulRuleSession
See Also:
addObject(java.lang.Object)

addObjects

public java.util.List addObjects(java.util.List list)
                          throws javax.rules.InvalidRuleSessionException
Adds a List of Objects to the working memory of this rule session.
Specified by:
addObjects in interface javax.rules.StatefulRuleSession
See Also:
addObjects(java.util.List)

updateObject

public void updateObject(javax.rules.Handle handle,
                         java.lang.Object object)
                  throws javax.rules.InvalidRuleSessionException
Notifies the rules engine that a given object in working memory has changed. The semantics of this call are equivalent to calling removeObjectForHandle followed by addObject. The original Handle is rebound to the new value for the Object however.
Specified by:
updateObject in interface javax.rules.StatefulRuleSession
See Also:
updateObject(javax.rules.Handle, java.lang.Object)

removeObject

public void removeObject(javax.rules.Handle handle)
                  throws javax.rules.InvalidRuleSessionException
Removes a given object from the working memory of this rule session.
Specified by:
removeObject in interface javax.rules.StatefulRuleSession
See Also:
removeObject(javax.rules.Handle)

getObjects

public java.util.List getObjects()
Returns a List of all objects in the working memory of this rule session that pass the default RuleExecutionSet filter (if present).
Specified by:
getObjects in interface javax.rules.StatefulRuleSession
See Also:
getObjects()

getObjects

public java.util.List getObjects(javax.rules.ObjectFilter objectFilter)
Returns a List over the objects in the working memory of this rule session based upon a given object filter.
Specified by:
getObjects in interface javax.rules.StatefulRuleSession
See Also:
getObjects(ObjectFilter)

executeRules

public void executeRules()
                  throws javax.rules.InvalidRuleSessionException
Executes the rules in the bound rule execution set using the objects present in working memory until no rule is executable anymore.
Specified by:
executeRules in interface javax.rules.StatefulRuleSession
See Also:
executeRules()

reset

public void reset()
Resets this rule session. Calling this method will remove all objects from the working memory of this rule session and will reset any other state associated with this rule session.
Specified by:
reset in interface javax.rules.StatefulRuleSession
See Also:
reset()

getObject

public java.lang.Object getObject(javax.rules.Handle handle)
Returns the Object within the StatefulRuleSession associated with a Handle.
Specified by:
getObject in interface javax.rules.StatefulRuleSession
See Also:
getObject(javax.rules.Handle)

release

public void release()
Releases all resources used by this rule session. This method renders this rule session unusable until it is reacquired through the RuleRuntime.
Specified by:
release in interface javax.rules.RuleSession
Overrides:
release in class org.drools.jsr94.rules.RuleSessionImpl

getRuleExecutionSetMetadata

public javax.rules.RuleExecutionSetMetadata getRuleExecutionSetMetadata()
Returns the meta data for the rule execution set bound to this rule session.
Specified by:
getRuleExecutionSetMetadata in interface javax.rules.RuleSession

getType

public int getType()
            throws javax.rules.InvalidRuleSessionException
Returns the type identifier for this RuleSession. The type identifiers are defined in the RuleRuntime interface.
Specified by:
getType in interface javax.rules.RuleSession


Copyright © 2001-2003 The Werken Company. All Rights Reserved.