[rules-users] Replacement for eval

Greg Barton greg_barton at yahoo.com
Tue Nov 16 12:09:23 EST 2010


If you use bean property conventions for naming your methods you can use a regular condition element.  for instance, you could rename emptyMessageFinder() to isMessageFound() or getMessageFound() and your condition would look like this:

when
  m : Message(messageFound == true)
then
...
end

And when you do this the rete is used, birds sing in the trees, and world peace will be declared.

GreG

On Nov 16, 2010, at 5:37, Nirmal Fernando <nirmal070125 at gmail.com> wrote:

Hi,

I have two questions.

1) Is there any other way/method in Drools to test the truth value of a condition other than "eval"? 
In almost all rules of my application needs to test conditions, and it takes ages to run using "eval". 

2) Say I have a java method which returns a boolean, and I have used it within an "eval" function. (eg: eval(message.emptyMessageFinder()) )
This "emptyMessageFinder()" method will return a "boolean" if there's an empty message. This function is containing many loops and recursive operations.

Will I get a performance improvement if I alternate the above such that the "emptyMessageFinder()" method sets a boolean attribute (anyEmptyMessage)
in the Message class to true and false, and I'm using following in my drl.

when 
   m: Message()
   m.emptyMessageFinder()
   eval(m.anyEmptyMessage)  //can I use eval here??
......

If someone can answer these questions it would be a great help!

Thank you in advance!

-- 
Best Regards,
Nirmal

C.S.Nirmal J. Fernando
Department of Computer Science & Engineering,
Faculty of Engineering,
University of Moratuwa,
Sri Lanka.

Blog: http://nirmalfdo.blogspot.com/

_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20101116/f6e24d49/attachment.html 


More information about the rules-users mailing list