ilog.rules.res.session
Interface IlrSessionRequest
-
- All Superinterfaces:
- java.io.Serializable
public interface IlrSessionRequest extends java.io.Serializable
IlrSessionRequest
is the interface for session requests. This class is used to execute rulesets in a stateless rule session.Code example
The following code example shows how to execute rules in a J2SE session.
public IlrSessionResponse executeRulesOnJ2SESession(Customer user, ShoppingCart cart) throws IlrFormatException, IlrSessionException { IlrSessionFactory factory = new IlrJ2SESessionFactory(); IlrStatelessSession session = factory.createStatelessSession(); IlrSessionRequest sessionRequest = factory.createRequest(); sessionRequest.setRulesetPath(IlrPath.parsePath(rulesetPath)); // Ensure correct version of the ruleset is taken in account sessionRequest.setForceUptodate(true); sessionRequest.setTraceEnabled(true); sessionRequest.getTraceFilter().setInfoAllFilters(true); // Set the input parameters for the execution of the rules Map
inputParameters = new HashMap (); Announcement announcement = new Announcement(); inputParameters.put("announcement", announcement); inputParameters.put("customer", user); inputParameters.put("shoppingCart", cart); sessionRequest.setInputParameters(inputParameters); IlrSessionResponse sessionResponse = session.execute(sessionRequest); return sessionResponse; } - Since:
- 7.0
-
-
Method Summary
Methods Modifier and Type Method and Description java.lang.String
getExecutionId()
Returns the assigned execution ID.java.lang.Object
getInputParameter(java.lang.String name)
Returns the value of an input parameter.java.util.Map<java.lang.String,java.lang.Object>
getInputParameters()
Returns the input parameters.IlrPath
getRulesetPath()
Returns the ruleset path.java.lang.String
getTaskName()
Returns the name of the task to be executed.IlrTraceFilter
getTraceFilter()
Returns the trace filter.java.io.Serializable
getUserData()
Return the user data.boolean
isBOMAccess()
Returns the BOM access flag.boolean
isForceUptodate()
Tests if the ruleset has to be up-to-date before execution starts.boolean
isInterceptorEnabled()
Checks if session or session factory interceptors are overridden.boolean
isTraceEnabled()
Checks if XU traces are enabled.void
removeInputParameter(java.lang.String name)
Removes an input parameter from the parameters map.void
setBOMAccess(boolean bomAccess)
Sets the BOM access flag.void
setExecutionId(java.lang.String executionId)
Sets the execution ID for this request.void
setForceUptodate(boolean forceUptodate)
Forces execution to wait until ruleset parsing has been completed.void
setInputParameter(java.lang.String name, java.lang.Object value)
Sets an input parameter.void
setInputParameters(java.util.Map<java.lang.String,java.lang.Object> inputParameters)
Sets the input parameters.void
setInterceptorEnabled(boolean interceptorEnabled)
Overrides any session or session factory interceptors.void
setRulesetPath(IlrPath rulesetPath)
Sets the ruleset path.void
setTaskName(java.lang.String taskName)
Sets the name of the task to be executed.void
setTraceEnabled(boolean traceEnabled)
Enables or disables XU traces.void
setUserData(java.io.Serializable userData)
Set the user data that is passed to the interceptor and the XU.
-
-
-
Method Detail
-
setRulesetPath
void setRulesetPath(IlrPath rulesetPath)
Sets the ruleset path. The path can be in either of the following formats.- "/myruleapp/myruleset"
- "/myruleapp/1.0/myruleset/1.0"
- Parameters:
rulesetPath
- The ruleset path.
-
getRulesetPath
IlrPath getRulesetPath()
Returns the ruleset path.- Returns:
- The ruleset path.
-
setInputParameter
void setInputParameter(java.lang.String name, java.lang.Object value)
Sets an input parameter. This shortcut method is equivalent to callinggetInputParameters().put(name, value)
.Neither parameter can be set to
null
.- Parameters:
name
- The name of the input parameter.value
- The value of the input parameter.
-
getInputParameter
java.lang.Object getInputParameter(java.lang.String name)
Returns the value of an input parameter. This shortcut method is equivalent to callinggetInputParameters().get(name)
).- Parameters:
name
- The parameter name. This value must not benull
.- Returns:
- The value of the parameter. If no parameter matching
name
has been set,null
is returned.
-
removeInputParameter
void removeInputParameter(java.lang.String name)
Removes an input parameter from the parameters map. This shortcut method is equivalent to callinggetInputParameters().remove(name)
.- Parameters:
name
- The name of the parameter to remove. This value must not benull
.
-
getInputParameters
java.util.Map<java.lang.String,java.lang.Object> getInputParameters()
Returns the input parameters.- Returns:
- The input parameters.
-
setInputParameters
void setInputParameters(java.util.Map<java.lang.String,java.lang.Object> inputParameters)
Sets the input parameters.- Parameters:
inputParameters
- A map containing<name,value>
input parameters. This value must not benull
.
-
getTraceFilter
IlrTraceFilter getTraceFilter()
Returns the trace filter. Use the trace filter to set the trace level.- Returns:
- The trace filter.
-
setUserData
void setUserData(java.io.Serializable userData)
Set the user data that is passed to the interceptor and the XU.- Parameters:
userData
- The user data.
-
getUserData
java.io.Serializable getUserData()
Return the user data.- Returns:
- The user data.
-
isBOMAccess
boolean isBOMAccess()
Returns the BOM access flag.- Returns:
- The BOM access flag.
-
setBOMAccess
void setBOMAccess(boolean bomAccess)
Sets the BOM access flag.- Parameters:
bomAccess
- The BOM access flag.
-
getTaskName
java.lang.String getTaskName()
Returns the name of the task to be executed.- Returns:
- The name of the task to be executed.
-
setTaskName
void setTaskName(java.lang.String taskName)
Sets the name of the task to be executed. If this value is not set, no task is executed.- Parameters:
taskName
- The name of the task to be executed
-
isTraceEnabled
boolean isTraceEnabled()
Checks if XU traces are enabled.- Returns:
- If XU traces are enabled,
true
is returned.
-
setTraceEnabled
void setTraceEnabled(boolean traceEnabled)
Enables or disables XU traces.- Parameters:
traceEnabled
- Set totrue
to activate XU traces.
-
isInterceptorEnabled
boolean isInterceptorEnabled()
Checks if session or session factory interceptors are overridden.- Returns:
- If session or session factory interceptors are overridden,
true
is returned.
-
setInterceptorEnabled
void setInterceptorEnabled(boolean interceptorEnabled)
Overrides any session or session factory interceptors.- Parameters:
interceptorEnabled
- Set totrue
to override any session or session factory interceptors.
-
isForceUptodate
boolean isForceUptodate()
Tests if the ruleset has to be up-to-date before execution starts.- Returns:
- If the ruleset has to be up-to-date before execution starts,
true
is returned.
-
setForceUptodate
void setForceUptodate(boolean forceUptodate)
Forces execution to wait until ruleset parsing has been completed. If the XU pool does not have an up-to-date version of the ruleset, execution takes place after ruleset parsing is completed.- Parameters:
forceUptodate
- Set totrue
to ensure that the ruleset us up-to-date before execution starts.
-
getExecutionId
java.lang.String getExecutionId()
Returns the assigned execution ID.- Returns:
- The assigned execution ID. If no execution ID has been
set on this request,
null
is returned.
-
setExecutionId
void setExecutionId(java.lang.String executionId)
Sets the execution ID for this request. When set, rule sessions do not generate an ID,executionId
is returned in the response. The uniqueness ofexecutionId
is up to you. It is mandatory if the Decision Warehouse is used.- Parameters:
executionId
- The execution ID for this request.
-
-