javax.rules
Interface StatefulRuleSession

All Superinterfaces:
RuleSession, java.io.Serializable

public interface StatefulRuleSession
extends RuleSession, java.io.Serializable

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 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.

See Also:
RuleSession, RuleRuntime, RuleExecutionSet, Rule

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.
 boolean containsObject(Handle objectHandle)
          Returns true if the given object is contained within rule session 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)
          Returns the Object within the StatefulRuleSession associated with a 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.
 void removeObject(Handle handleObject)
          Removes a given object from the rule session state of this rule session.
 void reset()
          Resets this rule session.
 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 interface javax.rules.RuleSession
getRuleExecutionSetMetadata, getType, release
 

Method Detail

containsObject

public boolean containsObject(Handle objectHandle)
                       throws java.rmi.RemoteException,
                              InvalidRuleSessionException,
                              InvalidHandleException
Returns true if the given object is contained within rule session state of this rule session.

Parameters:
objectHandle - the handle to the target object.
Returns:
true if the given object is contained within the rule session state of this rule session.
Throws:
InvalidRuleSessionException - on illegal rule session state.
java.rmi.RemoteException
InvalidHandleException

addObject

public Handle addObject(java.lang.Object object)
                 throws java.rmi.RemoteException,
                        InvalidRuleSessionException
Adds a given object to the rule session state of this rule session. The argument to this method is Object because in the non-managed env. not all objects should have to implement Serializable. If the RuleSession is Serializable and it contains non-serializable fields a runtime exception will be thrown.

Parameters:
object - the object to be added.
Returns:
the Handle for the newly added Object
Throws:
InvalidRuleSessionException - on illegal rule session state.
java.rmi.RemoteException

addObjects

public java.util.List addObjects(java.util.List objList)
                          throws java.rmi.RemoteException,
                                 InvalidRuleSessionException
Adds a List of Objects to the rule session state of this rule session.

Parameters:
objList - the objects to be added.
Returns:
a List of Handles, one for each added Object. The List must be ordered in the same order as the input objList.
Throws:
InvalidRuleSessionException - on illegal rule session state.
java.rmi.RemoteException

updateObject

public void updateObject(Handle objectHandle,
                         java.lang.Object newObject)
                  throws java.rmi.RemoteException,
                         InvalidRuleSessionException,
                         InvalidHandleException
Notifies the rules engine that a given object in the rule session state has changed.
The semantics of this call are equivalent to calling removeObject followed by addObject. The original Handle is rebound to the new value for the Object however.

Parameters:
objectHandle - the handle to the original object.
newObject - the new object to bind to the handle.
Throws:
InvalidRuleSessionException - on illegal rule session state.
InvalidHandleException - if the input Handle is no longer valid
java.rmi.RemoteException

removeObject

public void removeObject(Handle handleObject)
                  throws java.rmi.RemoteException,
                         InvalidHandleException,
                         InvalidRuleSessionException
Removes a given object from the rule session state of this rule session.

Parameters:
handleObject - the handle to the object to be removed from the rule session state.
Throws:
InvalidRuleSessionException - on illegal rule session state.
InvalidHandleException - if the input Handle is no longer valid
java.rmi.RemoteException

getObjects

public java.util.List getObjects()
                          throws java.rmi.RemoteException,
                                 InvalidRuleSessionException
Returns a List of all objects in the rule session state of this rule session. The objects should pass the default filter test of the default 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.

Returns:
a List of all objects part of the rule session state.
Throws:
InvalidRuleSessionException - on illegal rule session state.
java.rmi.RemoteException

getHandles

public java.util.List getHandles()
                          throws java.rmi.RemoteException,
                                 InvalidRuleSessionException
Returns a List of the Handles being used for object identity.

Returns:
a List of Handles present in the currect state of the rule session.
Throws:
java.rmi.RemoteException
InvalidRuleSessionException

getObjects

public java.util.List getObjects(ObjectFilter filter)
                          throws java.rmi.RemoteException,
                                 InvalidRuleSessionException
Returns a 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.

Parameters:
filter - the object filter.
Returns:
a List of all the objects in the rule session state of this rule session based upon the given object filter.
Throws:
InvalidRuleSessionException - on illegal rule session state.
java.rmi.RemoteException

executeRules

public void executeRules()
                  throws java.rmi.RemoteException,
                         InvalidRuleSessionException
Executes the rules in the bound rule execution set using the objects present in the rule session state. This will typically modify the rule session state - and may add, remove or update Objects bound to Handles.

Throws:
InvalidRuleSessionException - on illegal rule session state.
java.rmi.RemoteException

reset

public void reset()
           throws java.rmi.RemoteException,
                  InvalidRuleSessionException
Resets this rule session. Calling this method will bring the rule session state to its initial state for this rule session and will reset any other state associated with this rule session.
A reset will not reset the state on the default object filter for a RuleExecutionSet.

Throws:
InvalidRuleSessionException - on illegal rule session state.
java.rmi.RemoteException

getObject

public java.lang.Object getObject(Handle handle)
                           throws java.rmi.RemoteException,
                                  InvalidHandleException,
                                  InvalidRuleSessionException
Returns the Object within the StatefulRuleSession associated with a Handle.

Throws:
InvalidHandleException - if the Handle is no longer valid for this StatefulRuleSession
java.rmi.RemoteException
InvalidRuleSessionException


Copyright © 2004 Java Community Process. All Rights Reserved.