<div dir="ltr">just basic Drools 5.5.0 Final<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jul 14, 2013 at 8:40 PM, Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Which Drools version do you use?<br>
<div class="HOEnZb"><div class="h5"><br>
On 14/07/2013, k <<a href="mailto:rrdh@gmx.net">rrdh@gmx.net</a>> wrote:<br>
> Hi,<br>
> basically it's the same problem this guy had<br>
> <a href="http://stackoverflow.com/questions/11485122/non-template-dynamic-rules-in-drools" target="_blank">http://stackoverflow.com/questions/11485122/non-template-dynamic-rules-in-drools</a><br>
> <<a href="http://stackoverflow.com/questions/11485122/non-template-dynamic-rules-in-drools" target="_blank">http://stackoverflow.com/questions/11485122/non-template-dynamic-rules-in-drools</a>><br>
><br>
> , but the links in that question don't work.<br>
><br>
> I'd like to dynamically add rules to a running session, but can use 'eval'<br>
> only in the very first one. If I add a second rule like the following, it<br>
> won't execute:<br>
><br>
> ---<br>
><br>
> String test2 =<br>
> "\nrule id4" +<br>
> "\nwhen" +<br>
> "\neval(0 == 0)" + // if this eval is removed, "done2" is inserted<br>
> "\nthen" +<br>
> "\ninsertLogical( \"done2\" );" +<br>
> "\nend";<br>
><br>
> kbuilder.add(ResourceFactory.newByteArrayResource(test2.getBytes()),<br>
> ResourceType.DRL);<br>
> session.getKnowledgeBase().addKnowledgePackages(kbuilder.getKnowledgePackages());<br>
><br>
> fired = session.fireAllRules();<br>
> System.out.println(fired); // 0<br>
> effects = session.getObjects();<br>
> assertTrue("fired", effects.contains("done2")); // fails<br>
><br>
> ---<br>
><br>
> You can see the complete Test at <a href="http://codetidy.com/6206/" target="_blank">http://codetidy.com/6206/</a><br>
><br>
> I'm also not sure if this is the correct way to dynamically add rules, so<br>
> please let me know, if there's a better way to add rules from strings.<br>
><br>
> How can I dynamically add new rules to a running session and still use<br>
> eval?<br>
><br>
><br>
><br>
> --<br>
> View this message in context:<br>
> <a href="http://drools.46999.n3.nabble.com/Dynamic-Rules-and-Eval-tp4024908.html" target="_blank">http://drools.46999.n3.nabble.com/Dynamic-Rules-and-Eval-tp4024908.html</a><br>
> Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
> _______________________________________________<br>
> rules-users mailing list<br>
> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
><br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br></div>