-
Notifications
You must be signed in to change notification settings - Fork 1.1k
defining rules engine listener
Mahmoud Ben Hassine edited this page Dec 18, 2017
·
4 revisions
You can listen to rules engine execution events through the RulesEngineListener API:
/**
* A listener for rules engine execution events.
*
* @author Mahmoud Ben Hassine ([email protected])
*/
public interface RulesEngineListener {
/**
* Triggered before evaluating the rule set.
* <strong>When this listener is used with a {@link InferenceRulesEngine}, this method will be triggered before the evaluation of each candidate rule set in each iteration.</strong>
*
* @param rules to fire
* @param facts present before firing rules
*/
void beforeEvaluate(Rules rules, Facts facts);
/**
* Triggered after executing the rule set
* <strong>When this listener is used with a {@link InferenceRulesEngine}, this method will be triggered after the execution of each candidate rule set in each iteration.</strong>
*
* @param rules fired
* @param facts present after firing rules
*/
void afterExecute(Rules rules, Facts facts);
}You can implement this interface to provide custom behavior to execute before/after firing the whole rule set. To register your listener, use the following snippet:
DefaultRulesEngine rulesEngine = new DefaultRulesEngine();
rulesEngine.registerRulesEngineListener(myRulesEngineListener);You can register as many listeners as you want, they will be executed in their registration order.
Easy Rules is created by Mahmoud Ben Hassine with the help of some awesome contributors
-
Introduction
-
User guide
-
Tutorials
-
Get involved