Add a comment


Re: A really simple but powerful rule engine

I'm not quite sure what you mean by "composite rule", but if you look at the first listing in this article, it creates a "composite" rule using the first two rules:

Rule r1 = new Rule("YouthTarif", "input.person.age < 26", "YT2011", 3, "tarifs", null);
Rule r2 = new Rule("SeniorTarif", "input.person.age > 59", "ST2011", 3, "tarifs", null);
Rule r3 = new Rule("DefaultTarif", "!#YouthTarif && !#SeniorTarif", "DT2011", 3, "tarifs", null);

You can see that rule 3 is made up of the first two.

As for externalising to the database, I don't really understand what you are asking. We have successfully done it like this:

1) insert rules into database using scripts or a fancy home grown admin UI
2) at application startup, or whenever rules are modified in the database, read all the rules out of the database
3) for each rule that you read from the database, create a Rule object (as I just showed above) and pass all those rule objects to the rule engine constructor. (replace any instances of rule engines in your application with new instances)

Does that help?

Re: A really simple but powerful rule engine

HTML : b, strong, i, em, blockquote, br, p, pre, a href="", ul, ol, li, sub, sup
E-mail address
Remember me Yes  No 

E-mail addresses are not publicly displayed, so please only leave your e-mail address if you would like to be notified when new comments are added to this blog entry (you can opt-out later).