开发者

How to define constant in jboss drools?

开发者 https://www.devze.com 2023-03-13 09:57 出处:网络
All 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.

All

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.

Thanks.


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);
}

In the rule, this global can be accessed via the 'global' keyword:

global String var;

rule "Test"
    when
        # actual condition 
    then
        # RHS
end
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号