Writing and executing our first rule
Now that we have our project structure ready, we can write our first rule. For that, we will create a new empty text file. This will be a static resource, therefore, we need to place it in the src/main/resources
directory. This text file needs to have the .drl
extension so that it can be picked up as a rule file. In the .drl
files, we will write as many rules as we want. Now, we will start easy with just one rule.
Let's write our first rule to classify the items based on what they cost us. Our rules.drl
text file will look similar to the following:
package myfirstproject.rules import org.drools.devguide.eshop.model.Item; import org.drools.devguide.eshop.model.Item.Category; rule "Classify Item - Low Range" ...
Get Mastering JBoss Drools 6 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.