alexeypro
alexeypro

Reputation: 3673

Business rules Java app for User

The description may sound like just a bunch of words so here is a more detailed explanation. I have a User object which is mapped to database table. I want users to be in different roles. There will be a bunch of those - and they technically will be the same users in same table but to them will apply different roles. Say user in role A will have to have two fields as required, and will have to have certain restrictions to the length and contents on his password, as well as the time expiration of his password, etc.

While I can hardcore those rules I am very interested to find out of there is an other way to define the rules and may be store in database so it's easier to load/apply and the main idea - to change and update them -- without redeploying the codebase.

Technically the stupidest and straightforward solution is to implement class, serialized, store in db, then load, deserialze, call methods on it which will execute rules. The problem is in changes to the ruleset ( read "interface" of the rule class ) and that generally solution sounds like a hack.

Anytihing else? Any frameworks? Other approaches?

UPDATE: probably was not clear. say, I have class User.java I need to define different rules say: 1. do we need to verify length of password, and what should it be? 2. do we need to require some properties to be required? 3. do we need to track login attempts for this user? 4. if we do track, how many login attempts allowed? 5. do we expire password? 6. if we do, then in how many days? or months? or weeks? 7. ... and so on and so on. so questions ARE. - how do I define those rules and operate on User object WITHOUT modifying and redeploying code base? - how do I store those set of rules?

Drools, jBPM, etc. do not seem like a fit for that task. But any advice would help!

Upvotes: 0

Views: 398

Answers (2)

sashank
sashank

Reputation: 1541

JRuleengine is good I heard, sometime back I planned to use it for similar application.

There are many other Rule Engines though.

Upvotes: 1

Androider
Androider

Reputation: 21335

Well there are some good rules engines out there include jrules, drools I think is popular too. One thing to keep in mind is the relationship between a rule and the data it examines. After all you can have the rules in a word document, but when they execute they need examine data, and that is also a factor in choosing a rule engine or architecture. generally its if (a > b) then do y. Means you need to examine a and b in the rule execution. That is the real issue is how to get the parameters into the rule and engine.

Upvotes: 0

Related Questions