[rules-users] how to invoke java method with variable arguments from drl file

Wolfgang Laun wolfgang.laun at gmail.com
Thu Mar 8 06:08:16 EST 2012


2012/3/7 Matteo Cusmai <cusmaimatteo at gmail.com>

> From my experience, if you want call a method from then clause, it has to
> be static method.
> Bye bye,
>

Surely you don't mean that only a "static method" can be called in a
consequence?!

Also, using 5.3.0 and 5.4.0.Beta2,.I had no problems with a consequence
    modify( $ms ){ add( "three", "four" ) }
    insert( new MySet( "x", "y" ) );
where both method add and constructor MySet have the signature (String...
strings)

But - as in many other situations - using
   dialect "mvel"
is to be avoided.

-W

Matteo Cusmai
> Il giorno 07/mar/2012 18:10, "womuji" <cmregister at gmail.com> ha scritto:
>
> We are upgrading Drools from 5.1 to 5.3, and running into some issue when
>> invoking a Java method with
>> String variable arguments:
>>
>> methodA(String... params)
>>
>> how do we invoke this in a drl file? We used to call it in 5.1 as:
>>
>> objA.methodA({"string1"});
>>
>> and it works fine. Now in 5.3, it complains that
>>
>> "unable to resolve method using strict-mode:
>> objA.methodA([Ljava.lang.Object;)]"
>>
>> If we tried objA.methodA(new String[]{"string1"});
>> it complains that
>> "unable to resolve method using strict-mode:
>> objA.methodA([Ljava.lang.String;)]"
>>
>> It passes the rule loading if we change to :
>>
>> objA.methodA("string1");
>>
>> but when actually running the rule, we are getting error saying
>> " unable to resolve method methodA(java.lang.String)"
>>
>>
>> --
>> View this message in context:
>> http://drools.46999.n3.nabble.com/how-to-invoke-java-method-with-variable-arguments-from-drl-file-tp3807314p3807314.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
>>
>
> _______________________________________________
> 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/20120308/4a23e19e/attachment.html 


More information about the rules-users mailing list