首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

Drools规约执行顺序

2012-10-10 
Drools规则执行顺序以堆栈方式执行,优先级低的先入栈,同一优先级的,在规则文件中位置靠前的先入栈.测试1ru

Drools规则执行顺序
以堆栈方式执行,优先级低的先入栈,同一优先级的,在规则文件中位置靠前的先入栈.
测试1

rule "test first"    salience 0    no-loop false    when        $test: String( )    then         System.out.println($test);        insert("test second");endrule "test second"    salience -10    when        $test: String( )    then         System.out.println($test + " the 2nd");    insert("test three");end

测试1结果
testtest secondtest second the 2ndtest threetest three the 2ndtest the 2nd

测试2
rule "test first"    salience 0    no-loop false    when        $test: String( )    then         System.out.println($test);        insert("test second");endrule "test second"    salience 0    no-loop false    when        $test: String( )    then         System.out.println($test + " the 2nd");        insert("test three");end

测试2结果
test the 2ndtest three the 2ndtest threetest second the 2ndtest secondtest

同一互斥组下,优先级高的如果no-loop true,则,此规则内如果插入新对象,视本规则为不匹配,执行下一规则.
测试3
rule "test second"salience 0activation-group "show"no-loop truewhen$test: String( )then System.out.println($test);insert("test second");endrule "test first"salience 0activation-group "show"no-loop truewhen$test: String( )then System.out.println($test + " the 2nd");insert("test three");end

测试3结果
test the 2ndtest threetest second the 2nd

热点排行