com.ibm.websphere.brb.implementor
Class RuleMerger

java.lang.Object
  extended bycom.ibm.websphere.brb.implementor.RuleMerger
All Implemented Interfaces:
RuleImplementor

public class RuleMerger
extends java.lang.Object
implements RuleImplementor

Combination rule comprised of three or more rules, one of which is a merger rule. All but the merger rule are fired to get a set of results. The merger rule is then fired to arrive at a combined result. The passed in firing parameters are passed to each of the rules whose results are to be combined. All these rules must accept the same set of firing parameters. The firing parameters which are passed to the merger rule consist of the original firing parameters, followed by the result of each rule that was just fired.

Note that it is allowed to pass 0 or 1 rules whose results are to be combined. Therefore, in general, the merger rule must be prepared to handle getting no results or just one result from the rules to be combined.


Field Summary
protected  java.lang.String[] dependentRules
           
 
Constructor Summary
RuleMerger()
          Parameterless constructor for RuleMerger.
 
Method Summary
 java.lang.Object fire(TriggerPoint tp, java.lang.Object target, IRuleCopy rule, java.lang.Object[] parms)
          Given a set of rules, fires all but the first and passes the results and any input parameters to the first rule (the merger rule) for combining.
 java.lang.String getDescription()
          The programmer's description of what the algorithm does.
 void init(java.lang.Object[] parms, java.lang.String[] dependentRules, java.lang.String userDefinedData, IRuleCopy rule)
          Initializes constants used by this rule.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dependentRules

protected java.lang.String[] dependentRules
Constructor Detail

RuleMerger

public RuleMerger()
Parameterless constructor for RuleMerger.

Method Detail

fire

public java.lang.Object fire(TriggerPoint tp,
                             java.lang.Object target,
                             IRuleCopy rule,
                             java.lang.Object[] parms)
                      throws BusinessRuleBeansException
Given a set of rules, fires all but the first and passes the results and any input parameters to the first rule (the merger rule) for combining.

Specified by:
fire in interface RuleImplementor
Parameters:
tp - the trigger point which is firing this rule implementor.
target - the target object of the trigger point
rule - the rule that the implementor is running on behalf of
Returns:
The result of firing the rule implementor. Implementors that carry out classifications must return a single String. Implementors which check constraints should generally return a ConstraintReturn, especially if the results are to be combined and returned by the BRBeans framework.
Throws:
BusinessRuleBeansException

getDescription

public java.lang.String getDescription()
The programmer's description of what the algorithm does.

Specified by:
getDescription in interface RuleImplementor
Returns:
A description of this rule implementor.

init

public void init(java.lang.Object[] parms,
                 java.lang.String[] dependentRules,
                 java.lang.String userDefinedData,
                 IRuleCopy rule)
          throws BusinessRuleBeansException
Initializes constants used by this rule. Saves the set of rules ids to be fired. The first rule id is the merger rule that combines results from the other rules. The second through nth rules are the rules whose results are combined.

Specified by:
init in interface RuleImplementor
Parameters:
parms - the parameters needed to initialize this RuleImplementor
dependentRules - the names of the dependent rules to this rule; if there are none, null is passed
userDefinedData - userDefinedData property from the Rule
rule - the Rule on whose behalf the rule implementor is running
Throws:
BusinessRuleBeansException