Accessing decision engine and related artifacts from ARL mapping code

You can access the decision engine and its related artifacts, by writing ARL mapping code in the BOM-to-XOM mapping section of the BOM Editor.

About this task

The engine and other related artifacts can be accessed directly from the Advanced Rule Language (ARL) mapping code.

Note: You cannot use extender mapping to access the engine, ruleset variables, parameters, and rules.
When you write the ARL mapping code in the Body field, you associate it with a number of classes:
  • The current object, if you write the body for a non-static member.
  • The RunningEngineWithWorkingMemory, which represents the engine that is running.
  • The RuleInstance, which is null if the body is not called within a rule action.
  • The TaskInstance, which is null if the body is not called within a task execution.
  • The $EngineData class, which is a generated class that extends the EngineData interface, and contains the ruleset parameters and variables.
As in Java, when there is no ambiguity, you can directly refer to a member by its name. However, when there is ambiguity, you can follow the Java dot notation for accessing containing instances:
ContainingClass.this.member

Procedure

  1. In the Outline view, click the member that contains the ARL mapping that you want to edit.
  2. In the BOM Editor, open the BOM-to-XOM mapping section, and then go to the ARL statement in the Body field.
  3. You have the following options:
    Option Description
    Accessing running engine members from ARL mapping code

    Use RunningEngineWithWorkingMemory API to access the running engine members.

    You can use ARL mapping to stop the running engine:
    stop("stop by ARL mapping of method M");
    If your API call is ambiguous, it can be written by using the notation for accessing the enclosing class.
    com.ibm.rules.engine.runtime.RunningEngineWithWorkingMemory.this.stop("stop by ARL mapping of method M");
    Accessing rule instance from ARL mapping code

    Use RuleInstance API to access the rule instance members.

    You can use ARL mapping to add a trace:
    if (com.ibm.rules.engine.ruledef.runtime.RuleInstance.this != null)
      note("ARL mapping of method M being called by rule "+ ruleName);
    If your API call is ambiguous, it can be written by using the notation for accessing the enclosing class.
    if (com.ibm.rules.engine.ruledef.runtime.RuleInstance.this != null)
      note("ARL mapping of method M being called by rule "+ com.ibm.rules.engine.ruledef.runtime.RuleInstance.this.ruleName);
    Accessing ruleset variables and parameters from ARL mapping code

    Use EngineData API to access the ruleset variables and parameters.

    You can use ARL mapping to get the value of a ruleset parameter:
    param;
    or
    Object v = get("param");
    If your API call is ambiguous, it can be written by using the notation for accessing the enclosing class.
    Object v = $EngineData.this.get("param");
    or
    Object v = $EngineData.this.param;
  4. Save the BOM.

Results

You access the engine, ruleset variables, parameters, and rules directly from the BOM Editor, in which you edit the ARL mapping code.