Thursday, June 16, 2011

View Drools Generated Code

When we execute rules, behind the scene java code is generated which is actually getting executed, to see this java code you need to set configuration path where you want java code generated by drools to be stored.

PackageBuilderConfiguration configuration = new PackageBuilderConfiguration();
configuration.setDumpDir(new File("XYZ"));

final KnowledgeBuilder kbuilder = KnowledgeBuilderFactory

Set XYZ as a directory path where you would like drools to store generated code. e.g. XYZ = "c:/drools/codegen"

When you run your program the java classes generated for the .drl files are stored at the path XYZ.

This generated code is really helpful to understand the behavior in lot of situations.

1 comment:

  1. Awesome Sir. This helped me view the Java code generated for our DRLs. Thanks a million!


Java 9 Collection Changes Overview

Introduction Java 9 finally brings the convenience of creating small unmodifiable Collection instances using just one line code. New APIs...