Hi man, I didn&#39;t have the time to review the code of this feature but I&#39;m really interested to understand how you are achieving this:<div>&quot;<span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: arial, sans-serif; font-size: medium; "><table class="Bs nH iY" cellpadding="0" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: rgb(255, 255, 255); width: 1031px; position: relative; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-collapse: collapse; border-top-width: 1px; border-top-style: solid; border-top-color: rgb(228, 228, 228); margin-top: 10px; background-position: initial initial; background-repeat: initial initial; ">
<tbody><tr><td class="Bu" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: arial, sans-serif; vertical-align: top; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
<div class="nH if" style="padding-top: 0px; padding-right: 0px; padding-bottom: 1px; padding-left: 0px; "><div class="nH"><div class="nH hx" style="color: rgb(51, 51, 51); padding-top: 4px; padding-right: 8px; padding-bottom: 4px; padding-left: 0px; ">
<div class="nH"><div class="h7 ie nH oy8Mbf" style="padding-bottom: 0px; clear: both; "><div class="Bk" style="position: relative; margin-bottom: 10px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(239, 239, 239); border-right-color: rgb(239, 239, 239); border-left-color: rgb(239, 239, 239); border-bottom-color: rgb(226, 226, 226); border-top-width: 0px; border-top-left-radius: 2px 2px; border-top-right-radius: 2px 2px; border-bottom-right-radius: 2px 2px; border-bottom-left-radius: 2px 2px; width: 790px; ">
<div class="G3 G2" style="padding-top: 3px; background-color: rgb(255, 255, 255); border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-right-color: rgb(207, 207, 207); border-bottom-color: rgb(207, 207, 207); border-left-color: rgb(207, 207, 207); border-top-width: 1px; border-top-style: solid; border-top-color: rgb(207, 207, 207); border-top-left-radius: 2px 2px; border-top-right-radius: 2px 2px; border-bottom-right-radius: 2px 2px; border-bottom-left-radius: 2px 2px; ">
<div><div id=":11p"><div class="HprMsc"><div class="gs"><div id=":11r" class="ii gt" style="font-size: 13px; margin-top: 5px; margin-right: 15px; margin-bottom: 5px; margin-left: 15px; padding-bottom: 20px; position: relative; z-index: 2; ">
<div id=":11q">-All matched rule&#39;s Activations are inserted into WorkingMemory as<br>facts. </div></div></div></div></div></div></div></div></div></div></div></div></div></td></tr></tbody></table></span>&quot;</div><div>
How are you getting the newly created activation and inserting it inside the working memory? Are you wrapping the real Activation Object or creating a new representation of it?  I want to understand how you are managing the information and if you create a hook to do that to be able to copy the same mechanism and apply it for processes.</div>
<div><br></div><div>Cheers.</div><div><br></div><div><br></div><div><br><div class="gmail_quote">On Sun, Aug 7, 2011 at 6:29 AM, Mark Proctor <span dir="ltr">&lt;<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">I just got a first cut working for &quot;declarative agenda&quot;. The idea here<br>
is rules can control which rule can or cannot fire. Because this is<br>
highly experimental it is off by default and users must explicitely<br>
enable it, it will stay this way until we are happy with the solution.<br>
My hope is that it will provide a more declarative approach to execution<br>
control; which will enable more readable and maintainable rules compared<br>
to using magic salience values and in some circumstances control objects..<br>
<br>
         KnowledgeBaseConfiguration kconf =<br>
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();<br>
         kconf.setOption( DeclarativeAgendaOption.ENABLED );<br>
         KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(<br>
kconf );<br>
<br>
The basic idea is:<br>
-All matched rule&#39;s Activations are inserted into WorkingMemory as<br>
facts. So you can now match against an Activation the rules metadata and<br>
declarations are available as -fields on the Activation object.<br>
-You can use the kcontext.block( $a ) for the current rule to block the<br>
selected activation. Only when that rule becomes false will the<br>
activation be elegible for firing. If it is already elebible for firing<br>
and is later blocked, it will be removed from the agenda until it is<br>
unblocked.<br>
-An activation may have multiple blockers, all blockers must became<br>
false, so they are removed to enable the activation to fire<br>
-kcontext.unblockAll( $a ) is an over-ride rule that will remove all<br>
blockers regardless<br>
-@activationListener(&#39;direct&#39;) allows a rule to fire as soon as it&#39;s<br>
matched, this is to be used for rules that block/unblock activations, it<br>
is not desirable for these rules to have side effects that impact else<br>
where. The name may change later, this is actually part of the pluggable<br>
terminal node handlers I made, which is an &quot;internal&quot; feature for the<br>
moment.<br>
<br>
I should be committing this later today, and will send a follow up email<br>
once it hits HEAD, but here is a unit test. It uses a control role to<br>
stop all rules with metadata declaring the rules to be in the &quot;sales&quot;<br>
department. Only when that control rule becomes false can they fire.<br>
<br>
package org.domain.test<br>
import org.drools.runtime.rule.Activation<br>
global java.util.List list<br>
dialect &#39;mvel&#39;<br>
<br>
rule rule1 @department(&#39;sales&#39;)<br>
when<br>
      $s : String( this == &#39;go1&#39; )<br>
then<br>
     list.add( <a href="http://kcontext.rule.name" target="_blank">kcontext.rule.name</a> + &#39;:&#39; + $s );<br>
end<br>
rule rule2 @department(&#39;sales&#39;)<br>
when<br>
      $s : String( this == &#39;go1&#39; )<br>
then<br>
     list.add( <a href="http://kcontext.rule.name" target="_blank">kcontext.rule.name</a> + &#39;:&#39; + $s );<br>
end<br>
rule rule3 @department(&#39;sales&#39;)<br>
when<br>
      $s : String( this == &#39;go1&#39; )<br>
then<br>
     list.add( <a href="http://kcontext.rule.name" target="_blank">kcontext.rule.name</a> + &#39;:&#39; + $s );<br>
end<br>
rule blockerAllSalesRules @activationListener(&#39;direct&#39;)<br>
when<br>
      $s : String( this == &#39;go2&#39; )<br>
      $i : Activation( department == &#39;sales&#39; )<br>
then<br>
     list.add( $<a href="http://i.rule.name" target="_blank">i.rule.name</a> + &#39;:&#39; + $s  );<br>
     kcontext.block( $i );<br>
end<br>
<br>
KnowledgeBaseConfiguration kconf =<br>
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();<br>
kconf.setOption( DeclarativeAgendaOption.ENABLED );<br>
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase( kconf );<br>
kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() );<br>
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();<br>
List list = new ArrayList();<br>
ksession.setGlobal( &quot;list&quot;, list);<br>
ksession.insert(  &quot;go1&quot; );<br>
FactHandle go2 = ksession.insert(  &quot;go2&quot; );<br>
ksession.fireAllRules();<br>
assertEquals( 3, list.size() ); // none of the rules 1-3 fire, as they<br>
are blocked.<br>
assertTrue( list.contains( &quot;rule1:go2&quot; ));<br>
assertTrue( list.contains( &quot;rule2:go2&quot; ));<br>
assertTrue( list.contains( &quot;rule3:go2&quot; ));<br>
<br>
list.clear();<br>
<br>
ksession.retract( go2 ); // the blocker rule is nolonger true, so rules<br>
1-3 can now fire.<br>
ksession.fireAllRules();<br>
<br>
assertEquals( 3, list.size() );<br>
assertTrue( list.contains( &quot;rule1:go1&quot; ));<br>
assertTrue( list.contains( &quot;rule2:go1&quot; ));<br>
assertTrue( list.contains( &quot;rule3:go1&quot; ));<br>
<br>
ksession.dispose();<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
</blockquote></div><br><br clear="all"><br>-- <br> - CTO @ <a href="http://www.plugtree.com">http://www.plugtree.com</a>  <br> - MyJourney @ <a href="http://salaboy.wordpress.com">http://salaboy.wordpress.com</a><br> - Co-Founder @ <a href="http://www.jbug.com.ar">http://www.jbug.com.ar</a><br>
 <br> - Salatino &quot;Salaboy&quot; Mauricio -<br>
</div>