[rules-users] calling a function in When of DRL

Wolfgang Laun wolfgang.laun at gmail.com
Fri Jan 10 04:11:37 EST 2014


The conditional element eval() expects a boolean expression. See
Expert 6.0.x -- 7.8.3.8. Conditional Element eval, where it also
explains why it is slower.

For combining a void method call with the boolean evaluation, use a
DRL function. See Expert 6.0.x -- 7.6. Function.

function boolean initcomp( Map  map, String s1, String s2 ){
 ...
}

-W


On 10/01/2014, wtang <wtang at kana.com> wrote:
> I need to call a java function in the LHS (When part of the DRL) like so:
>
> When
>
> eval(DataComparator.compare("key1", "key2"))
>
> where key1 and key2 are keys into a Map encapsulated by DataComparator
> class.  How do I pass the Map to the DataComparator class in the first
> place.  Do I have to do like so:
>
> eval(DataComparator.init(Map<String, String> map)
> eval(DataComparator.compare("key1", "key2")
>
> This all seems like a bad hack to me.
>
> What are the standard best practice to achieve what I need?
>
> Also eval are slow why?  is eval the only way to call a function in the
> When
> part?
>
> thx!
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/calling-a-function-in-When-of-DRL-tp4027641.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list