[rules-users] typed dsl variables

Matt Geis mgeis at yahoo.com
Thu Sep 4 12:41:09 EDT 2008


Hi Pallav,
I just started a new gig, so I don't have my drools env all set up, but here are my suggestions to help you to really understand dsl's and build some powerful rules using them.

Quick, dirty, but you won't become a guru:
1.  Download Drools 5.
2.  Use the syntax for typed variables, and use regular expressions in your mapping file.  For example, 
[condition][]{varname:[a-zA-z0-9]+}\s+is\sa\s+Volume\s+where\s+....
3.  Keep in mind that dsl entries are expanded in a rule in the order they are declared in the DSL mapping file.

How to really learn it...
1.  D/L the source and build.
2.  Run your app, but run it through a debugger with breakpoint in the DefaultExpander class, so you can see exactly how pattern matching is going on, and step by step how your mappings transform your rule.  The rule below should have 3 mappings, the third one matching in two locations.


v1 is a Volume where status is "NV"  and sourceId is 2  and volume is
1000

Also, check the blog at http://blog.athico.com/2008/06/allowing-variable-masks-in-dsl-grammar.html, and on the mailing list.  I've posted several times in the last couple months on how to solve this very problem using typed DSL variables.

--Matt


      



More information about the rules-users mailing list