com.ibm.websphere.brb
Interface RuleImplementor

All Known Implementing Classes:
RuleLink, RuleOR, RuleFalse, RuleTrue, RuleIfThenElse, RuleValueForRangeNonInclusive, RuleConstant, RuleGreaterThan, RuleIsNotNull, RuleAND, RuleValueForRange, RuleGreaterThanEqual, RuleLessThanEqual, RuleConvert, RuleRangeNonInclusive, RuleIsNull, RuleMerger, RuleLessThan, RuleRange, RuleEqual

public interface RuleImplementor

The Java interface for rule implementations. RuleImplementors are the objects that provide the actual behavior of the rules. When a Rule is fired for the first time it will create an instance of its RuleImplementor class using the default constructor. Then the init(Object[],String[],String,IRuleCopy) method is called, passing the initialization parameters defined for the Rule. Then the fire(TriggerPoint,Object,IRuleCopy,Object[]) method is called to elicit the RuleImplementor's behavior.

The init method is called before the fire method is called for the first time. Once the RuleImplementor is instantiated, the Rule caches it so that it doesn't have to be created and initialized again the next time that Rule is fired. On subsequent fires, only the RuleImplementor's fire method is called, not its init method. Thus the RuleImplementor is generally initialized only once but can be fired many times.

In some scenarios, the method fire may be called from multiple processes on the same instance of a RuleImplementor. This will happen if more than one client triggers the same rule at the same time. The implication of this is that the method fire should not change instance attributes of the implementor unless synchronization of the data being changed is performed.


Method Summary
 java.lang.Object fire(TriggerPoint tp, java.lang.Object target, IRuleCopy rule, java.lang.Object[] firingParms)
          Invoke this method to elicit the behavior of the RuleImplementor.
 java.lang.String getDescription()
          Returns a String describing the RuleImplementor.
 void init(java.lang.Object[] initParams, java.lang.String[] dependentRules, java.lang.String userDefinedData, IRuleCopy rule)
          Just after a RuleImplementor is instantiated through its parameterless constructor (which is the only way RuleImplementors come into existence), this method is called and passed RuleImplementor-specific parameters.
 

Method Detail

fire

public java.lang.Object fire(TriggerPoint tp,
                             java.lang.Object target,
                             IRuleCopy rule,
                             java.lang.Object[] firingParms)
                      throws BusinessRuleBeansException
Invoke this method to elicit the behavior of the RuleImplementor. The behavior is completely determined by the programmer writing the rule implementor class.

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
firingParams - the firing parameters, i.e. those parameters that are passed to the BRBeans framework at the trigger point
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:
com.ibm.brb.BusinessRuleBeansException - Thrown when an error condition is associated with the fired Rule implementation.

getDescription

public java.lang.String getDescription()
Returns a String describing the RuleImplementor. This String may used in an administrative system to describe what the RuleImplementor does. Often the user's task is to choose among a set of RuleImplementors and this description could help them make that choice.

Returns:
A description of this rule implementor.

init

public void init(java.lang.Object[] initParams,
                 java.lang.String[] dependentRules,
                 java.lang.String userDefinedData,
                 IRuleCopy rule)
          throws BusinessRuleBeansException
Just after a RuleImplementor is instantiated through its parameterless constructor (which is the only way RuleImplementors come into existence), this method is called and passed RuleImplementor-specific parameters. These parameters are the Rule initialization parameters.

Parameters:
initParams - 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