[rules-dev] is this a bug? import function not supporting varargs?
Michael Neale
michael.neale at gmail.com
Tue Nov 3 20:44:12 EST 2009
yes my point is the varargs thing probably will not work.
On Wed, Nov 4, 2009 at 4:59 AM, Jane James <jane6210 at yahoo.com> wrote:
> public static void error (RuleContext kcontext, Object... context) {...}
>
> ===>Object... context
>
>
>
>
>
> ----- Original Message ----
> From: Michael Neale <michael.neale at gmail.com>
> To: Rules Dev List <rules-dev at 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 at 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 at 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 at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
>
>
>
> _______________________________________________
> rules-dev mailing list
> rules-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
--
Michael D Neale
home: www.michaelneale.net
blog: michaelneale.blogspot.com
More information about the rules-dev
mailing list