[rules-users] dynamically loading drl files

rama bhupal ramas_reddy at yahoo.com
Fri Sep 21 10:17:04 EDT 2007


Hi All

Adance thanks,Can some please help me i'm trying to
load drl files  when i start my program or if any
change occured in drl file need to load drl files into
rulebase.

private RuleBase loadRules() throws Exception {
		Reader source = null;
		PackageBuilder builder = new PackageBuilder();
		Package pkg = null;
		RuleBase ruleBase = RuleBaseFactory.newRuleBase();
		String path[] = rulesFile.split(",");
		builder = new PackageBuilder();

		for (String filePath : path) {

			source = new
InputStreamReader(RulesEngineDoerLinkWithQuery3jmx.class
					.getResourceAsStream(filePath));
		
			builder.addPackageFromDrl(source);
			
		}
		
		pkg = builder.getPackage();
		ruleBase.addPackage(pkg);
		return ruleBase;
	}


i'm doing that and using with new rulebase creating
new statefullSession,



after adding new rule when program is running calling
the loadRules() method

So it returns new ruleBase.

When i print ruleNames,its not priting the new
rulename.

Note:could have doubt for any one i may not calling
loadRules() when i change in drl file,its calling i
checked using break point in debug mode.


Rule rules[] =
ruleBase.getPackage("rulesrules").getRules();
		for(int i = 0; i <rules.length; i++)
		System.out.println("*****"+rules[i].getName());
		

StatefulSession workingMemory =
ruleBase.newStatefulSession();








..............
Inserting objects............
.....


workingMemory.fireAllRules();
			if (workingMemory != null) {
							workingMemory.dispose();
							workingMemory = null;
						}


I'm using rules 4.0.1.

Thanks
Rama






       
____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play Sims Stories at Yahoo! Games.
http://sims.yahoo.com/  



More information about the rules-users mailing list