ILOG JRules User Guide > Creating Rule Projects > Tasks > Defining How Business Elements Map to the XOM > Accessing Rule Instances from IRL Mapping Code

You can access the current rule instance by using the predefined variable instance (you can also write it ?instance). This predefined variable can be used in any of the execution modes (Rete, Sequential, or Fastpath).

In IRL mapping code, the instance variable may be null. It is not null when the member is used in a rule action.

To access a rule instance:

  1. In the Outline view, click the member that contains the IRL mapping you want to edit.
  2. In the BOM Editor, open the BOM to XOM Mapping section, and go to the IRL statement in the Body field.
  3. Use the variable instance to access the rule instance.
  4. Save the BOM.

In this example, IRL mapping is used to add a trace:

if (instance != null)
  out.println("IRL mapping of method M being called
                          by rule "+instance.ruleName);

Related Concepts

Business Object Model (BOM)
Execution Object Model (XOM)
BOM and XOM

Related Tasks

Defining How Business Elements Map to the XOM
Managing XOM Changes in the BOM

Related Reference

BOM Editor
ILOG Rule Language

Related Samples and Tutorials

Tutorial: Defining a Vocabulary