-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rules engine listener #121
Comments
Hi, Yes the rule listener is executed per rule. What do you mean an API per execution? Could you please give an example? Kr |
I am in the process of implementing coupon campaigns. I would like to query database coupons before evaluations starting. I will pass them to rules as a fact. Specifically I need some hooks in BTW I had implemented a custom RulesEngine but It might be something wrong. I wanted to discuss as well. What is the best place to fetch some data for rules? |
Thank you for the example, I see now. Basically you are looking for something like a public interface RulesEngineListener {
void beforeFiringRules(Rules rules, Facts facts);
void afterFiringRules(Rules rules, Facts facts);
} With this listener, you can add custom behaviour before/after firing the whole rule set. Is this correct? I want to make sure I correctly understand your request.
The best place would be in the |
Yeah exactly :) By the way I had added almost same class :)
But |
ok cool. But in hindsight, do we really need such a listener? What would be the added value compared to something like: Data data = .. // fetch data before rule set execution
facts.put("data", data);
rulesEngine.fire(rules, facts);
// check facts after rule set execution The |
I will have some modules which will encapsulated all logic. Such an interface will be a contract between modules and core logic. |
That makes perfect sense. The interface actually has some benefits:
So let me plan this for next release! Thank you for this suggestion! Kr, |
This commit is nice. The code reside in easy-rules/easy-rules-core/src/main/java/org/jeasy/rules/core/DefaultRulesEngine.java Lines 101 to 109 in 42251de
apply method, you can just use fire method. This will be nice since we can delegate in this case to default implementation.
|
yes that was coming 😄 I was planning to add a I will deploy v3.1 snapshot and keep you posted. |
tested. |
Great! thank you for your time! |
I would like to fetch some data from database and pass into per rule. I noticed that there is
RuleListener
but it seems it is triggered per rule. I think that an API for per execution.The text was updated successfully, but these errors were encountered: