Hi Jane,<br><br>The varargs feature definitely works with 5.0.1. I haven't tried 5.1.0M.<br><br>You can download the working example from <a href="http://code.google.com/p/droolsbook/">http://code.google.com/p/droolsbook/</a><br>
Download the parent-1.0-examples.zip<a href="http://droolsbook.googlecode.com/files/parent-1.0-examples.zip"></a>, 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<br>
<br>You could also try to put the fuction inside the DRL itself as it is shown in validation.drl (code that is commented out)<br><br>BTW the 'Rules Dev List' is not for these type of questions. It is meant for core developers of the Drools platform.<br>
<br>Best regards,<br>Michal<br><br><br><div class="gmail_quote">On Wed, Nov 4, 2009 at 2:44 AM, Michael Neale <span dir="ltr"><<a href="mailto:michael.neale@gmail.com">michael.neale@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
yes my point is the varargs thing probably will not work.<br>
<div><div></div><div class="h5"><br>
On Wed, Nov 4, 2009 at 4:59 AM, Jane James <<a href="mailto:jane6210@yahoo.com">jane6210@yahoo.com</a>> wrote:<br>
> public static void error (RuleContext kcontext, Object... context) {...}<br>
><br>
> ===>Object... context<br>
><br>
><br>
><br>
><br>
><br>
> ----- Original Message ----<br>
> From: Michael Neale <<a href="mailto:michael.neale@gmail.com">michael.neale@gmail.com</a>><br>
> To: Rules Dev List <<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a>><br>
> Sent: Mon, November 2, 2009 11:56:09 PM<br>
> Subject: Re: [rules-dev] is this a bug? import function not supporting varargs?<br>
><br>
> I think there are issues with java5 syntax isms - which varargs is?<br>
><br>
> On Tue, Nov 3, 2009 at 2:17 PM, Jane James <<a href="mailto:jane6210@yahoo.com">jane6210@yahoo.com</a>> wrote:<br>
>> Hi guys,<br>
>> I have a question regarding the import function feature in Drools<br>
>> 5.1.0M.<br>
>><br>
>> I am reading the Drools JBoss Rules 5.0 book Developer's guide by Michal<br>
>> Bali and tried one of the examples but somehow I couldn't get my rules work<br>
>> with the method that has varargs.<br>
>><br>
>> Here's what I have (copied from page 123):<br>
>><br>
>> public class ValidationHelper {<br>
>> public static void error (RuleContext kcontext, Object... context) {<br>
>> KnowledgeRuntime knowledgeRuntime = kcontext.getKnowledgeRuntime();<br>
>> ValidationReport validationReport =<br>
>> (ValidationReport)knowledgeRuntime.getGlobal("validationReport");<br>
>> ReportFactory reportFactory = (ReportFactory)<br>
>> knowledgeRuntime.getGlobal("reportFactory");<br>
>><br>
>> kcontext.insertLogical(reportFactory.createMessage(<br>
>> Message.Type.ERROR, kcontext.getRule().getName(),<br>
>> context));<br>
>> }<br>
>> }<br>
>><br>
>><br>
>> then in my drools file (copied from page 42):<br>
>> i have<br>
>><br>
>> import org.drools.runtime.rule.RuleContext;<br>
>> import function ValidationHelper.error;<br>
>> ...<br>
>> rule test<br>
>> when<br>
>> #condition<br>
>> then<br>
>> error(drools)<br>
>><br>
>><br>
>> but when I ran the test, I got error message:<br>
>><br>
>> Exception in thread "main" org.drools.runtime.rule.ConsequenceException:<br>
>> [Error: unable to resolve method:<br>
>> ValidationHelper.error(org.drools.base.DefaultKnowledgeHelper)<br>
>> [arglength=1]]<br>
>><br>
>> If I remove the parameter Object... context, then everything worked. But I<br>
>> do need the varargs here because I need my error message to be more<br>
>> specific.<br>
>><br>
>> Did anyone else encounter the same problems?<br>
>><br>
>><br>
>> thanks!<br>
>><br>
>> _______________________________________________<br>
>> rules-dev mailing list<br>
>> <a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
>> <a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
>><br>
>><br>
><br>
><br>
><br>
> --<br>
> Michael D Neale<br>
> home: <a href="http://www.michaelneale.net" target="_blank">www.michaelneale.net</a><br>
> blog: <a href="http://michaelneale.blogspot.com" target="_blank">michaelneale.blogspot.com</a><br>
><br>
> _______________________________________________<br>
> rules-dev mailing list<br>
> <a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
><br>
><br>
><br>
><br>
> _______________________________________________<br>
> rules-dev mailing list<br>
> <a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
><br>
<br>
<br>
<br>
--<br>
Michael D Neale<br>
home: <a href="http://www.michaelneale.net" target="_blank">www.michaelneale.net</a><br>
blog: <a href="http://michaelneale.blogspot.com" target="_blank">michaelneale.blogspot.com</a><br>
<br>
_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
</div></div></blockquote></div><br>