Writing actions in IRL

When you write rule actions, use the same syntax as a Java™ method body, except for the syntax for anonymous inner classes.

All bound variables that are defined in the rule, all ruleset parameters, all public static methods and attributes, and all functions are visible in the action scope. Some specific variables are always available in the action scope:

  • ?context is the current rule engine

  • ?instance is the current rule instance

As in a Java method body, all public classes of the current class loader are visible (through an import or with their fully qualified name).

Example

then {
     System.out.println("The account " + account + " has no 
                        money in it");
     Report report = new Report(account);
     dispatcher.send(report); // dispatcher is a ruleset parameter
}