繁体   English   中英

是否可以在Drools中不公开规则?

[英]Is it possible to unexpose a Rule in Drools?

假设我有这样的流口水档案,

rule "Test Rule 1"
salience 10

when
    $data : Map( this["amount"] >= 1000 && this["quantity"] >=3 )
then
    System.out.println("You've met the Criteria");
end

===========================================================================================

rule "Test Rule 2"
salience 9

when
    $data : Map( this["amount"] >= 1000 )
then
    System.out.println("Quantity Criteria is not met");
end

===========================================================================================

rule "Test Rule 3"
salience 8

when
    $data : Map( this["quantity"] >= 3 )
then
    System.out.println("Amount criteria is not met");
end

所有这些都将存在于单个.drl文件中。 就像规则中一样,规则的顺序将基于最高显着性数。 我需要类似的东西

1)如果满足Test Rule 1 ,我不希望执行其他规则。

2)如果不满足Test Rule 1 ,那么我不必担心,它会按照最高显着性的顺序执行其他规则。

是否有诸如hideRule("Test Rule 2", "Test Rule 3")hideRules() - which should unexpose rules waiting to be executed

我知道我可以更改何时满足我的条件,但是我想知道在Drools中是否有不unexpose规则的选项?

添加drools.halt(); Test Rule 1的末尾

激活组将解决此问题:

激活组是由相同的“激活组”规则属性绑定在一起的一组规则。 在该组中,只有一个规则可以触发,并且在该规则触发后,所有其他规则都将从议程中删除。 可以随时调用clear()方法,该方法会在有机会触发之前取消所有激活。

activation-group "groupName"添加到每个规则中应该会产生预期的行为。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM