• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

A design question

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a query on a design question.
The requirement is as follows:
I have to develop a generic rule service. My application has list of possible rules as components (say Rule1, Rule2, Rule3, Rule4, Rule5, Rule6, Rule7 and so on). Based on user input I have to trigger one or more of these rules. e.g
If input=1 then trigger Rule1, Rule2, Rule3
If input=2 then trigger Rule1, Rule2, Rule4
If input=3 then trigger Rule1, Rule2
If input=4 then trigger Rule5, Rule6, Rule7
and so on.
I have designed all rules to be implementing same interface(say RuleInterface).
RuleInterface has a single method as follows - execute()
My design approach is as follows:

Develop a RuleProcessor
which will have a attribute - Collection<Rule> ruleCollection
and a method process(int input) which will iterate each rule from rules and execute it.

My query is how do I design the set-up of ruleCollection attribute.One design I could think of is to populate all rules combination in DB and then use it to populate the ruleCollection attribute. Thus given above requirement, we will have 4 entries in DB (one for each input value). Is there a better and simple design possible(I am sure there is). I am tending to look at a design solution which is java based (and not necessarily dependent on DB) but am open to all the suggestions. I am using spring framework so if spring provides something out of the box then I would prefer that.

Thanks,
 
Pankaj Kumarkk
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can somebody please help on this. I would greatly appreciate this.

Thanks,
Pankaj
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want user-designable decision logic (instead of logic that's permanently hard-coded in an app), you should look at one of the rule-based frameworks. One of the most famous such frameworks is Drools, which is now part of the JBoss project.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic