|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The job of the FilteringStrategy is to take the list of rules which were
found by the FindingStrategy
and
to filter out those rules which should not be fired. There are three sets of
filtering strategies used in TriggerPoint
:
TriggerPoint
methods: setMultipleRulesFilteringStrategy()
,
setNoRulesFilteringStrategy()
, and
setOneRuleFilteringStrategy()
.
To specify one of the predefined filtering strategies, use the static constants
on this interface.
As an example, here is one common way to use filtering strategies. Suppose you want to ensure that exactly one rule is found on a TriggerPoint call. You would set all three strategies (zero rules, one rule, and multiple rules) for this TriggerPoint to FilteringStrategy.ACCEPT_ONE. This strategy throws an exception if the number of rules is not one.
Clients may implement their own filtering strategies to filter rules using a custom
algorithm. This may be done by creating a class that implements the FilteringStrategy
interface and providing an implementation for the filterRules
method.
Note that, since the filtering 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
FilteringStrategy implementation must implement the Serializable interface.
Field Summary | |
---|---|
static FilteringStrategy |
ACCEPT_ANY
Accepts any number of rules which are found and returns them unmodified. |
static FilteringStrategy |
ACCEPT_FIRST
Returns only the first rule which is given; if zero rules are given, throws a NoRulesFoundException. |
static FilteringStrategy |
ACCEPT_LAST
Returns only the last rule which is given; if zero rules are given, throws a NoRulesFoundException. |
static FilteringStrategy |
ACCEPT_ONE
Ensures that there is exactly one rule which is found. |
Method Summary | |
---|---|
IRule[] |
filterRules(TriggerPoint tp,
IRule[] rules)
Filter out the rules which should not be fired and returns an array containing only rules that should be fired. |
Field Detail |
public static final FilteringStrategy ACCEPT_ANY
public static final FilteringStrategy ACCEPT_FIRST
public static final FilteringStrategy ACCEPT_LAST
public static final FilteringStrategy ACCEPT_ONE
Method Detail |
public IRule[] filterRules(TriggerPoint tp, IRule[] rules) throws BusinessRuleBeansException
tp
- the trigger point which is used to make this callrules
- a list of rules, possibly empty, which this method can modify and return; will not
be null
BusinessRuleBeansException
- if any exceptions occur
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |