deliveredtechnologies / rulebook

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

Can I make Spring aware non-POJO ruleBooks? #162

Closed victoraugustofd closed 5 years ago

victoraugustofd commented 5 years ago

Hi,

I'm trying to make a Spring Boot application that aware some custom books that I created. These books aren't POJO Rules, but the classes are inherited from CoRRuleBook, for example.

Is this possible? I have tried using SpringAwareRuleBookRunner, passing my package as parameter. My last try was to create a bean of RuleBookRunner type, passing my package as parameter, but it didn't work.

Thanks in advance.

Clayton7510 commented 5 years ago

You can create a RuleBook class that is annotated for Spring. POJO rules are just little more Spring-y by nature. You can also specify your own RuleBook bean in your Spring config. That would probably be the way to do it. Make sure you specify the bean name in your injections if you are just using an instance of CoRRuleBook so that you can correctly identify it.

SpringAwareRuleBookRunner is really for POJO rules. I suppose you could prewire a custom RuleBook and pass it into SpringAwareRuleBookRunner, but it really wouldn't buy you much. I assume you may have been trying to load your RuleBook with SpringAwareRuleBookRunner, which won't work. It will only load Rules.