Thanks very much for this reply :)
  However, I was wondering: will it work in a multi-threaded environment ?
  I have a Servlet, where each HTTP request is handled by a separate thread, as 
usual. 
  All those threads use the rule engine, simultaniously... if it's a static 
variable, won't they override each other's data ? 
   
                       Thanks again
                       Sol
   
   

Ricardo Rojas Aguirre <[EMAIL PROTECTED]> wrote:
  Hi, I solved the same problem with a local variable defined in the function 
tag...

To solve your proble try somthing like this...


public static double sqrtResult;





< parameter identifier="num" >
< class > Integer < / class >
< / parameter >

< java:condition >
(sqrtResult=Math.sqrt(num.intValue())) > 1000
< / java:condition >

< java:consequence >
System.out.println( sqrtResult );
< / java:consequence >



Cheers
Rik


----- Original Message ----- 
From: "sol myr" 
To: 
Sent: Tuesday, January 31, 2006 11:04 AM
Subject: [drools-user] Drools: Sharing a value between the rule's 
"condition" and "consequence" ?


> Hi,
> I'm new to Drools. Could anyone please help with the following:
>
> Can you share data between a rule's "condition" and "consequence" ?
> For example:
> - My "condition" calculates some square root (Math.sqrt)
> - The "consequence" needs to print out the same square root
>
> It's not efficient to call Math.sqrt twice... :
>
> < parameter identifier="num" >
> < class > Integer < / class >
> < / parameter >
> < java:condition >
> Math.sqrt(num.intValue()) > 1000
> < / java:condition >
> < java:consequence >
> System.out.println( Math.sqrt(num.intValue())
> < / java:consequence >
>
> Is there a way to store the result of "Math.sqrt" in some temporary 
> variable ( so as to avoid the duplicate calculation ) ?
> Please note I know about "application data", but i'd rather not use it, 
> because my sqrt is just a temporary value...
>
> Thanks :)
>
>
> ---------------------------------
>
> What are the most popular cars? Find out at Yahoo! Autos 


  


                        
---------------------------------
 Yahoo! Autos. Looking for a sweet ride? Get pricing, reviews, & more on new 
and used cars.

Reply via email to