Rule Execution Server API

ilog.rules.res.session
Class IlrJ2SESessionFactory

java.lang.Object
  extended by ilog.rules.res.session.impl.IlrSessionFactoryBase
      extended by ilog.rules.res.session.IlrJ2SESessionFactory
All Implemented Interfaces:
IlrSessionFactory

public class IlrJ2SESessionFactory
extends ilog.rules.res.session.impl.IlrSessionFactoryBase

The IlrJ2SESessionFactory class is a rule session factory for Java SE environments. This class is a wrapper for a fully functional J2SE Execution Unit (XU). It does not depend on application server resources.

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<String, Object> inputParameters = new HashMap<String, Object>();
     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

Constructor Summary
IlrJ2SESessionFactory()
           
IlrJ2SESessionFactory(IlrSessionFactoryConfig config)
          Creates a session factory with a custom configuration.
 
Method Summary
static IlrSessionFactoryConfig createDefaultConfig()
          Creates a session factory configuration that holds default settings.
 IlrManagementSession createManagementSession()
          Returns a new management 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.
protected  InputStream findXUDescriptorStream()
           
 void release()
          Releases the resources that are used by this session factory.
After this method has been called, any rule session that is created by this factory and still in use may have an unpredictable behaviour.
Call this method only if you no longer want to execute rule sessions and need to release the corresponding resources.
 
Methods inherited from class ilog.rules.res.session.impl.IlrSessionFactoryBase
createRequest, createStatefulSession, createTraceDAOFactory, isInterceptorEnabled, setInterceptorEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlrJ2SESessionFactory

public IlrJ2SESessionFactory()

IlrJ2SESessionFactory

public IlrJ2SESessionFactory(IlrSessionFactoryConfig config)
Creates a session factory with a custom configuration. Use createDefaultConfig() to create a session factory configuration.

Parameters:
config - a session factory configuration
Method Detail

createDefaultConfig

public static IlrSessionFactoryConfig createDefaultConfig()
Creates a session factory configuration that holds default settings. Use this method in conjunction with IlrJ2SESessionFactory(IlrSessionFactoryConfig) to create a custom session factory.

Since:
8.0
Returns:
a session factory configuration that holds default settings

createStatelessSession

public IlrStatelessSession createStatelessSession()
                                           throws IlrSessionCreationException
Description copied from interface: IlrSessionFactory
Returns a stateless rule session.

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

createStatefulSession

public IlrStatefulSession createStatefulSession(IlrPath rulesetPath,
                                                Serializable userData,
                                                Map<String,Object> initParameters,
                                                boolean forceUptodate,
                                                boolean enableInterceptor)
                                         throws IlrSessionCreationException
Description copied from interface: IlrSessionFactory
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.

createManagementSession

public IlrManagementSession createManagementSession()
                                             throws IlrSessionCreationException
Description copied from interface: IlrSessionFactory
Returns a new management session.

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

findXUDescriptorStream

protected InputStream findXUDescriptorStream()

release

public void release()
Releases the resources that are used by this session factory.
After this method has been called, any rule session that is created by this factory and still in use may have an unpredictable behaviour.
Call this method only if you no longer want to execute rule sessions and need to release the corresponding resources.


Rule Execution Server API

© Copyright IBM Corp. 1987, 2013