Interface IRuleEngine


  • @Deprecated(since="9.2")
    public interface IRuleEngine
    Deprecated.

    Rule Engine is an engine to execute rules. A rule is composed of two parts, a condition and an action: When the condition is met, the action is executed.

    From this interface you can create RuleBase. The RuleBase is a repository for all rule resources. Then the RuleBase has to create a new rule session to execute the rules.

    • Rule resource is a resource that defines rules. It can be a native rule language (*.drl) file, decision table.
    • Rule session is a session that interacts with the engine.

    Example: execute rules on an object

      // This example will calculate tax for an employee
      Employee employee = new Employee("John Snow", 4000);
      IRuleBase rulebase = Rules.engine().createRuleBase();
      // namespace.of.rules is the folder hierarchy (namespace\of\rules) that contains rule resources
      // and inside the root rules folder in the Ivy project
      rulebase.loadRulesFromNamespace("namespace.of.rules");
      
      IStatelessRuleSession session = rulebase.createSession();
      session.execute(employee);
      
    Example: execute rules on a collection of objects
      // This example will calculate tax for list of employees
      IRuleBase rulebase = Rules.engine().createRuleBase();
      rulebase.loadRulesFromNamespace("namespace.of.rules");
      IStatelessRuleSession session = rulebase.createSession();
      session.execute(employees);
      

    API:
    This is a public API.