com.ibm.websphere.brb
Interface CombiningStrategy

All Known Implementing Classes:
ReturnAllCombiningStrategy, ReturnAndCombiningStrategy, ReturnFirstCombiningStrategy, ReturnLastCombiningStrategy, ReturnOrCombiningStrategy, ThrowViolationCombiningStrategy

public interface CombiningStrategy

The job of the CombiningStrategy is to take the results of the rules which were fired by the FiringStrategy and to combine them to form a reasonable result to the TriggerPoint caller. The CombiningStrategy may be specified using the TriggerPoint.setCombiningStrategy() method. To specify one of the predefined combining strategies, use the static constants on this interface.

BRBeans provides several combining strategies to be used in applications. Some of them, ThrowViolationCombiningStrategy, ReturnOrCombiningStrategy, and ReturnAndCombiningStrategy assume that the results which are passed are either ConstraintReturn objects or java.lang.Boolean objects. Exceptions are thrown if this is not the case.

Clients may implement their own combining strategies to combine results using a custom algorithm. This may be done by creating a class that implements the CombiningStrategy interface and providing an implementation for the combineResults method. Note that, since the combining 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 CombiningStrategy implementation must implement the Serializable interface.


Field Summary
static CombiningStrategy RETURN_ALL
          Returns an array containing the results from all of the applicable rules.
static CombiningStrategy RETURN_AND
          Returns the logical AND of all the results.
static CombiningStrategy RETURN_FIRST
          Returns the first result; if no rules are found, returns null.
static CombiningStrategy RETURN_LAST
          Returns the last result; if no rules are found, returns null.
static CombiningStrategy RETURN_OR
          Returns the logical OR of all the results.
static CombiningStrategy THROW_VIOLATION
          Throws a RuleViolation containing all failed ConstraintReturns or returns true when no constraints fail.
 
Method Summary
 java.lang.Object combineResults(TriggerPoint tp, java.lang.Object[] results)
          Takes the results of firing the rules and combines them to form a single result.
 

Field Detail

RETURN_ALL

public static final CombiningStrategy RETURN_ALL
Returns an array containing the results from all of the applicable rules. Note that an array of length one is returned if only one result is given.


RETURN_FIRST

public static final CombiningStrategy RETURN_FIRST
Returns the first result; if no rules are found, returns null.


RETURN_LAST

public static final CombiningStrategy RETURN_LAST
Returns the last result; if no rules are found, returns null.


RETURN_AND

public static final CombiningStrategy RETURN_AND
Returns the logical AND of all the results.


RETURN_OR

public static final CombiningStrategy RETURN_OR
Returns the logical OR of all the results.


THROW_VIOLATION

public static final CombiningStrategy THROW_VIOLATION
Throws a RuleViolation containing all failed ConstraintReturns or returns true when no constraints fail.

Method Detail

combineResults

public java.lang.Object combineResults(TriggerPoint tp,
                                       java.lang.Object[] results)
                                throws BusinessRuleBeansException

Takes the results of firing the rules and combines them to form a single result. This single result may, however, still be an array of Objects.

Parameters:
tp - the trigger point which is used to make this call
results - the list of results of firing the rules
Returns:
The combined result of the rules fired on this TriggerPoint call. Any type of object can be returned as the result.
Throws:
BusinessRuleBeansException - if any exceptions occur