java代码访问drools guvnor

时间:2011-05-12 10:32:42

标签: java drools

我们有一个项目要求通过Web应用程序访问guvnor。任何人都可以通过java代码告诉我如何访问guvnor吗?

2 个答案:

答案 0 :(得分:5)

抵押贷款示例已经有一些示例代码。 Drools Expert手册可能会详细解释它。 这是代码:

private static KnowledgeBase readKnowledgeBase() throws Exception {
    KnowledgeAgent kagent = KnowledgeAgentFactory
            .newKnowledgeAgent( "MortgageAgent" );
    kagent.applyChangeSet( ResourceFactory
            .newClassPathResource( "changeset.xml" ) );
    KnowledgeBase kbase = kagent.getKnowledgeBase();
    kagent.dispose();
    return kbase;
}

<?xml version="1.0" encoding="UTF-8"?>
<change-set xmlns='http://drools.org/drools-5.0/change-set'
    xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
    xs:schemaLocation='http://drools.org/drools-5.0/change-set drools-change-set-5.0.xsd'>
  <add>
    <resource
  source='http://localhost:8080/guvnor-webapp/org.drools.guvnor.Guvnor/package/mortgages/LATEST'
  type='PKG' basicAuthentication='enabled' username='admin' password='admin' />

  </add>
</change-set>

答案 1 :(得分:0)

我们应该在Guvnor参考手册中记录。这是the issue