com.ibm.websphere.brb
Interface FiringStrategy

All Known Implementing Classes:
DefaultFiringStrategy

public interface FiringStrategy

The firing strategy implements the function which takes the rules which were found by the FindingStrategy, (possibly modified by the FilteringStrategy), and fires each of the rules in order. An array containing the results of each rule is returned.The FiringStrategy}, may be specified using the TriggerPoint.setFiringStrategy() method. To specify one of the predefined firing strategies, use the static constants on this interface.

A single default FiringStrategy is provided by BRBeans, as all types of rules are fired in the same way. This implementation takes each rule in order and performs the following steps:

  1. Determine what firing parameters to pass to the rule. If there are no firing parameters specified for this rule, use the firing parameters passed on the TriggerPoint call. Otherwise use the firing parameters specified in the rule in place of the parameters passed on the TriggerPoint call.
  2. Call the fire method on the rule, passing the firing parameters from the first step.
Unexpected exceptions result in an BusinessRuleBeansException being thrown that contains the original exception.

The default firing strategy should be adequate for most purposes. One possible reason to implement a custom firing strategy may be to implement a judicial review strategy, where the results of each rule are passed into the next rule. Another possibility would be to implement a new firing strategy that logs every rule that is fired.


Field Summary
static FiringStrategy DEFAULT
          The default firing strategy.
 
Method Summary
 java.lang.Object[] fireRules(TriggerPoint tp, IRule[] rules, java.lang.Object target, java.lang.Object[] tpFiringParams)
          Fires the rules which are given to it and returns the results of each one in an array.
 

Field Detail

DEFAULT

public static final FiringStrategy DEFAULT
The default firing strategy.
Method Detail

fireRules

public java.lang.Object[] fireRules(TriggerPoint tp,
                                    IRule[] rules,
                                    java.lang.Object target,
                                    java.lang.Object[] tpFiringParams)
                             throws BusinessRuleBeansException
Fires the rules which are given to it and returns the results of each one in an array. The result array should be in the same order as the given rules, for example the result of firing rule[0] should be in result[0], etc. The length of the result array should equal the number of rules being fired. Note: a FiringStrategy should not normally interpret or change the results returned from the set of rules being fired. That is intended to be done by a CombiningStrategy.

Part of the work done by this method is to determine what firing parameters are to be passed to the rules being fired. Normally the firing parameters passed should be the firing parameters passed on the trigger point or, if firing parameters are specified in the rule itself, then these should be passed. However, the programmer writing his or her own firing strategy can override this behavior.

DefaultFiringStrategy provides more details about writing your own firing strategy.

Parameters:
tp - the trigger point which is used to make this call
rules - the ordered array of rules which are to be fired
target - the target object which was passed on the trigger point
tpFiringParams - the firingParams which were passed on the trigger point
Returns:
An array of results, each of which corresponds to exactly one fired rule.
Throws:
BusinessRuleBeansException - if any exceptions occur