[jboss-user] [JBoss Seam] - Re: JBoss Rules problem (where else to post?)
dgallego
do-not-reply at jboss.com
Mon Sep 4 11:43:26 EDT 2006
You shouldn't use an absolute path to load your rules.
Instead, use this method (extracted from Drools examples and modified).
| public static RuleBase readRule(Class readerClass, String rulesFile, String rulesDslFile) throws Exception
| {
| if (rulesFile == null)
| return null;
| PackageBuilder builder = new PackageBuilder();
| Reader source = new InputStreamReader(readerClass.getResourceAsStream(rulesFile));
| if (rulesDslFile == null)
| builder.addPackageFromDrl(source);
| else
| {
| Reader dsl = new InputStreamReader(readerClass.getResourceAsStream(rulesDslFile));
| builder.addPackageFromDrl(source, dsl);
| }
| RuleBase ruleBase = RuleBaseFactory.newRuleBase();
| Package pkg = builder.getPackage();
| ruleBase.addPackage(pkg);
| return ruleBase;
| }
|
[...]
| RuleBase ruleBase = readRule(MyClass.class, "rules.drl", null);
| WorkingMemory wm = ruleBase.newWorkingMemory();
|
Hope it helps.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969256#3969256
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3969256
More information about the jboss-user
mailing list