From commons-user-return-13684-apmail-jakarta-commons-user-archive=jakarta.apache.org@jakarta.apache.org Mon Sep 19 17:59:24 2005 Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 31397 invoked from network); 19 Sep 2005 17:59:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Sep 2005 17:59:23 -0000 Received: (qmail 31628 invoked by uid 500); 19 Sep 2005 17:59:15 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 31544 invoked by uid 500); 19 Sep 2005 17:59:14 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 31531 invoked by uid 99); 19 Sep 2005 17:59:14 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Sep 2005 10:59:14 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [68.142.201.239] (HELO web30511.mail.mud.yahoo.com) (68.142.201.239) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 19 Sep 2005 10:59:22 -0700 Received: (qmail 92211 invoked by uid 60001); 19 Sep 2005 17:59:09 -0000 Message-ID: <20050919175909.92209.qmail@web30511.mail.mud.yahoo.com> Received: from [198.204.133.208] by web30511.mail.mud.yahoo.com via HTTP; Mon, 19 Sep 2005 10:59:09 PDT X-RocketYMMF: dplotnik Date: Mon, 19 Sep 2005 10:59:09 -0700 (PDT) From: Dmitri Plotnikov Reply-To: dmitri@apache.org Subject: Re: [JXPath] Standard extension functions stop working after registering custom extension functions To: Jakarta Commons Users List In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Luis, By calling setFunctions with a custom set of functions, you in fact override the default behavior completely (which you should be able to do). To preserve the default behavior, do this: FunctionLibrary lib = new FunctionLibrary(); lib.addFunctions(new ClassFunctions(MyFunctions.class, "myfunc")); lib.addFunctions(new PackageFunctions("", null)); // default jx_ctx.setFunctions(lib); I hope this helps, - Dmitri --- Luis Neves wrote: > > Hello all, > After registering custom extension functions I'm not able to call > instance methods on > objects. > > ******************************************************** > public class MyBean > { > public String echo(String input) > { > return input; > } > } > > ******************************************************** > public class MyFunctions > { > public long add(int a, int b) > { > return a + b; > } > } > ******************************************************** > import org.apache.commons.jxpath.ClassFunctions; > import org.apache.commons.jxpath.JXPathContext; > > public class JxPathTests > { > public static void main(String[] args) > { > JXPathContext jx_ctx = JXPathContext.newContext(null); > jx_ctx.getVariables().declareVariable("bean", new MyBean()); > > // This works > System.out.println(jx_ctx.getValue("echo($bean, 'foobar')")); > > // Lets register a "function" and see what happens > jx_ctx.setFunctions(new ClassFunctions(MyFunctions.class, > "myfunc")); > > // It does not work anymore > System.out.println(jx_ctx.getValue("echo($bean, 'foobar')")); > } > } > > ******************************************************** > > Is this a bug? Am I misunderstanding something? > > Thanks in advance. > > Luis Neves > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-user-help@jakarta.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org