[rules-users] property change listeners aren't working as described in the Expert Doc

Wolfgang Laun wolfgang.laun at gmail.com
Thu Jun 20 14:52:05 EDT 2013


On 20/06/2013, abasile <alex.basile at interactivedata.com> wrote:
> 2 things aren't working as expected:
>
> 1.) Slot Selection - Rules listening for different properties on the object
> are being fired
> ie:) Object obj has 3 properties a, b, and c. Rule 1 modifies obj.a
> triggers
> Rule 2 which is listening for obj.b (different property on the same object)
> Can you please refer me to a working example?

@PropertyReactive
public class Alpha {
    private int    a;
    private String b;
    private boolean c;
    ...getters & setters
}

rule one
when
   $alpha: Alpha( a != 1 )
then
   modify( $alpha ){
       setA( 1 )
   }
   System.out.println( "one: Alpha a = " + $alpha.getA() );
end

rule two
salience 100
when
   $alpha: Alpha( b == "b1" )
then
   System.out.println( "two: Alpha b = " + $alpha.getB() );
end

kSession.insert( new Alpha(  4, "b1", true ) );
kSession.fireAllRules();

Without annotation:
two: Alpha b = b1
one: Alpha a = 1
two: Alpha b = b1

With annotation:
two: Alpha b = b1
one: Alpha a = 1

Using 5.5.0.
-W


More information about the rules-users mailing list