[rules-users] Adding rules at runtime

Justin King justin.matthew.king at gmail.com
Wed Aug 26 22:55:51 EDT 2009


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.king at 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090827/48ebfb99/attachment.html 


More information about the rules-users mailing list