Rule implementors

A rule implementor, in terms of Business Rule Beans, is an algorithm written in Java that implements the BRBeans RuleImplementor interface.

A Business Rule Beans (BRBeans) Rule is a persistent object that exists on the BRBeans Rule server. One of the rule's persistent attributes, in addition to startDate, endDate, initParams, and so on, is javaRuleImplementorName, which is the name of its rule implementor.

BRBeans supplies a number of predefined rule implementor classes that can be used in user-defined BRBeans rules (see the BRBeans Javadoc ) to implement the BRBeans RuleImplementor Interface. The Java source code for these rule implementors is supplied as BRBeans sample code in the com.ibm.websphere.brb.implementor package. This sample code, packaged in a JAR file, appears in the CLASSPATH of the BRBeans Rule Server (for "remote" firing) or is co-located in the CLASSPATH of the application or applications using it (for "local" firing). Typically, the RuleImplementor is in the application EAR file.

Using standard Java development tools, you can externalize BRBeans by attaching them to either enterprise beans or ordinary Java objects. Programming a new rule implementation in Java is typically a simple process. If you write your own rule implementor, you must create a new Java class that implements the com.ibm.websphere.brb.RuleImplementor interface. This class must implement the following methods:

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
The init method comes from the RuleImplementor interface and is called when the rule implementor is first. 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 normally is passed as an initialization parameter. This parameter is 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 stores these names to be used when the fire method is called. These dependent rules are intended to be triggered as part of the algorithm performed by the rule implementor. See Dependent Rules for more information. This parameter is 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 the Business Rule Beans (BRBeans). BRBeans does not interpret this data in any way. This parameter is 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
The fire method comes from the RuleImplementor interface. This method is called to perform the algorithm of the rule implementor. Any desired algorithm can be performed here. Normally, a value is returned by the fire method that is ultimately returned as the result of triggering the rule. The following parameters are passed to the fire method:
The TriggerPoint object that is being used to trigger the rule
This parameter is needed if the rule has dependent rules that the fire method needs to trigger.
The target object for this particular trigger call
This parameter can be any object that is thought of as the target of the rule. However, the parameter can be null.
A reference to the actual rule being triggered
This parameter can be used to extract attribute values from the rule, if needed.
The firing parameters for this particular trigger call
Normally, these parameters are the firing parameters passed by the code that invoke 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 run time to perform its function. Normally, these are run-time variables that are to be processed 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 normally is passed as a firing parameter. This parameter is null if no firing parameters are passed by the caller and none are defined on the rule itself.
getDescription
getDescription 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 information might be displayed on a user interface to help select what implementor to use. This method, however, is currently not used by the BRBeans framework. Users can incorporate this information if they create their own rule implementor. For additional information, see the BRBeans Javadoc for the RuleImplementor interface.


Related concepts
Overview of Business Rule Beans
Dependent rules



Searchable topic ID:   cbrb_rulimp
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/brb/concepts/cbrb_rulimp.html

Library | Support | Terms of Use | Feedback