[rules-users] drools 4.0 compilation

fuadhamidov fuad.hamidov at tav.aero
Thu Aug 9 03:30:38 EDT 2007


ok, now final state of my code is as bellow. 
now my question is this: how do i define compositeConflictResolver to
RuleBase?


private static void runrule(CmsFlightServiceUsg usg) throws Exception {
	ConflictResolver[] conflictResolvers = new ConflictResolver[] {
			SalienceConflictResolver.getInstance(),
			ComplexityConflictResolver.getInstance(),
			FifoConflictResolver.getInstance() };
	CompositeConflictResolver compositeConflictResolver = new
CompositeConflictResolver(
			conflictResolvers);
	Package pkg = (Package) readSerializedObject();

	RuleBase ruleBase = RuleBaseFactory.newRuleBase();
	ruleBase.addPackage(pkg);
	WorkingMemory workingMemory = ruleBase.newStatefulSession();
	workingMemory.insert(usg);
	workingMemory.fireAllRules();
}

private static void compile() throws Exception {
	String rulecontent = readRuleFromFile();
	PackageBuilder builder = new PackageBuilder();
	builder.addPackageFromXml(new BufferedReader(new StringReader(
			rulecontent)));
	Package pkg = builder.getPackage();
	writeSerializedObject(pkg);
}

private static void writeSerializedObject(Object object) throws IOException
{
	FileOutputStream fileOutputStream = new FileOutputStream("sample.txt");
	ObjectOutputStream objectOutputStream = new ObjectOutputStream(
			fileOutputStream);
	objectOutputStream.writeObject(object);
	objectOutputStream.close();
}

private static Object readSerializedObject() throws IOException,
		ClassNotFoundException {
	FileInputStream fileInputStream = new FileInputStream("sample.txt");
	ObjectInputStream objectInputStream = new ObjectInputStream(
			fileInputStream);
	Object object = objectInputStream.readObject();
	return object;
}


Mark Proctor wrote:
> 
> While drools 2.x was limited to XML, 4.0 preference is for the DRL, 
> which is a none xml format. It doesn't produce a jar at the moment just 
> a binary Packaage instance, which you can serialise.
> 
> Mark
> 

-- 
View this message in context: http://www.nabble.com/drools-4.0-compilation-tf4204509.html#a12067771
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list