jboss - Drools rules categorization -
i looking way categorize rules in drl files , determine category/ categories of rules fired.
i see drools guvnor documentation has categorization http://docs.jboss.org/drools/release/5.2.0.final/drools-guvnor-docs/html/ch03.html#d0e228. however, unclear me if metadata maintained guvnor or if part of drl file/ rules execution. have not been able find sample drl file category mentioned in it. and, way determine category/ categories of rules got fired.
i aware of activation-group doesn't quite fit need since once rule in activation-group fires other rules in group not evaluated.
thanks
the best way classify rules via metadata. metadata entry added rule:
rule metademo @meta2( 123 ) @meta3( foo ) @meta4( "foo" ) when...then...end
you access metadata via rule, obtained package or event:
for( rule rule: kpackage.getrules() ){ map<string,object> key2meta = rule.getmetadata(); for( map.entry<string,object> entry: key2meta.entryset() ){ system.out.print( " @" + entry.getkey() + "( " ); object value = entry.getvalue(); system.out.print( "[" + value.getclass().getsimplename() + "] " + value.tostring() ); system.out.println( " ) " ); } }
output:
@meta2( [integer] 123 ) @meta4( [string] foo ) @meta3( [string] foo )
there plan permit maps value might use
@meta7( foo = "foo", bar = "bar" )
this didn't work in 5.5, , never tried again.
Comments
Post a Comment