General steps for implementing custom rule class
The general steps for implementing a custom risk firewall rule class are as follows:
1. Use com.apama.firewall.RuleClassFactory to create a com.apama.firewall.RuleClass object, which defines a number of actions.
2. Write implementations that override the default RuleClass actions. You are required to override either the evaluateRuleClassQuery() action or both the addRuleInstance() and evaluateRuleInstanceQuery() actions. You must also write implementations that override any other RuleClass actions your custom rule class requires.
3. If you override the RuleClass.addRuleInstance() action, you should
Check that the configuration of an instance of your custom rule class that an application is trying to add is valid.
Provide informative error messages if an instance of your custom rule class is missing a required parameter setting or has an invalid parameter setting.
4. If you override the RuleClass.evaluateRuleClassQuery() action or the RuleClass.evaluateRuleInstanceQuery() action, you should
Perform the custom logic that you created the rule for. You are provided with both the query request and the original configuration for the rule instance being evaluated.
Based on the results of your custom evaluation, construct a query response object that uses the query request identifier.
Call the provided completion callback with the query response.
5. Define the configuration schema for your custom rule class. The configuration schema specifies the parameters for evaluating an order against your custom rule. For each parameter, you can specify the parameter name, parameter type, default value, and a description.
6. Use the rule class object to register your custom rule class with one or more risk firewalls.
7. Add one or more instances of your custom rule class to each risk firewall with which you registered your custom rule class.
Best practice
The following are the recommended practices for implementing a custom rule class.
Encapsulate the logic of your custom rule class in an event.
In this event, define an
action type field named
create() that returns a
RuleClass object.
In your
create() action:
Instantiate the
com.apama.firewall.RuleClassFactory, and call
create() on this factory to obtain a
com.apama.firewall.RuleClass object.
Create and override each
RuleClass action required by your custom rule class.