deliveredtechnologies / rulebook

100% Java, Lambda Enabled, Lightweight Rules Engine with a Simple and Intuitive DSL
http://www.deliveredtechnologies.com
Apache License 2.0
717 stars 124 forks source link

Rule wiring at build time via annotation processing #119

Closed cactus818 closed 5 years ago

cactus818 commented 6 years ago

Currently package scanning is performed at runtime which has pros and cons. It is probably more robust and safer to wire the logic at build time. The idea: have an annotation processor similar to the RuleBookRunner that looks for @Rule annotated classes and groups them into rulebooks according to the packages they're found in. A registry would then permit to retrieve the fully wired rule books. This is a little less dynamic than the runtime scanning, but has the huge benefit to not depend at all on JAR formats etc. It's as robust as plain Java.

Clayton7510 commented 6 years ago

Hmm... that's an interesting idea. I don't think I would want to change or remove the ability to have RuleBooks built at runtime. And there are many reasons for this - it uses a similar approach to Spring's component scanning, which is what many people are used to and the implementation is of POJO rules is really just an adapter, which makes it relatively simple.

However, I could see having an option (or a different kind of POJO RuleBook) that built the rules differently. I think that could work.