Hi Justin, Try this:
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); Resource resource = ResourceFactory.newClassPathResource("MyDrl.drl", MyClass.class); kbuilder.add(resource, ResourceType.DRL); KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); Hope to help, Nestor 2009/8/27 Justin King <justin.matthew.k...@gmail.com> > Anyone at all? I still haven't found a way to do this. > > > On Tue, Aug 25, 2009 at 11:03 AM, Justin King < > justin.matthew.k...@gmail.com> wrote: > >> Hi Everyone, >> >> I found an old example that shows how to add a rule at runtime: >> >> function void addRule(String pkgName, String rule, RuleBase ruleBase ) { >> PackageBuilder builder = new PackageBuilder(); >> builder.addPackgeFromDrl( new StringReader( rule ) ); >> ruleBase.addPackage ( builder.addPackage() ); >> } >> >> I'm trying to do a similar thing with Drools 5 but things seem to have >> changed. What I want is to add a rule (just as a string) to an already >> existing set of rules I've loaded from a drl file (the new rule does not >> have to be saved to the actual file though). I see KnowledgeBase has a >> remove rule method but no add rule. >> I should also note that the set of rules I wish to add to is already >> executing (as in I've called *fireUntilHalt()*) I hope this wont make a >> difference. >> >> Thanks in advance for any help, this mailing list saves me every time! >> >> Cheers, >> >> Justin >> > > > _______________________________________________ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > >
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users