[rules-users] Question About Programmatically Creating Drools Rules Remotely

nanic23 nanic23 at hotmail.com
Wed Mar 17 11:32:19 EDT 2010


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-Rules-Remotely-tp452619p453503.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list