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