I have previously written JBoss Drools – an Initial Study.
Now as I thought of showing an example of drool project, I am directing showing coding related to this.
As I thought, the related libraries are necessary for the project, I am showing the image for this in a Dynamic Web Project in eclipse.
Please take all the jars as specified in the project.
Now for example working purpose I have created one servlet which actually validate the orders via drool file.
The drool file is -
So pass and fail rule is created here.
After this, I am showing the codebase related to Drool Validation code in Servlet -
I have placed drools related configuration in an other file – Droolsinitialiser.java and used stateless drool object -
So these codes are self-explanatory. For any better help, I am attaching the source files with the eclipse project for DroolWebProject. For space crunch, the library jars are not included here.
This project can be tested in Tomcat 7.
After rule change in .drl file, we need no new deployment, but re-staring of tomcat to take the effect of rule change.
This is an drool infrastructure ready codebase to start with drools. Any comments and suggestions related to Drool rules related project are welcome.