Hi Jane,

The varargs feature definitely works with 5.0.1. I haven't tried 5.1.0M.

You can download the working example from http://code.google.com/p/droolsbook/
Download the parent-1.0-examples.zip, extract it and see project validation in droolsBookParent/validation/src/main/resources/validation.drl. To test it you can run the unit test in droolsBookParent/validation/src/test/java/droolsbook/bank/service/impl/ValidationTest

You could also try to put the fuction inside the DRL itself as it is shown in validation.drl (code that is commented out)

BTW the 'Rules Dev List' is not for these type of questions. It is meant for core developers of the Drools platform.

Best regards,
Michal


On Wed, Nov 4, 2009 at 2:44 AM, Michael Neale <michael.neale@gmail.com> wrote:
yes my point is the varargs thing probably will not work.

On Wed, Nov 4, 2009 at 4:59 AM, Jane James <jane6210@yahoo.com> wrote:
>  public static void error (RuleContext kcontext, Object... context) {...}
>
> ===>Object... context
>
>
>
>
>
> ----- Original Message ----
> From: Michael Neale <michael.neale@gmail.com>
> To: Rules Dev List <rules-dev@lists.jboss.org>
> Sent: Mon, November 2, 2009 11:56:09 PM
> Subject: Re: [rules-dev] is this a bug? import function not supporting varargs?
>
> I think there are issues with java5 syntax isms - which varargs is?
>
> On Tue, Nov 3, 2009 at 2:17 PM, Jane James <jane6210@yahoo.com> wrote:
>> Hi guys,
>>     I have a question regarding the import function feature in Drools
>> 5.1.0M.
>>
>>     I am reading the Drools JBoss Rules 5.0 book Developer's guide by Michal
>> Bali and tried one of the examples but somehow I couldn't get my rules work
>> with the method that has varargs.
>>
>> Here's what I have (copied from page 123):
>>
>> public class ValidationHelper {
>>     public static void error (RuleContext kcontext, Object... context) {
>>         KnowledgeRuntime knowledgeRuntime = kcontext.getKnowledgeRuntime();
>>         ValidationReport validationReport =
>> (ValidationReport)knowledgeRuntime.getGlobal("validationReport");
>>         ReportFactory reportFactory = (ReportFactory)
>> knowledgeRuntime.getGlobal("reportFactory");
>>
>>         kcontext.insertLogical(reportFactory.createMessage(
>>                 Message.Type.ERROR, kcontext.getRule().getName(),
>>                 context));
>>     }
>> }
>>
>>
>> then in my drools file (copied from page 42):
>> i have
>>
>> import org.drools.runtime.rule.RuleContext;
>> import function ValidationHelper.error;
>> ...
>> rule test
>> when
>>   #condition
>> then
>>     error(drools)
>>
>>
>> but when I ran the test, I got error message:
>>
>> Exception in thread "main" org.drools.runtime.rule.ConsequenceException:
>> [Error: unable to resolve method:
>> ValidationHelper.error(org.drools.base.DefaultKnowledgeHelper)
>> [arglength=1]]
>>
>> If I remove the parameter Object... context, then everything worked. But I
>> do need the varargs here because I need my error message to be more
>> specific.
>>
>> Did anyone else encounter the same problems?
>>
>>
>> thanks!
>>
>> _______________________________________________
>> rules-dev mailing list
>> rules-dev@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-dev
>>
>>
>
>
>
> --
> Michael D Neale
> home: www.michaelneale.net
> blog: michaelneale.blogspot.com
>
> _______________________________________________
> rules-dev mailing list
> rules-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
>
>
>
> _______________________________________________
> rules-dev mailing list
> rules-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>



--
Michael D Neale
home: www.michaelneale.net
blog: michaelneale.blogspot.com

_______________________________________________
rules-dev mailing list
rules-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev