com.ibm.websphere.brb.strategy
Class DefaultFiringStrategy

java.lang.Object
  |
  +--com.ibm.websphere.brb.strategy.DefaultFiringStrategy
All Implemented Interfaces:
FiringStrategy, java.io.Serializable

public class DefaultFiringStrategy
extends java.lang.Object
implements FiringStrategy, java.io.Serializable

The default implementation of the FiringStrategy interface. This is the firing strategy that is used if no other is specified on the trigger point. Clients wishing to write their own firing strategies can use it as the basis for implementing various kinds of firing strategies. The client programmer should subclass DefaultFiringStrategy to implement a specific kind of strategy. Normally new behavior should be implemented by overriding the determineFiringParms and/or fireOneRule methods. The default fireRules method should usually be adequate. Note that, since the firing strategy is stored as part of the TriggerPoint and the TriggerPoint may be passed on a remote method call to the rule when it is fired, any FiringStrategy implementation must implement the Serializable interface.

See Also:
Serialized Form

Fields inherited from interface com.ibm.websphere.brb.FiringStrategy
DEFAULT
 
Constructor Summary
DefaultFiringStrategy()
          DefaultFiringStrategy constructor.
 
Method Summary
 java.lang.Object[] determineFiringParms(IRule ruleToFire, TriggerPoint tp, java.lang.Object target, java.lang.Object[] tpFiringParms)
          Determine what firing parameters should be passed to the specified rule when it is fired.
 java.lang.Object fireOneRule(IRule ruleToFire, TriggerPoint tp, java.lang.Object target, java.lang.Object[] firingParms)
          Fire the specified rule with the specified firing parameters and target object and return the result.
 java.lang.Object[] fireRules(TriggerPoint tp, IRule[] rules, java.lang.Object target, java.lang.Object[] tpFiringParams)
          This implementation of the fireRules method controls the overall flow of events that result in the specified rules being fired.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFiringStrategy

public DefaultFiringStrategy()
DefaultFiringStrategy constructor.
Method Detail

determineFiringParms

public java.lang.Object[] determineFiringParms(IRule ruleToFire,
                                               TriggerPoint tp,
                                               java.lang.Object target,
                                               java.lang.Object[] tpFiringParms)
                                        throws BusinessRuleBeansException
Determine what firing parameters should be passed to the specified rule when it is fired. The array of objects returned by this method is intended to be passed on the rule's fire method as the firing parameters.

Any of the parameters passed to this method may be used to determine what firing parameters are to be passed to the rule. This implementation checks to see if the rule itself has any firing parameters defined. If it does, these are used to generate the firing parameters to be passed on the fire method. If the rule does not have firing parameters, then the firing parameters passed on the trigger point call are passed unmodified to the fire method.

The behavior described above is considered the normal behavior for firing parameters. However, the client may override this method to determine the firing parameters using whatever algorithm makes sense for the rule being fired.

Parameters:
ruleToFire - the rule to be fired
tp - the trigger point which is used to make this call
target - the target object which was passed on the trigger point
tpFiringParms - the firingParams which were passed on the trigger point
Returns:
Array containing the firing parameters to be passed to the rule.
Throws:
BusinessRuleBeansException - if any exceptions occur

fireOneRule

public java.lang.Object fireOneRule(IRule ruleToFire,
                                    TriggerPoint tp,
                                    java.lang.Object target,
                                    java.lang.Object[] firingParms)
                             throws BusinessRuleBeansException
Fire the specified rule with the specified firing parameters and target object and return the result. This implementation just calls the fire method on the specified rule, passing the specified parameters. However, the client may use another algorithm if desired as long as the result returned can be interpreted as the result of firing the specified rule.

Parameters:
ruleToFire - the rule to be fired
tp - the trigger point which is used to make this call
target - the target object which was passed on the trigger point
tpFiringParms - the firingParams which are to be passed to this rule
Returns:
The result of firing the specified rule.
Throws:
BusinessRuleBeansException - if any exceptions occur

fireRules

public java.lang.Object[] fireRules(TriggerPoint tp,
                                    IRule[] rules,
                                    java.lang.Object target,
                                    java.lang.Object[] tpFiringParams)
                             throws BusinessRuleBeansException
This implementation of the fireRules method controls the overall flow of events that result in the specified rules being fired. This consists of iterating through the array of rules and, for each one, determining the firing parameters and firing the rule. An array of results is built up and returned after all rules have been fired. Any unexpected errors will result in an BusinessRuleBeansException being thrown immediately. Remaining rules are not fired.

When implementing a custom firing strategy, if this method is overridden, care should be taken that the new implementation fulfills the method's contract. Normally the overall sequence of events defined in this implementation should be adequate and clients should override the determineFiringParms and fireOneRule methods to implement their own FiringStrategy.

Specified by:
fireRules in interface FiringStrategy
Following copied from interface: com.ibm.websphere.brb.FiringStrategy
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