[rules-users] reuse existing functions/imports when adding new rule at runtime

Sibylle Duerr sibylle.duerr at mymail.ch
Wed Apr 30 04:47:37 EDT 2008


how to add a rule at runtime to an existing package without having to
re-add the functions and imports?

at the moment I do it like this: 

	PackageBuilder builder = new PackageBuilder();
	builder.addPackageFromDrl(imports);
	builder.addPackageFromDrl(functions);
	builder.addPackageFromDrl(newrule, dsl);

	// Check the builder for errors
	...

	ruleBase.addPackage(builder.getPackage());

that works fine but I don't like to re-add all the functions and imports
every time a new rule is added. it should be possible to define new rules
using the existing functions. is there a better way to do this?

I also tried to reuse the PackageBuilder and just add the new rule with 
	builder.addPackageFromDrl(newrule, dsl);
	
but this ends up in a NullPointerException:
	java.lang.NullPointerException
		at org.drools.reteoo.ReteooBuilder.removeRule(ReteooBuilder.java:224)
		at org.drools.reteoo.ReteooRuleBase.removeRule(ReteooRuleBase.java:270)	
		...

best regards
sibylle

___________________________________________________________________________
mymail - der unschlagbare und kostenlose E-Mail-Dienst der Schweiz!
http://mymail.ch/?redirect=9999
Geschenkidee.ch - Geschenke für jeden Anlass!
http://ad.zanox.com/ppc/?8113402C1838543470T





More information about the rules-users mailing list