Rule Execution Server API

ilog.rules.res.session
Interface IlrSessionFactory

All Known Implementing Classes:
IlrEJB3SessionFactory, IlrJ2SESessionFactory, IlrPOJOSessionFactory, ilog.rules.res.session.IlrSessionFactoryBase

public interface IlrSessionFactory

IlrSessionFactory is the interface implemented by all rule session factories. Use rule session factories to retrieve management, stateless, or stateful sessions and session requests. A rule session factory is the entry point for connections to the Rule Execution Server using the rule session API.

Code example

The following code example shows how to execute rules in a Java SE 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
 IlrManagementSession createManagementSession()
          Returns a new management session.
 IlrSessionRequest createRequest()
          Returns a request object used to execute rulesets.
 IlrStatefulSession createStatefulSession(IlrPath rulesetPath, Serializable userData, Map<String,Object> initParameters, boolean forceUptodate)
          Returns a stateful rule session.
 IlrStatefulSession createStatefulSession(IlrPath rulesetPath, Serializable userData, Map<String,Object> initParameters, boolean forceUptodate, boolean enableInterceptor)
          Returns a stateful rule session.
 IlrStatelessSession createStatelessSession()
          Returns a stateless rule session.
 IlrTraceDAOFactory createTraceDAOFactory()
          Returns an initialized IlrTraceDAOFactory instance used to write traces for the rule sessions created by this factory.
 boolean isInterceptorEnabled()
          Returns whether interceptors are enabled.
 void setInterceptorEnabled(boolean interceptorEnabled)
          Sets the "interceptors enabled" flag for all the requests created by this factory.
 

Method Detail

createStatelessSession

IlrStatelessSession createStatelessSession()
                                           throws IlrSessionCreationException
Returns a stateless rule session.

Throws:
IlrSessionCreationException - if an error occurred when the stateless session was created:
Returns:
A new stateless session.

createStatefulSession

IlrStatefulSession createStatefulSession(IlrPath rulesetPath,
                                         Serializable userData,
                                         Map<String,Object> initParameters,
                                         boolean forceUptodate)
                                         throws IlrSessionCreationException
Returns a stateful rule session.

Throws:
IlrSessionCreationException - if an error occurred when the stateful session was created.
Parameters:
rulesetPath - The ruleset path for the session.
userData - A serializable object supplied by the user.
initParameters - Initalization parameters used by the interceptors if necessary.
forceUptodate - Set to true to indicate that the latest version of the ruleset must be used.
Returns:
A new stateful session.

createRequest

IlrSessionRequest createRequest()
Returns a request object used to execute rulesets.

Returns:
A new request.

createManagementSession

IlrManagementSession createManagementSession()
                                             throws IlrSessionCreationException
Returns a new management session.

Throws:
IlrSessionCreationException - if an error occurs when the management session is created.
Returns:
A new management session.

isInterceptorEnabled

boolean isInterceptorEnabled()
Returns whether interceptors are enabled.

Returns:
true if interceptors are enabled.

setInterceptorEnabled

void setInterceptorEnabled(boolean interceptorEnabled)
Sets the "interceptors enabled" flag for all the requests created by this factory. You can override this method at the request level.

Parameters:
interceptorEnabled - Set to true to enable interceptors.

createTraceDAOFactory

IlrTraceDAOFactory createTraceDAOFactory()
                                         throws IlrTraceDAOException
Returns an initialized IlrTraceDAOFactory instance used to write traces for the rule sessions created by this factory. Override this method when you need a different IlrTraceDAOFactory instance from the one configured at the Rule Execution Server level.

Throws:
IlrTraceDAOException - if an error occurred when the factory was created.
Returns:
An initialized IlrTraceDAOFactory instance.

createStatefulSession

IlrStatefulSession createStatefulSession(IlrPath rulesetPath,
                                         Serializable userData,
                                         Map<String,Object> initParameters,
                                         boolean forceUptodate,
                                         boolean enableInterceptor)
                                         throws IlrSessionCreationException
Returns a stateful rule session.

Throws:
IlrSessionCreationException - if an error occurred when the stateful session was created.
Parameters:
rulesetPath - The ruleset path for the session.
userData - A serializable object supplied by the user.
initParameters - Initalization parameters used by the interceptors if necessary.
forceUptodate - Set to true to indicate that the latest version of the ruleset must be used.
enableInterceptor - Set to true to indicate that the interceptors should be enabled
Returns:
A new stateful session.

Rule Execution Server API

© Copyright IBM Corp. 1987, 2012