Business Rule Beans (BRBeans) run-time behavior can best be described by giving a simple example of a trigger point selecting, executing, and then responding to the results of a business rule.
The first step in triggering a rule is for the trigger point framework to perform a query on the rule server to determine which rules to trigger. The main item used for the query is the fully qualified rule name. Other items used in the query include the start and end date, whether this is a classifier, the classification of the rule, and whether the rule is marked "ready". This query returns zero or more rules. If there is at least one rule, the trigger point assembles the data that is sent as parameters to each rule. The trigger point then loops through the list of rules invoking the fire() method on each and passing the parameters. The results are combined depending on the combining strategy used.
When the trigger point framework invokes fire on a rule, it instantiates the RuleImplementor and uses it to do the actual work (to execute the rule algorithm or test). Once it has arrived at a result, the RuleImplementor returns that result. For constraint rules (ones that arrive at a boolean true or false answer) the returned value is, by convention, a ConstraintReturn. A ConstraintReturn is a data structure that indicates whether the constraint was satisfied. If not, the ConstraintReturn indicates what went wrong. For derivation rules (ones that calculate a single, generally non-boolean value), the return value can be any type. In the simplest case, the return value from each RuleImplementor is returned back to the trigger point where it is analyzed to determine what action to take.
The following is an overview of what happens when the maxTruckDriverHours rule is triggered:
A rule exists named maxTruckDriverHours. The purpose of this rule is to check that the number of hours entered by a user for a particular truck driver does not exceed the maximum allowed value. This rule contains an initialization parameter list consisting of a single value of 8. This rule is bound to a RuleImplementor class called MaxRuleImpl. MaxRuleImpl tests the parameter it is passed against the initialization list value and returns a ConstraintReturn. The ConstraintReturn is set to true if the passed parameter is less than or equal to the initialization value. Otherwise, a ConstraintReturn is set to false and some information is added that describes which values were compared and why the test failed.
When this rule is triggered, the following details the trigger point process: