0
일부 처리를 위해 사용자 정의 함수에서 규칙 이름을 가져야한다는 요구 사항이 있습니다. 아래 코드는 내가 수행하려는 방법입니다. 이것이 직접 가능하지 않은 경우 대안이 있습니까? BTW 현재 우리가 사용 Drools가 5.6Drools 언제 또는 조건에서 ruleContext를 얻는가?
import org.drools.spi.KnowledgeHelper;
function boolean printRuleName(KnowledgeHelper context) {
System.out.println(context.getRule().getName());
return true;
}
// rule values at C15, header at C10
rule "MY_RULE_15"
salience 65521
when
k:StatefulKnowledgeSession(true == "true")
//context: KnowledgeHelper(true=="true")
m:Map(true == "true")
Map((printRuleName(kcontext) == "true")
then
System.out.println(kcontext.getRule().getName());
//this works in action
end
//Map((printRuleName(kcontext) == "true") this is causing null pointer exception, kcontext is not getting injected
응답 해 주셔서 감사합니다. 규칙의 이름을 매개 변수로 포함하는 문자열 리터럴을 작성해야 할 것입니다. 우리가 어떻게 할 수 있는지. – Praneeth
다음과 같은 메소드 호출 :'x ("y")' – laune