[rules-users] How to Capture the rule which does not get executed

Navdeep Kumar nkumar at objectwave.com
Thu Oct 14 15:51:09 EDT 2010


Hi, i am not getting how to set that variable so that inner classes can use
that. rather than using that i tried to print that rule in both of the
events and i was surprised to know that those events are not fired. The last
event handler gets executed and print the rules which are executed in the
rule file but *activationCreated* and *activationCanceled* are not fired.
Can you tell me what both events do?

i assume that 1st one will add that rules to the list which gets execution
and 2nd will remove that rule from the list which will not. and finally we
can see that list that which rules get execution and which are not. Am i
right or i am taking this wrong.


                        ksession.insert(Obj1);
ksession.insert(Obj2);
 LOG.info("Rules are fired");
 ksession.addEventListener(new DefaultAgendaEventListener() {
    @Override
public
    void activationCreated(ActivationCreatedEvent event) {
     super.activationCreated(event);
     LOG.info("I am in event activation created and" +
     "removed rule is"+ event.getActivation().getRule().getName() );
        //myGlobal.remove(event.getActivation().getRule());
    }
});
ksession.addEventListener(new DefaultAgendaEventListener() {
    @Override
public
    void activationCancelled(ActivationCancelledEvent event) {
     super.activationCancelled(event);
     LOG.info("I am in event activation cancelled and" +
     "removed rule is"+event.toString() );
        //myGlobal.add((Rule) event.getActivation().getRule());
    }
});
 ksession.addEventListener( new DefaultAgendaEventListener() {
    public void afterActivationFired(AfterActivationFiredEvent event) {
        super.afterActivationFired( event );
        System.out.println( event );
    }
});
 ksession.fireAllRules();

*Output*
*
*
*
2010-10-14 14:25:08,077 INFO [main]
com.navistar.dam.services.impl.AvailabilityMatrixServiceDroolesImpl - Before
calling the function readKnowledgeBase
2010-10-14 14:25:08,078 INFO [main]
com.navistar.dam.services.impl.AvailabilityMatrixServiceDroolesImpl - Rule
file is loaded
2010-10-14 14:25:11,204 INFO [main]
com.navistar.dam.services.impl.AvailabilityMatrixServiceDroolesImpl - Rule
file added to the knowledgebuilder
2010-10-14 14:25:11,500 INFO [main]
com.navistar.dam.services.impl.AvailabilityMatrixServiceDroolesImpl - After
setting the gloabal map
2010-10-14 14:25:11,500 INFO [main]
com.navistar.dam.services.impl.AvailabilityMatrixServiceDroolesImpl - Rule
are added to the list named myGlobal
2010-10-14 14:25:11,524 INFO [main]
com.navistar.dam.services.impl.AvailabilityMatrixServiceDroolesImpl - Rules
are fired
I am in  2
==>[ActivationEventImpl: getActivation()=[Activation
rule=FrontSuspension:Type|FrontAxle:Type, tuple=[fact
0:1:29477163:29477163:1:DEFAULT:com.navistar.dam.services.bo.Feature at 1c1c92b
]
[fact
0:2:6059828:6059828:2:DEFAULT:com.navistar.dam.services.bo.Feature at 5c7734]
],
getKnowledgeRuntime()=org.drools.impl.StatefulKnowledgeSessionImpl at 14e0e90]
These are compatible
FrontSuspension
==>[ActivationEventImpl: getActivation()=[Activation
rule=FrontAxle:Capacity|FrontSuspension:Capacity, tuple=[fact
0:1:29477163:29477163:1:DEFAULT:com.navistar.dam.services.bo.Feature at 1c1c92b
]
[fact
0:2:6059828:6059828:2:DEFAULT:com.navistar.dam.services.bo.Feature at 5c7734]
],
getKnowledgeRuntime()=org.drools.impl.StatefulKnowledgeSessionImpl at 14e0e90]
2010-10-14 14:25:11,691 INFO [main]
com.navistar.dam.services.impl.AvailabilityMatrixServiceDroolesImpl - Value
inserted in Rule file in the HashMap [12.35]
{FrontSuspension-FrontAxle=12.35}

*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20101014/9729fe2d/attachment.html 


More information about the rules-users mailing list