Dirk,

Looking at your questions, it feels like you are stretching the meaning of declarative programming, if you know what I mean. :) Maybe if you can show us the real use case (or something close), we can help you figure out a way to do it...

  []s
  Edson


Dirk Bergstrom wrote:

Dirk Bergstrom was heard to exclaim, On 11/27/06 23:03:
Dirk Bergstrom was heard to exclaim, On 11/27/06 22:16:
The only think I can think of is this, which looks offensively clunky to me:
global HashMap stash;
rule "a rule"
when
 stash.put("a rule", 7)
 SomeObject( aField > (stash.get("a rule")) )
then
 takeSomeAction(stash.get("a rule"))
end
I was wrong.  The above doesn't work.  So now I'm stuck.  Can anyone think of
a way to do what I'm trying to do?

Sigh, I figured something out five minutes after I sent the message...

I created a class like this:

public class ConstantStash {
   private Map<Object, Integer> things = new HashMap<Object, Integer>();
   public Integer set(Object key, int value) {
       things.put(key, value);
       return value;
   }
   public Integer get(Object key) {
       return things.get(key);
   }
}

And used it like this:

global ConstantStash stash;
rule "foo"
when
 SomeObject( aField > (stash.set("a rule", 7)) )
then
 takeSomeAction(stash.get("a rule"))
end

It's still clunky, but at least it looks like it will work.



--
 ---
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com

 IT executives: Red Hat still #1 for value
http://www.redhat.com/promo/vendor/

---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email

Reply via email to