Rule Execution Server API

ilog.rules.res.session
Interface IlrSessionRequest

All Superinterfaces:
Serializable

public interface IlrSessionRequest
extends 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
 String getExecutionId()
          Returns the assigned execution ID.
 Object getInputParameter(String name)
          Returns the value of an input parameter.
 Map<String,Object> getInputParameters()
          Returns the input parameters.
 IlrPath getRulesetPath()
          Returns the ruleset path.
 String getTaskName()
          Returns the name of the task to be executed.
 IlrTraceFilter getTraceFilter()
          Returns the trace filter.
 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(String name)
          Removes an input parameter from the parameters map.
 void setBOMAccess(boolean bomAccess)
          Sets the BOM access flag.
 void setExecutionId(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(String name, Object value)
          Sets an input parameter.
 void setInputParameters(Map<String,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(String taskName)
          Sets the name of the task to be executed.
 void setTraceEnabled(boolean traceEnabled)
          Enables or disables XU traces.
 void setUserData(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.

Parameters:
rulesetPath - The ruleset path.

getRulesetPath

IlrPath getRulesetPath()
Returns the ruleset path.

Returns:
The ruleset path.

setInputParameter

void setInputParameter(String name,
                       Object value)
Sets an input parameter. This shortcut method is equivalent to calling getInputParameters().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

Object getInputParameter(String name)
Returns the value of an input parameter. This shortcut method is equivalent to calling getInputParameters().get(name)).

Parameters:
name - The parameter name. This value must not be null.
Returns:
The value of the parameter. If no parameter matching name has been set, null is returned.

removeInputParameter

void removeInputParameter(String name)
Removes an input parameter from the parameters map. This shortcut method is equivalent to calling getInputParameters().remove(name).

Parameters:
name - The name of the parameter to remove. This value must not be null.

getInputParameters

Map<String,Object> getInputParameters()
Returns the input parameters.

Returns:
The input parameters.

setInputParameters

void setInputParameters(Map<String,Object> inputParameters)
Sets the input parameters.

Parameters:
inputParameters - A map containing <name,value> input parameters. This value must not be null.

getTraceFilter

IlrTraceFilter getTraceFilter()
Returns the trace filter. Use the trace filter to set the trace level.

Returns:
The trace filter.

setUserData

void setUserData(Serializable userData)
Set the user data that is passed to the interceptor and the XU.

Parameters:
userData - The user data.

getUserData

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

String getTaskName()
Returns the name of the task to be executed.

Returns:
The name of the task to be executed.

setTaskName

void setTaskName(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 to true 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 to true 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 to true to ensure that the ruleset us up-to-date before execution starts.

getExecutionId

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(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 of executionId is up to you. It is mandatory if the Decision Warehouse is used.

Parameters:
executionId - The execution ID for this request.

Rule Execution Server API

© Copyright IBM Corp. 1987, 2013