Jonathan Spickernell
Jonathan Spickernell

Reputation: 162

Create a drool to list all rules within other drools

basically i was wondering if there is a way to run something and it would go into every drools file in the directory's under it (in a folder with say 50 folders in there, would go into each folder.) and pull certain data from these files So i run it, it access lets say 10 .DRLs each with 5 rules inside that have a name rule "blah blah" and a logger.info line. among what the rule actually does.

Could something be written to go into all these files and create a list of each filename, then under that all rule names and logger lines?

We have roughly 500 .drl files each with anything from 1 to 100 rules within these files. manually creating a list of what we have in place for each file, would take alot of time :)

Upvotes: 0

Views: 921

Answers (1)

melchoir55
melchoir55

Reputation: 7276

Drools can do this, but I don't think it is the tool you would want to employ. Drools is for modeling business logic. You aren't really doing that here. You could pull the data manually using notepad++, grep, emacs, or other mass text manipulation tools. I wouldn't really recommend that either.

The best tool for this task is probably going to be a script written in python or ruby. Ruby being the one I would pick in this instance for its better integration of regular expressions. Once you have this script you can extract this data at will in the future. Scripts are re-usable and extendable. This makes them a better choice than the hack and slash of mass text editors if you expect you will need this information or information like it on a regular basis.

If one of your requirements is that this task occur whenever your drools fire then it might be easier to do this text processing in Java. You would probably want to have Java do the work before or after the fireAllRules event depending on your requirements.

Finally, drools does actually know quite a bit about itself. You could conceivably ask drools for a lot of this information when it runs. I have never done this myself. When I had to tackle a task like the one you describe, I used a script.

Upvotes: 1

Related Questions