Alex Rivera | Logout

I need a simple rules engine, I think?

Asked 2010-12-01T22:36:22.980
20

I need some advice on the best approach to solving this problem.

I've researched DROOLS, Java Rule Engine and a few others. All of these are powerful, and have good things about them. I don't know which (if any) will be the best choice for me.

I have one business object. (simplified for demo)

Person
     firstName:String
     lastName:String
     departMent:String
     hireDate:Date

I need to write an editor in a web application that will allow for complex rules to be built around these fields. I need to support complex nested AND/OR logic. I just need basic operators, and the rule should simply evaluate to true or false. If the rule evaluates to true or false, one action will occur respectively.

For example,

firstName CONTAINS "value" AND (lastName EQUALS "input" OR department CONTAINS "input")

I had thought, maybe I should just write my own parser and evaluate the logic in my own code. I don't know what to do, any advice or links to something to read would be greatly appreciated. Is there a specific design pattern I could research?

How would you solve this problem? One reservations about the rules engines is that maybe they are too complex for just a simple problem?

Edit
Report

1 Answer

0

Wouldn't Jython be usefull?

Each expression/complex-rule could be the body of a function. So the user provides the body, and your code puts the function spec around it, and then execute it.

You can also put any Java objects / variables of your own into the jython context to be used in your script/ function body.

Then you have a standardized, extendable widely used language at your fingertips. But i think the Jython editor could be a challenge.

answered 2010-12-02T08:35:41.157

Your Answer