- A default constructor
The class must have a default, no argument
constructor so that it can be instantiated when a rule using it is triggered.
- init
This method comes from the RuleImplementor
interface
and is called when the rule implementor is first instantiated. Its purpose
is to perform an initialization needed by the rule implementor instance before
it is actually fired. The following parameters are passed to the init
method:
- The initialization parameters defined for the rule being triggered. These
can be any parameters needed to properly initialize the rule implementor instance.
Often the initialization parameters consist of constants required by the
algorithm. For example, when using a rule implementor that checks whether
a number is greater than a threshold value, the threshold value would normally
be passed as an initialization parameter. This will be null if there are
no initialization parameters for the rule.
- An array of names of dependent rules for the rule being triggered.
Normally the rule implementor should store these to be used when the
fire
method
is called. These depenent rules are intended to be triggered as part of the
algorithm performed by the rule implementor. Refer to Dependent
Rules for more information. This will be null if there are no dependent
rules defined for the rule.
- The user-defined data for the rule being triggered. This data
is completely defined by the user of BRBeans. BRBeans does not interpret
this data in any way. This will be null if there is no user-defined data
defined for the rule.
- A reference to the actual rule being triggered. This can be used
to extract attribute values from the rule, if needed.
- fire
This comes from the RuleImplementor
interface.
This method is called to actually perform the algorithm of the rule implementor.
Any desired algorithm can be performed here. Normally some value is returned
by the fire
method. This value is ultimately returned as the
result of triggering the rule. The following parameters are passed to the
fire method:
- The TriggerPoint object which is being used to trigger the rule.
This is needed if the rule has dependent rules that the fire method needs
to trigger.
- The target object for this particular trigger call. This can be
any object that can be thought of as the target of the rule. This may be
null.
- A reference to the actual rule being triggered. This can be used
to extract attribute values from the rule, if needed.
- The firing parameters for this particular trigger call. Normally
these are the firing parameters passed by the code invoking the trigger point.
However, these can be overridden by specifying firing parameters on the rule
itself. Wherever they ultimately come from, these are the parameters that
the rule implementor needs at runtime to perform its function. Normally these
will be runtime variables that are to be processed in some fashion by the
rule implementor. For example, when using a rule implementor that checks
whether a number is greater than a threshold value, the number to be checked
would normally be passed as a firing parameter. This will be null if no firing
parameters are passed by the caller and none are defined on the rule itself.
- getDescription
This comes from the RuleImplementor
interface.
The purpose of this method is to return a text string that describes the
function of the rule implementor. This could be used, for example, to display
on a user interface to help a user select what implementor to use. This method
is currently not used by the BRBeans framework.