DROOLS takes a forward chaining approach e.g. rather than asking questions and infering facts it (Is it raining? You need an umbrella! It can just state "You need an umbrella"). It does this by implementing a Rete algorithm.
A Rule in DROOLS is described in XML and must have constraints on the Left Hand Side and actions on the right.
For example (taken from the DROOLS 1 minute tutorial)
< rule-set name="cheese rules"
xmlns="http://drools.org/rules"
xmlns:java="http://drools.org/semantics/java"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:schemaLocation="http://drools.org/rules rules.xsd
http://drools.org/semantics/java java.xsd" >
< rule name="Bob Likes Cheese" >
< parameter identifier="bob" >
< class > org.drools.examples.simple.Bob < /class >
< /parameter >
< java:condition > bob.likesCheese() == true < /java:condition >
< java:consequence >
System.out.println( "Bob likes cheese." );
< /java:consequence >
< /rule >
< /rule-set >
In this example we state that for an instance of the Class Bob where the
likesCheese() returns true the Java code System.out.println("Likes
cheese") is executed.
This is clearly very powerful. We could envisage a situation where, say, a complex graph of objects that
represent the state of an Applicant was sent to a Java program.
The business rules that express the services for which that applicant was elligable
(e.g. Applicant is 21, lives in wales and is a housholder and not a current customer return houshold insurance products
with new customer and low crime discounts) could be expressed as a number of rules and when each one fires a
method on a business component is executed with a resultant set of appropriate products added to the object graph
for return to a client system.