如何在jboss drools中定义常量? [英] How to define constant in jboss drools?
本文介绍了如何在jboss drools中定义常量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
全部
我想知道如何在jboss drools规则中定义内含变量。
I want to know that how to define contant variable in jboss drools rule.
所以,管理员只需更改一个地方即可修改可配置值。
So, Admin has to change only one place to modify the configurable value.
谢谢。
推荐答案
您可以在规则中定义全局变量。这个变量可以通过Java填充如下:
You´re able to define global variables within a rule. This variable can be filled via Java like this:
public void init() {
StatefulKnowledgeSession ksession = knowledgeBase.newStatefulKnowledgeSession();
String string = "foo";
// setGlobal 'string' as 'var' in rule
ksession.setGlobal("var", string);
}
在规则中,可以通过'global'关键字访问此全局:
In the rule, this global can be accessed via the 'global' keyword:
global String var;
rule "Test"
when
# actual condition
then
# RHS
end
这篇关于如何在jboss drools中定义常量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文