3 August 2008
Drools Plugin for Grails Application
I have just released a Grails Plugin for Drools. The plugin details can also be found at http://www.grails.org/Drools+Plugin.
Drools is a business rule management system (BRMS) and an enhanced Rules Engine implementation, ReteOO, based on Charles Forgy’s Rete algorithm tailored for the Java language.
Features
- Easy implementation of Drools
- Rules can be stored in file or in database
- Rules can be dynamically changed without rebuilding or restarting application
Installation
grails install-plugin drools
Usage
- Install the plugin
- Verify example rules:
http://localhost:8080/your_app/drools/example
- Create your own rules: http://localhost:8080/your_app/drools and use droolsService in your code
Components
- DroolsController: Provides CRUD functionality for Drools Rule
- DroolsService: Fires all rules
DroolsService
droolsService.fireRules(resource, ruleKey, objList)
- resource: specifies where the rules are stored. ‘file’ or ‘db’
- ruleKey: identifier for the rule. For ‘file’ resource, this would be the name of the file (eg:ticket_example.drl). For ‘db’ resource, this is the Drools Rule key
- objList: list of objects that need to be put in session
Example
A simple Ticket processing system is available in the plugin. This example shows how tickets are processed based on their subscription plan.
Run the example: http://localhost:8080/your_app/drools/example
Your console output should be:
Start processing Ticket # 3 Start processing Ticket # 2 Start processing Ticket # 1 Firing rule Bronze Priority for Ticket # 3 Firing rule Silver Priority for Ticket # 2 Firing rule Gold Priority for Ticket # 1 Firing rule Special Discount for Ticket # 1
Display on your browser should be:
Tickets due for processing: Ticket #1: Customer[Name:Jack, Subscription:Gold, Discount:0%] Status[New] Ticket #2: Customer[Name:Tom, Subscription:Silver, Discount:0%] Status[New] Ticket #3: Customer[Name:Bill, Subscription:Bronze, Discount:0%] Status[New] Firing rules now ... Tickets after processing: Ticket #1: Customer[Name:Jack, Subscription:Gold, Discount:5%] Status[Escalate] Ticket #2: Customer[Name:Tom, Subscription:Silver, Discount:0%] Status[Escalate] Ticket #3: Customer[Name:Bill, Subscription:Bronze, Discount:0%] Status[Pending]
Note: This post was originally posted in the author’s blog
Technorati Tags: Grails, Grail Plugin, Drools for Grails, Drools Plugin
3 Comments currently posted.
Katharyn Kuruvilla says:
ugg boots uk says:
I love this post, enjoyed this one regards for posting .
recommended acting classes says:
You are correct; we dont care as long as you leave us alone too. The problem is that you and many others like you insist that you are the special ones and that everyone else must give you the recognition of being special. Sorry, aint going to happen! What makes you special since you obviously have the wrong ideas about what sex is all about? If you are wrong about that as many have tried to tell you then what else are you wrong about? You are certainly wrong about being special. At best you are no better than anyone else. But you can prove you are less than others by being worse than they are.


Something more important is that when searching for a good on the net electronics shop, look for online shops that are frequently updated, preserving up-to-date with the latest products, the most beneficial deals, and also helpful information on services and products. This will ensure you are getting through a shop which stays on top of the competition and offers you what you should need to make intelligent, well-informed electronics expenditures. Thanks for the important tips I’ve learned from your blog.