XU configuration properties for Java SE

You can set configuration properties for execution units (XU) by using the API of session factories or the XU configuration API.

About this task

You can modify the behavior of Java™ SE instances of the execution unit (XU) by using the session factory API to change the XU configuration settings. In this example, you use the session API to set the persistence mode.

You can also use the IlrXUConfig.loadSettings method, which loads the value of XU configuration properties from the resource adapter descriptor file (by default, ra.xml).

Procedure

  1. Set up a custom IlrSessionFactoryConfig instance by calling the IlrJ2SESessionFactory.createDefaultConfig method.
    IlrSessionFactoryConfig config = IlrJ2SESessionFactory.createDefaultConfig();
  2. Make the appropriate changes on the returned instance of IlrSessionFactoryConfig.
    In this example, the session factory instance uses a file-based ruleset repository. Its home path is C:/my_ruleset_rep
    config.getXUConfig().getPersistenceConfig().setPersistenceType(IlrPersistenceType.FILE);
    config.getXUConfig().getPersistenceConfig().getFilePersistenceConfig().setDirectory(new File("C:/my_ruleset_repo"));
    
  3. Call the IlrJ2SESessionFactory#IlrJ2SESessionFactory(ilog.rules.res.session.config.IlrSessionFactoryConfig) constructor.
    IlrJ2SESessionFactory factory = new IlrJ2SESessionFactory(config);

Results

Here is the entire code sample:
IlrSessionFactoryConfig config = IlrJ2SESessionFactory.createDefaultConfig();
config.getXUConfig().getPersistenceConfig().setPersistenceType(IlrPersistenceType.FILE);
config.getXUConfig().getPersistenceConfig().getFilePersistenceConfig().setDirectory(new File("C:/my_ruleset_repo"));
IlrJ2SESessionFactory factory = new IlrJ2SESessionFactory(config);