[rules-users] Pass Parameter to drools file dynamically

Richa rsinha2889 at gmail.com
Fri Mar 15 02:28:32 EDT 2013


I created a fact type in my code but I am getting exceptions: 

declare Airline
 name:String
end

and this is the java code that I am using.

DroolsXPathEvaluatorFactory evaluatorFactory=new
DroolsXPathEvaluatorFactory();

evaluatorFactory.setPackageStream(TestMain.class.getResourceAsStream("rule1.drl"));
	
	KnowledgeBase kbase=KnowledgeBaseFactory.newKnowledgeBase();
	FactType airlineType=kbase.getFactType("droolshelloworld", "Airline");
	Object ob=airlineType.newInstance();
	airlineType.set(ob, "name", "//Airline");
	StatefulSession
ksession=evaluatorFactory.getRuleBase().newStatefulSession(true);
	ksession.insert(ob);
	ksession.fireAllRules();
	
	XPathEvaluator evaluator=evaluatorFactory.create();
	evaluator.evaluate(TestMain.class.getResourceAsStream("test.xml"));

This is giving me exception. Please tell me what am I doing wrong here?




--
View this message in context: http://drools.46999.n3.nabble.com/Pass-Parameter-to-drools-file-dynamically-tp4022820p4022832.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list