如何在drl文件中访问ResourceBundle?

时间:2013-11-26 09:36:09

标签: java drools resourcebundle

我正在尝试在.drl文件中使用ResourceBundle。但它抛出一个像

这样的例外
`java.util.MissingResourceException: Can't find bundle for base name messages,     locale en_US.`

我的代码如下

public class KnowledgeHelper {

@BeforeClass
public static KnowledgeBase getKnowledgeBase() throws Exception {
    KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    String droolsRuleFilePath = System.getenv("JBOSS_HOME") + "/pp-Conf/rules/Validator.drl";
    builder.add(ResourceFactory.newFileResource(droolsRuleFilePath), ResourceType.DRL);
    if (builder.hasErrors()) {
        throw new RuntimeException(builder.getErrors().toString());
    }

    KnowledgeBaseConfiguration configuration = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
    KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(configuration);
    knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages());
    return knowledgeBase;
}

我正在访问此帮助程序类以生成知识库

我正在我的控制器类中创建知识会话,如下所示

knowledgeBase=knowledgeHelper.getKnowledgeBase();
        knowledgeSession = knowledgeBase.newStatefulKnowledgeSession();
        knowledgeSession.insert(olmvo);
        knowledgeSession.insert(validationResponse1);
        knowledgeSession.fireAllRules();

我的drl文件如下

rule "OLM_PRODUCTION_VALIDATOR"

when
   $olm : OLMVO(workflow.code == "OLM_PRODUCTION" ,workflow_type : workflow.processKey)
   $validationResponse : ValidationResponse() 
then
    System.out.println("MESSAGE FILE-----"+EdgeAppConstant.EDGE_APP_MESSAGES_FILE);
    ResourceBundle edgeappErrorBundle = ResourceBundle.getBundle(EdgeAppConstant.EDGE_APP_MESSAGES_FILE);
    System.out.println("Workflow Type-----"+workflow_type);
end

我已经导入了我在这个drl中使用的所有类。

所以我想知道如何直接在.drl文件中访问属性文件。 请帮忙!!

0 个答案:

没有答案