Here&#39;s an example project (Eclispe).<br><br>Using Rule in the Set didn&#39;t work (so I suspect it doesn&#39;t overide equals\hashcode correctly), however using rule name instead is fine.<br><br><div class="gmail_quote">
2010/10/14 Navdeep Kumar <span dir="ltr">&lt;<a href="mailto:nkumar@objectwave.com">nkumar@objectwave.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div>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 <b>activationCreated</b> and <b>activationCanceled</b> are not fired. Can you tell me what both events do? </div>

<div><br></div><div>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.              </div>
<div class="im">
<div><br></div><div><br></div><div>                        ksession.insert(Obj1);</div><div><span style="white-space: pre-wrap;">                        </span>ksession.insert(Obj2);</div><div><span style="white-space: pre-wrap;">                        </span></div>

<div><span style="white-space: pre-wrap;">                        </span>LOG.info(&quot;Rules are fired&quot;);</div><div><span style="white-space: pre-wrap;">                        </span></div><div><span style="white-space: pre-wrap;">                        </span>ksession.addEventListener(new DefaultAgendaEventListener() {</div>

<div><span style="white-space: pre-wrap;">                        </span>    @Override</div><div><span style="white-space: pre-wrap;">                                </span>public</div><div><span style="white-space: pre-wrap;">                        </span>    void activationCreated(ActivationCreatedEvent event) {</div>

</div><div><span style="white-space: pre-wrap;">                        </span>    <span style="white-space: pre-wrap;">        </span>super.activationCreated(event);<span style="white-space: pre-wrap;">                </span></div>
<div><span style="white-space: pre-wrap;">                        </span>    <span style="white-space: pre-wrap;">        </span>LOG.info(&quot;I am in event activation created and&quot; +</div><div><span style="white-space: pre-wrap;">        </span>    <span style="white-space: pre-wrap;">                        </span>&quot;removed rule is&quot;+ event.getActivation().getRule().getName() );</div>

<div><span style="white-space: pre-wrap;">                        </span>        //myGlobal.remove(event.getActivation().getRule());</div><div class="im"><div><span style="white-space: pre-wrap;">                        </span>    }</div><div><span style="white-space: pre-wrap;">                        </span>});</div>

<div><span style="white-space: pre-wrap;">                        </span>ksession.addEventListener(new DefaultAgendaEventListener() {</div><div><span style="white-space: pre-wrap;">                        </span>    @Override</div>
<div><span style="white-space: pre-wrap;">                                </span>public</div></div><div><span style="white-space: pre-wrap;">                        </span>    void activationCancelled(ActivationCancelledEvent event) {</div><div>
<span style="white-space: pre-wrap;">                        </span>    <span style="white-space: pre-wrap;">        </span>super.activationCancelled(event);</div><div><span style="white-space: pre-wrap;">                        </span>    <span style="white-space: pre-wrap;">        </span>LOG.info(&quot;I am in event activation cancelled and&quot; +</div>

<div><span style="white-space: pre-wrap;">                        </span>    <span style="white-space: pre-wrap;">                        </span>&quot;removed rule is&quot;+event.toString() );</div><div><span style="white-space: pre-wrap;">                        </span>        //myGlobal.add((Rule) event.getActivation().getRule());</div>
<div class="im">
<div><span style="white-space: pre-wrap;">                        </span>    }</div><div><span style="white-space: pre-wrap;">                        </span>});</div><div><span style="white-space: pre-wrap;">                        </span></div>
<div><span style="white-space: pre-wrap;">                        </span>ksession.addEventListener( new DefaultAgendaEventListener() {</div><div><span style="white-space: pre-wrap;">                        </span>    public void afterActivationFired(AfterActivationFiredEvent event) {</div>

<div><span style="white-space: pre-wrap;">                        </span>        super.afterActivationFired( event );</div><div><span style="white-space: pre-wrap;">                        </span>        System.out.println( event );</div>
<div><span style="white-space: pre-wrap;">                        </span>    }</div><div><span style="white-space: pre-wrap;">                        </span>});</div><div><span style="white-space: pre-wrap;">                        </span></div>
<div><span style="white-space: pre-wrap;">                        </span>ksession.fireAllRules();</div><div><br></div></div><div><b>Output</b></div><div><b><br></b></div><div><b><div>2010-10-14 14:25:08,077 INFO [main] com.navistar.dam.services.impl.AvailabilityMatrixServiceDroolesImpl - Before calling the function readKnowledgeBase</div>

<div>2010-10-14 14:25:08,078 INFO [main] com.navistar.dam.services.impl.AvailabilityMatrixServiceDroolesImpl - Rule file is loaded</div><div>2010-10-14 14:25:11,204 INFO [main] com.navistar.dam.services.impl.AvailabilityMatrixServiceDroolesImpl - Rule file added to the knowledgebuilder</div>

<div>2010-10-14 14:25:11,500 INFO [main] com.navistar.dam.services.impl.AvailabilityMatrixServiceDroolesImpl - After setting the gloabal map</div><div>2010-10-14 14:25:11,500 INFO [main] com.navistar.dam.services.impl.AvailabilityMatrixServiceDroolesImpl - Rule are added to the list named myGlobal</div>

<div>2010-10-14 14:25:11,524 INFO [main] com.navistar.dam.services.impl.AvailabilityMatrixServiceDroolesImpl - Rules are fired</div><div>I am in  2</div><div>==&gt;[ActivationEventImpl: getActivation()=[Activation rule=FrontSuspension:Type|FrontAxle:Type, tuple=[fact 0:1:29477163:29477163:1:DEFAULT:com.navistar.dam.services.bo.Feature@1c1c92b]</div>

<div>[fact 0:2:6059828:6059828:2:DEFAULT:com.navistar.dam.services.bo.Feature@5c7734]</div><div>], getKnowledgeRuntime()=org.drools.impl.StatefulKnowledgeSessionImpl@14e0e90]</div><div>These are compatible</div><div>FrontSuspension</div>

<div>==&gt;[ActivationEventImpl: getActivation()=[Activation rule=FrontAxle:Capacity|FrontSuspension:Capacity, tuple=[fact 0:1:29477163:29477163:1:DEFAULT:com.navistar.dam.services.bo.Feature@1c1c92b]</div><div>[fact 0:2:6059828:6059828:2:DEFAULT:com.navistar.dam.services.bo.Feature@5c7734]</div>

<div>], getKnowledgeRuntime()=org.drools.impl.StatefulKnowledgeSessionImpl@14e0e90]</div><div>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]</div>

<div>{FrontSuspension-FrontAxle=12.35}</div><div><br></div></b></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>