Executing rules with an embedded rule engine

You can run the rules locally for test purposes by using an embedded engine.

When you run rules in an embedded environment, you deploy and run a ruleset archive on a single Java™ Virtual Machine (JVM).

The following figure shows an embedded environment and the necessary parts to run rules by a rule engine:

Executing rules in an embedded environment

You must include the rule engine in the class path of the application.

In the application, you use the Rule Designer API to do the following tasks:

  • Load a ruleset.

  • Instantiate a rule engine.

  • run the rule engine against objects passed as parameters.

The Java Virtual Machine in which you run the ruleset must be able to locate the application, the XOM, the rule engine , and the JDK. The following figure shows the necessary components to run a ruleset.

Java Virtual Machine (JVM)

The rule engine uses a ruleset and a group of objects to evaluate which rules must be fired. Firing a rule means executing the action part of the rule in the context of the objects that have satisfied its conditions.

Graphic presentation of the rule engine

 Step 1  of this graphic shows that the rule engine is based on pattern matching: it matches rule conditions with a group of objects that are defined by the ruleset parameters.

In  Step 2 , the rule engine creates a rule instance for each match between a rule and an object or group of objects. The execution mode determines the way in which the rule instance is run.