[rules-users] Calling a method in when part

Sumeet Karawal sumeet.karawal at tcs.com
Wed Aug 10 05:05:59 EDT 2011


Hi,

I have a requirement where there is a customized Java class having a method
that returns some value.
like:

getValueBoolean("Some String")

{ //some calculation
   // returns a boolean value
}

The default getters and setters are not being used in the Application. The
value that is being returned by the method needs to be checked in the .drl
file.
There are different Java classes with these kind of methods. Where the
string and integer value is also returned. I have gone through the
documentation for Drools-Expert but have only found the implementation for
the method in the consequence part, i.e., the then part.

This is how I tried:

importing the class

in when
binding the a variable to the Class name suppose $c
eval ($c.getValueBoolean("abc"))
then
System.out.println("the value is true")


It didn't work this way.
I tried by another way like :

creating a function in the .drl itself that calls the method of that class
and returns a value
then calling this drl function in the when part and carrying on.

It would be very helpful if some body could let me know how to do this in
the .drl.


Thanks & Regards,
Sumeet Karawal
Mailto: sumeet.karawal at tcs.com

=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you






More information about the rules-users mailing list