|
Rule Execution Server API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IlrStatefulSession
IlrStatefulSession
represents a stateful rule session.
A stateful session is a rule session where the server stores the engine state and provides access to the working memory.
Use stateful rule sessions for the following actions:
You must work with stateful sessions when you want to change the state of a Java SE, POJO, or EJB component - that is, to insert and update objects in the working memory or retract objects from it.
A stateless rule session can pass objects as input parameters, then add them to the working memory by using a rule task initial action. You can do the same with output parameters. The working memory content can be modified at the end of an execution.
To reset an IlrStatefulSession
instance, you must reinitialize the engine.
The following code example shows how to execute rules in a stateful session.
IlrPath rulesetPath = IlrPath.parsePath("/simplejava/simplejavaruleset"); IlrStatefulSession session = null; try { session = sessionFactory.createStatefulSession(rulesetPath, null, null, false); session.setTraceEnabled(true); session.getTraceFilter().setInfoWorkingMemory(false); session.getTraceFilter().setInfoRules(true); Mapparams = new HashMap (); params.put("param1", "Value1"); IlrSessionResponse response = session.execute(params); IlrExecutionTrace trace = response.getRulesetExecutionTrace(); } finally { if (session!=null) { session.close(); } }
Method Summary | |
---|---|
void |
close()
Closes this session. |
IlrSessionResponse |
execute()
Executes a ruleset, based on the current state of the engine and the state of the session. |
IlrSessionResponse |
execute(Map<String,Object> inputParameters)
Executes a ruleset by using the input parameters. |
IlrSessionResponse |
execute(Map<String,Object> inputParameters,
String taskName)
Executes a ruleset by using the input parameters and starting from a specific task in the ruleflow. |
IlrSessionResponse |
execute(Map<String,Object> inputParameters,
String taskName,
boolean isBOMAccess)
Executes a ruleset by using the input parameters and starting from a specific task in the ruleflow. |
String |
getOutput()
Returns the value of the IlrContext.out stream. |
Map<String,String> |
getRulesetArchiveProperties()
Retrieves the properties of the ruleset archive. |
IlrPath |
getRulesetPath()
Returns the ruleset path that was specified at construction time, that is, when this stateful session was created. |
Collection<IlrRulesetParameter> |
getRulesetSignature()
Retrieves the ruleset parameters. |
IlrTraceFilter |
getTraceFilter()
Returns the trace filter that is used to collect trace data. |
Serializable |
getUserData()
Returns the user data supplied at construction time, that is, when this stateful session was created. |
List<IlrWarning> |
getWarnings(boolean clear)
Returns the warnings that are generated by the execution unit (XU). |
List<Object> |
getWorkingMemory()
Returns all the objects in the working memory. |
Map<UUID,Object> |
getWorkingMemoryUUIDs()
Returns all the objects with UUIDs in the working memory. |
List<UUID> |
insertJavaObjects(List<Object> objects)
Inserts objects into the working memory. |
List<UUID> |
insertXMLObjects(List<String> objects)
Inserts XML objects into the working memory. |
boolean |
isInterceptorEnabled()
Tests whether the interceptors are enabled. |
boolean |
isRulesetUptodate()
Tests whether the underlying ruleset used by this session is up to date with respect to the Rule Execution Server repository. |
boolean |
isTraceEnabled()
Tests whether the trace is enabled. |
void |
reset()
Clears data from this object. |
void |
resetRuleflow()
Resets the ruleflow. |
void |
retract(List<UUID> uuids)
Removes specific objects from the working memory. |
void |
setTraceEnabled(boolean enabled)
Enables or disables the trace. |
void |
setTraceFilter(IlrTraceFilter filter)
Sets the trace filter that is used to collect trace data. |
void |
update(List<UUID> uuids)
Sends a notification when a set of objects in the working memory has been changed. |
Method Detail |
---|
IlrPath getRulesetPath()
Serializable getUserData()
boolean isInterceptorEnabled()
true
if the interceptors are enabled.boolean isRulesetUptodate() throws IlrSessionException
As soon as the execution unit (XU) is notified of a change
on the ruleset of the session, this method returns
false
. This result enables the caller to open a new session to
use the up-to-date ruleset.
IlrSessionException
- An IlrSessionException
object if an
error occurred while the session was checking whether the ruleset is up to
date.
true
if the ruleset is up to date.boolean isTraceEnabled()
true
if the trace is enabled.void setTraceEnabled(boolean enabled)
enabled
- Set to true
to enable the trace.IlrTraceFilter getTraceFilter()
void setTraceFilter(IlrTraceFilter filter)
filter
- The new trace filter.String getOutput() throws IlrSessionException
IlrContext.out
stream.
An
- IlrSessionException
object if an error occurs when the output
string is returned.
IlrSessionException
IlrContext.out
stream.IlrSessionResponse execute() throws IlrSessionException
An
- IlrSessionException
object if an error occurred during ruleset execution.
IlrSessionException
IlrSessionResponse execute(Map<String,Object> inputParameters) throws IlrSessionException
An
- IlrSessionException
object if an error occurred during ruleset execution.
IlrSessionException
inputParameters
- A map that contains the input parameters.
IlrSessionResponse execute(Map<String,Object> inputParameters, String taskName) throws IlrSessionException
An
- IlrSessionException
object if an error occurred during ruleset execution.
IlrSessionException
inputParameters
- A map that contains the input parameters.taskName
- The name of the task to execute in the ruleflow.
IlrSessionResponse execute(Map<String,Object> inputParameters, String taskName, boolean isBOMAccess) throws IlrSessionException
An
- IlrSessionException
object if an error occurred during ruleset execution.
IlrSessionException
inputParameters
- A map that contains the input parameters.taskName
- The name of the task to execute in the ruleflow.isBOMAccess
- Set to true
so that the BOM-serialized version of the
parameters is available in the execution response.
List<UUID> insertJavaObjects(List<Object> objects) throws IlrSessionException
An
- IlrSessionException
object if an error occurs when these objects are added.
IlrSessionException
objects
- A list of Object
instances to be added
to the working memory.
UUID
of the objects to
be added.List<UUID> insertXMLObjects(List<String> objects) throws IlrSessionException
An
- IlrSessionException
object if an error occurs when the XML objects are added.
IlrSessionException
objects
- A list of String
objects to be added to
the working memory.
UUID
of the XML
objects to be added.void update(List<UUID> uuids) throws IlrSessionException
An
- IlrSessionException
object if an error occurs when the object is updated.
IlrSessionException
uuids
- The UUIDs of the objects to be notified.void retract(List<UUID> uuids) throws IlrSessionException
IlrSessionException
- if an error occurs when the objects are removed.uuids
- The UUIDs of the objects to be removed.List<Object> getWorkingMemory() throws IlrSessionException
An
- IlrSessionException
object if an error occurred when the
working memory is returned.
IlrSessionException
Map<UUID,Object> getWorkingMemoryUUIDs() throws IlrSessionException
An
- IlrSessionException
object if an error occurs while the UUIDs are retrieved.
IlrSessionException
void reset() throws IlrSessionException
An
- IlrSessionException
object if an error occurs.
IlrSessionException
void resetRuleflow() throws IlrSessionException
IlrSessionException
- if an error occurs when the ruleflow is reset.List<IlrWarning> getWarnings(boolean clear)
clear
- Set to true
to check whether the warnings kept by the
session must be cleared.
IlrSessionWarning
objects. If no warnings
are emitted, this list is empty.void close()
Collection<IlrRulesetParameter> getRulesetSignature() throws IlrSessionException
IlrSessionException
Map<String,String> getRulesetArchiveProperties() throws IlrSessionException
IlrSessionException
|
Rule Execution Server API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |