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

Michael Anstis michael.anstis at gmail.com
Thu Oct 14 16:33:22 EDT 2010


Here's an example project (Eclispe).

Using Rule in the Set didn't work (so I suspect it doesn't overide
equals\hashcode correctly), however using rule name instead is fine.

2010/10/14 Navdeep Kumar <nkumar at objectwave.com>

> 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}
>
> *
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20101014/7dc52943/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: manstis.zip
Type: application/zip
Size: 7975 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20101014/7dc52943/attachment.zip 


More information about the rules-users mailing list