<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><br></div><div><br></div><div>                        ksession.insert(Obj1);</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>ksession.insert(Obj2);</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>LOG.info(&quot;Rules are fired&quot;);</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span></div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>ksession.addEventListener(new DefaultAgendaEventListener() {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>    @Override</div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>public</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>    void activationCreated(ActivationCreatedEvent event) {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>    <span class="Apple-tab-span" style="white-space:pre">        </span>super.activationCreated(event);<span class="Apple-tab-span" style="white-space:pre">                </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>    <span class="Apple-tab-span" style="white-space:pre">        </span>LOG.info(&quot;I am in event activation created and&quot; +</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>    <span class="Apple-tab-span" style="white-space:pre">                        </span>&quot;removed rule is&quot;+ event.getActivation().getRule().getName() );</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>        //myGlobal.remove(event.getActivation().getRule());</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>    }</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>});</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>ksession.addEventListener(new DefaultAgendaEventListener() {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>    @Override</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span>public</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>    void activationCancelled(ActivationCancelledEvent event) {</div><div>
<span class="Apple-tab-span" style="white-space:pre">                        </span>    <span class="Apple-tab-span" style="white-space:pre">        </span>super.activationCancelled(event);</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>    <span class="Apple-tab-span" style="white-space:pre">        </span>LOG.info(&quot;I am in event activation cancelled and&quot; +</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>    <span class="Apple-tab-span" style="white-space:pre">                        </span>&quot;removed rule is&quot;+event.toString() );</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>        //myGlobal.add((Rule) event.getActivation().getRule());</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>    }</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>});</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>ksession.addEventListener( new DefaultAgendaEventListener() {</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>    public void afterActivationFired(AfterActivationFiredEvent event) {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>        super.afterActivationFired( event );</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>        System.out.println( event );</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>    }</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>});</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span></div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>ksession.fireAllRules();</div><div><br></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>