Edson,

Thanks for the tip. I figured I'd need to use a workaround like this.

Unfortunately I'm under a series of tight development and test deadlines all 
the way into early summer. Otherwise, I'd have a look. Hopefully someone else 
out there can assist.

Thanks,
-A

________________________________
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: Friday, October 10, 2008 5:46 AM
To: Rules Users List
Subject: Re: [rules-users] No globals in functions?


   Allen,

   There is a technical explanation behind that and we never had the time to 
find a way to overcome this limitation. What you can do, although not ideal, is 
to send the global as a parameter:

funcion void foo( Logger log, String cond )
{
...
}

rule XYZ
when
then
    foo( log, someString );
end

   If you or anyone would like to help improving this, let us know and we can 
discuss ways into doing it.

   []s
   Edson

2008/10/9 Bagwell, Allen F <[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>>

There's probably an easy explanation for this. I was wondering about why 
functions inside of rule files can't access globals?

For example, I have a log4j logger that I pass into my rule files via a global. 
 The logger should never be a part of working memory. It's just there to 
capture valuable feedback.

But I can't do this:

global Logger log;

function void foo(String cond)
{
   if (cond == "error")
       log.error("I saw an error");
}

Because the compiler says that in the function it can't resolve 'log'.

-A

Allen F. Bagwell
e-mail:  [EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>
phone:  505/284-4517
fax:  505/ 844-7886

There is no monument dedicated to the memory of a committee. -- Lester J. 
Pourciau




_______________________________________________
rules-users mailing list
[email protected]<mailto:[email protected]>
https://lists.jboss.org/mailman/listinfo/rules-users




--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com<http://www.jboss.com>
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to