Drools Expert
Drools Expert is a declarative, rule based, coding environment. This allows you to focus on "what it is you want to do", and not the "how to do this".
The following is a simple "reactive" monitoring example, that sends a message every for hours when the alarm is raised. The calendar attribute ensures the rule only executes on weekdays. Monitoring examples like this would be a long running application.
rule "Weekday Alarm Response" timer(int 4h) calendar "weekday" when
a : Alarm( )
then
sendMessage( "There is an alert" + a);
end
Here is another example showing the processing of driving license application. The example disqalifies any applicant who is not 18 or older. Data processing examples like this would be consider short running applications.
rule "Person must be over 18 for Driving License" when
$a : Application( person.age < 18 )
then
modify( $a ) { valid = false } end
Declarative rule based approaches are suitable for a wide variety of problems, even games, as shown in the following two recommended videos. Remember to select "720" setting in youtube, for best quality.
Build Pong in 13 minutes with JBoss Drools
Build a graphical adventure game in 20 minutes with JBoss Drools
Here are some more examples of code snippets:
Person(age > 30 && < 40 || hair == "black")
---
Person(pets["rover"].type == "dog")
---
forall(Bus (color=="red"))
---
$owner : Person( name == "mark" ) Pet( name == "rover" ) from $owner.pets
---
$zipCode : ZipCode() Person( ) from $hbn.getNamedQuery("Find People") .setParameters( [ "zipCode" : $zipCode ] )
.list()
---
accumulate( bus : Bus( color == "red" ); s : sum( bus.takings ); s > 100 )
---
zipCode : ZipCode()
accumulate( bus : Bus( color == "red") from $hbn.getNamedQuery("Find Buses") .setParameters( [ "zipCode", zipCode ] )
.list();
s : sum( but.takings );
s > 100 )
|
Eclipse authoring with DSL code completion |
|
Side by side ruleflow authoring with rules |
|
Interactive Debugging |
|
Guided Editor |
|
Decision Tables |
