ALTERthought Blogs

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

Installation

grails install-plugin drools

Usage

Components

DroolsService
droolsService.fireRules(resource, ruleKey, objList)

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: , , ,

Post to Twitter Post to Delicious Post to Digg Post to Reddit

3 Comments currently posted.

Katharyn Kuruvilla says:

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.

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.

Post a comment on this entry: