问题
We have a project requirement to access the guvnor through a web application .Can any one let me know how to access guvnor through java code ?
回答1:
The mortgage-example already has some example code. And the Drools Expert manual probably explains it in detail. Here's the code:
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>
回答2:
We should document that in the Guvnor reference manual. Here's the issue.
来源:https://stackoverflow.com/questions/5976677/java-code-to-access-drools-guvnor