I created a package in Guvnor and uploaded a ruleflow. You can also deploy
the rulflow to Guvnor through Eclipse plugin.
Then build the package in guvnor. You'll see this option by clicking in the
package you have your ruleflow.
Once it builds correctly you can consume this by doing the following:
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
try {
kbuilder.add( ResourceFactory.newUrlResource(
"http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/default/LATEST"),
ResourceType.PKG );
for ( KnowledgeBuilderError error: kbuilder.getErrors() ) {
System.out.println(error);
}
knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
knowledgeBase.addKnowledgePackages( kbuilder.getKnowledgePackages()
);
} catch (Throwable t) {
System.out.println(t.toString());
}
My package is named "default" but you can name it whatever you want. Note
that you have to use ResourceFactory.newUrlResource() and passed the URL
(Guvnor also provides you with the URL to your package) and declare type as
ResourceType.PKG.
This is working for me....
--
View this message in context:
http://n3.nabble.com/Question-About-Programmatically-Creating-Drools-Rule...
Sent from the Drools - User mailing list archive at
Nabble.com.