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

Chapter 2. Basic Rules

In this chapter, we'll start writing our first set of rules in Drools. We'll go through some basics needed to write and execute rules. We'll learn the necessary keywords of the Drools rule language.

But before all this, we'll have to set up our development environment. If you haven't already done so, please refer to Appendix A on development environment setup.

Rule basics

We'll now write our first Drools rule. Let's say that we have an Account bean that has one property called balance. For every Account bean, in which the balance is less than 100, we'll write a message to the standard output as follows:

package droolsbook; rule "basic rule" when Account( balance < 100 ) // condition then System.out.println("Account balance is ...

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