[rules-users] Discover when a rule isn't more active
Claudio Rainoldi
claudio.rainoldi at gmail.com
Tue Jul 29 14:59:07 EDT 2008
Yes i know this. I've tried to use activationCancelled method to
discover when a rule isn't more true but it doesn't work. The code was
public static class FiredRulesListener extends
DefaultAgendaEventListener static class FiredRulesListener extends
DefaultAgendaEventListener
{
List<Rule> firedRules = new ArrayList<Rule>();
public List<Rule> getFiredRules() List<Rule> getFiredRules()
{return this.firedRules;}
@Override
publicvoid afterActivationFired(AfterActivationFiredEvent event,
WorkingMemory workingMemory)
{Rule rule = event.getActivation().getRule();
if (!this.firedRules.contains(rule)) this.firedRules.add(rule);
(!this.firedRules.contains(rule)) this.firedRules.add(rule);
}
@Override
public void activationCancelled (ActivationCancelledEvent event,
WorkingMemory workingMemory)
{
System.out.println("i never see this message");
Rule rule= event.getActivation().getRule();
this.firedRules.remove(rule);
}
but when i turn off the ligth the method activationCancelled wasn't
never called
2008/7/29, Edson Tirelli <tirelli at post.com>:
>
>
> The same interface you are using (AgendaEventListener) has 2 methods for activations created and canceled:
>
> void activationCreated(ActivationCreatedEvent event,
> WorkingMemory workingMemory);
>
> void activationCancelled(ActivationCancelledEvent event,
> WorkingMemory workingMemory);
>
> []s
> Edson
>
>
> 2008/7/29 Claudio Rainoldi <claudio.rainoldi at gmail.com>
>
> >
> >
> > Hi everyone,
> > isn'it there a way to find when a rule isn't more active.
> > For example if i have this rule:
> >
> >
> > rule "light 2 on"
> > dialect "java"
> > when
> > Light (name=="0/0/2", actualvalue=="1");
> > then
> > System.out.println("luce 2 on");
> > end
> >
> >
> > when someone turn on the light 2 i discover that the rule is fired using an Agenda Event Listener and the method afterActivationFired;
> > But when someone turn off the ligth isn't there a similar way to discover that the rule "light 2 on" isn't more active.
> > My only solution is to use the dual rule:
> >
> > rule "light 2 on_dual"
> > dialect "java"
> > when
> > not (Light (name=="0/0/2", actualvalue=="1"));
> > then
> > System.out.println("luce 2 off");
> > end
> >
> > Isn't there a more sample way to do this?
> > Thanks in advance.
> >
> >
> > Cla
> > _______________________________________________
> > rules-users mailing list
> > rules-users at 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
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
More information about the rules-users
mailing list