O'Reilly logo

Drools JBoss Rules 5.0 Developer's Guide by Michal Bali, Bogdan Brinzarea

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Rule syntax

The following section will provide more details on rule (.drl) syntax. It will form the basis for later examples.

Rule concepts

A rule can contain many conditions/patterns. For example:

Account( balance == 200 )
Customer( name == "John" )

Code listing 5: Two rule conditions, one for type Account and one for type Customer.

Drools will then try to match every Account in the session in which the balance is equal to 200 with every Customer whose name is John. If we have three Account objects that meet this criteria and two that don't, and five Customer objects that meet this criteria and three that don't, it would create (3+2)*(5+3)=40 possible matches. However, only 3*5=15 of them would be valid. This means that a rule with these two conditions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required