Notifying a XU on Java EE of a ruleset update

In a Java™ EE application, you can notify the execution unit (XU) that a ruleset is no longer valid because it has been updated.

About this task

To notify the XU of a ruleset update on Java EE, use a rule session factory and the invalidate method. When a ruleset is invalidated, that ruleset is parsed at the next request. Therefore, this action can significantly affect performance.

The invalidate method takes a canonical ruleset path. To retrieve the canonical ruleset path, use the solveRulesetPath method.

Procedure

  1. Get the rule session factory.
    IlrSessionFactory sessionFactory = new IlrPOJOSessionFactory();
  2. Create the management session.
    IlrManagementSession managementSession=sessionFactory.createManagementSession();
  3. Retrieve the canonical path of the ruleset.
    IlrPath rulesetPath = IlrPath.parsePath("/RuleApp/1.0/RuleSet/1.0");
  4. Invalidate the ruleset.
    managementSession.invalidate(rulesetPath);

Example

Here is the entire code sample.
IlrSessionFactory sessionFactory = new IlrPOJOSessionFactory();
IlrManagementSession managementSession=sessionFactory.createManagementSession();
IlrPath rulesetPath = IlrPath.parsePath("/RuleApp/1.0/RuleSet/1.0");
managementSession.invalidate(rulesetPath);