[rules-users] Handle activationCancelled Event

Claudio Rainoldi claudio.rainoldi at gmail.com
Fri Jul 25 07:04:43 EDT 2008


Hi everyone,
i'm developing a java application using drools 4 for domotic control;
i ve implemented a listener on my working memory with the method
afterActivationFired(...)
and activationCancelled(...) .
At startup of my app i've write the following lines:

listener = *new* FiredRulesListener();
workingMemory.addEventListener(listener);

Each time a rule is fired the method afterActivationFired(...) is called and
it is ok; but when the rule stop to be true the method
activationCancelled  isn't
never called.
I try to be more clear:

i 've the following rule:
when mylamp=="on"
then
System.out.println("light 1 on");


When i turn on the light 1 the method afterActivationFired(...)  is called,
but when i turn off the light the method activationCancelled isn't called.
Can someboy help me??
Thanks in advance.


Cla


My listener code:

*

public* *static* *class* FiredRulesListener *extends*DefaultAgendaEventListener

{

List<Rule> firedRules = *new* ArrayList<Rule>();

*

public* List<Rule> getFiredRules()

{
*

return* *this*.firedRules;

}

@Override
*

public* *void* afterActivationFired(AfterActivationFiredEvent event,
WorkingMemory workingMemory)

{

Rule rule = event.getActivation().getRule();
*

if* (!*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);

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080725/bc31f947/attachment.html 


More information about the rules-users mailing list