<br> Dean,<br><br> I just committed the changes into trunk to allow support for that. Revision #25246 in trunk.<br><br><a href="https://jira.jboss.org/jira/browse/JBRULES-1969">https://jira.jboss.org/jira/browse/JBRULES-1969</a><br>
<br> So instead of using a parameter in the insert method, just annotate the types for which you want to use property change support.<br><br> []s<br> Edson<br><br><div class="gmail_quote">2009/2/11 Mark Proctor <span dir="ltr"><<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000"><div class="Ih2E3d">
J Michael Dean wrote:
<blockquote type="cite">I think I was not clear in my note. I used dynamic facts
with Drools 4.07 but am migrating to Drools 5, where there is no longer
a second argument to the insert method. My POJOs do have property
change listeners.</blockquote></div>
We have deprecated the insert method in favour of an attribute of a
type declaration for propertychangesupport, this will be in the CR.<br><font color="#888888">
<br>
Mark<br>
</font><blockquote type="cite"><div><div></div><div class="Wj3C7c">
<div><br>
</div>
<div>Here is an example rule that activates but never apparently
fires:</div>
<div><br>
</div>
<div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(0, 128, 0);"><span style="color: rgb(150, 0, 0);">rule</span><span style="color: rgb(0, 0, 0);"> </span>"Detect insulin on"</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(150, 0, 0);">dialect<span style="color: rgb(0, 0, 0);"> </span><span style="color: rgb(0, 128, 0);">"java"</span></div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(150, 0, 0);"><span style="color: rgb(0, 0, 0);"><span style="white-space: pre;"> </span></span>when</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span>decision :
GlucoseDecision(currentInsulinDripRate > 0)</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span>decisionState
: GlucoseDecisionState( insulinOn == <span style="color: rgb(150, 0, 0);">false</span> )</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(150, 0, 0);"><span style="color: rgb(0, 0, 0);"><span style="white-space: pre;"> </span></span>then</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span>decisionState.setInsulinOn(<span style="color: rgb(150, 0, 0);">true</span>);</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(150, 0, 0);">end</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; color: rgb(150, 0, 0);"><br>
</div>
<div>
<div>The relevant method that is called on the RHS:</div>
<div><br>
</div>
<div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span><span style="color: rgb(127, 0, 85);">public</span> <span style="color: rgb(127, 0, 85);">void</span> setInsulinOn(<span style="color: rgb(127, 0, 85);">boolean</span> insulinOn) {</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span><span style="color: rgb(127, 0, 85);">boolean</span> oldValue = <span style="color: rgb(127, 0, 85);">this</span>.isInsulinOn();</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span><span style="color: rgb(127, 0, 85);">this</span>.<span style="color: rgb(0, 0, 192);">insulinOn</span> = insulinOn;</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span>firePropertyChange(<span style="color: rgb(42, 0, 255);">"insulinOn"</span>, oldValue,
insulinOn);</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span>}</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><font size="2" face="Helvetica"><span style="font-size: 10px;"><br>
</span></font></div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="font-family: Helvetica; font-size: 10px;">The eventual call is
to fireRules which then calls executeRules in a callback. Previously,
I had a Boolean argument to the insert</span></div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="font-family: Helvetica; font-size: 10px;">statements and all
the code worked with the old RuleBase, RuleAgent objects. But since
changing to KnowledgeSession, the rules</span></div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="font-family: Helvetica; font-size: 10px;">do not appear to
fire. Here are the relevant methods:</span></div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><font size="2" face="Helvetica"><span style="font-size: 10px;"><br>
</span></font></div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;">
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span><span style="color: rgb(127, 0, 85);">public</span> <span style="color: rgb(127, 0, 85);">void</span>
executeRules(WorkingEnvironmentCallback callback) {</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span>StatefulKnowledgeSession
ksession = <span style="color: rgb(0, 0, 192);">kbase</span>.newStatefulKnowledgeSession();</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span>callback.initEnvironment(ksession);</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span>ksession.fireAllRules();</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span>ksession.dispose();</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span>}</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><br>
</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;">
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span><span style="color: rgb(127, 0, 85);">public</span> <span style="color: rgb(127, 0, 85);">void</span> fireRules(<span style="color: rgb(127, 0, 85);">final</span> GlucoseDecision
glucoseDecision, <span style="color: rgb(127, 0, 85);">final</span>
GlucoseDecisionState decisionState) {</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span><span style="color: rgb(0, 0, 192);">rulesEngine</span>.executeRules(<span style="color: rgb(127, 0, 85);">new</span>
WorkingEnvironmentCallback() {</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span><span style="color: rgb(127, 0, 85);">public</span> <span style="color: rgb(127, 0, 85);">void</span>
initEnvironment(StatefulKnowledgeSession workingMemory) {</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span>workingMemory.insert(glucoseDecision);</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span>workingMemory.insert(decisionState);</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span>}</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span>});</div>
<div style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal;"><span style="white-space: pre;"> </span>}</div>
</div>
</div>
</div>
<blockquote type="cite">
<div><br>
Message: 2<br>
Date: Wed, 11 Feb 2009 10:26:06 -0500<br>
From: Edson Tirelli <<a href="mailto:tirelli@post.com" target="_blank">tirelli@post.com</a>><br>
Subject: Re: [rules-users] Shadow facts<br>
To: Rules Users List <<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>><br>
Message-ID:<br>
<span style="white-space: pre;"> </span><<a href="mailto:e6dd5ba30902110726t2b09ee9dtdc7e85ed4217f80a@mail.gmail.com" target="_blank">e6dd5ba30902110726t2b09ee9dtdc7e85ed4217f80a@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
Dean,<br>
<br>
There are two unrelated things in here... the boolean flag for dynamic<br>
facts means your fact supports the property change listeners and you
don't<br>
need to call modify() when you change an attribute. ShadowFacts are a<br>
complete different thing that should be mostly transparent to users.<br>
If you can provide an example, it will be easier to help you.<br>
<br>
[]s<br>
Edson<br>
<br>
2009/2/11 J Michael Dean <<a href="mailto:mdean77@comcast.net" target="_blank">mdean77@comcast.net</a>><br>
<br>
<blockquote type="cite">I am migrating from 4.07 to 5 and my
previous DRL file does not function<br>
</blockquote>
<blockquote type="cite">correctly; I previousliy inserted facts
with the dynamic Boolean set true.<br>
</blockquote>
<blockquote type="cite"> I understand that this is no longer done
because shadow facts are "not<br>
</blockquote>
<blockquote type="cite">needed" in Drools 5, but is it necessary to
do anything different in the RHS<br>
</blockquote>
<blockquote type="cite">when modifying facts? My fact POJOs have a
method for adding text to<br>
</blockquote>
<blockquote type="cite">themselves. I believe my rules are not
working properly because nothing is<br>
</blockquote>
<blockquote type="cite">being modified - only the initial
activation set fires and then nothing<br>
</blockquote>
<blockquote type="cite">happens.<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">Restated, the documentation talks about how
to "avoid" shadow facts in<br>
</blockquote>
<blockquote type="cite">Drools 4.07 - are the restrictions in this
part of the docs necessary in<br>
</blockquote>
<blockquote type="cite">Drools 5?<br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
<blockquote type="cite">Thanks.<br>
</blockquote>
<blockquote type="cite">_______________________________________________<br>
</blockquote>
<blockquote type="cite">rules-users mailing list<br>
</blockquote>
<blockquote type="cite"><a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
</blockquote>
<blockquote type="cite"><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote>
<blockquote type="cite"><br>
</blockquote>
</div>
</blockquote>
</div>
</div>
</div></div><pre><hr size="4" width="90%"><div class="Ih2E3d">
_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</div></pre>
</blockquote>
<br>
</div>
<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></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>