Subject:More about Java extensions and External Functions Author:davide gallo Date:07 Oct 2004 04:11 AM
Hi,
I'm working with XQuery procedures that use to call java classes.
In a precedent topic we talked about calls to Non-Static methods,
and you said that in these cases there is an implicit creation of an
instance of my java class...
Now imagine that this class manages a collection inside itself, and this collection is populated
in the constructor..then imagine that this class as a method getNext(String dummy) to access the next element in this collection..
if i call thi method in Xquery as an external function , each time i call this function the xquery engine will create a NEW() instance of
my class, with this conseguences :
1. New population of the inside collection with loss of performace
2. The method getNext() as no memory of the past (because its class is just new...) and so i get each time the first element
I would know if there is the possibility to manage directly the instances of the external classes created, to reuse the same class for each call of the methods...
I think that a possible solution for me is to ask my class not the NEXT element but exactly the N-elment in a XQuery for cycle but :
i don't know how many elements there are , and each time there is the population tha costs in performace...
Subject:Re: More about Java extensions and External Functions Author:(Deleted User) Date:07 Oct 2004 05:21 AM
Hi Davide,
you are right, a method like getNext() would not work as you expect using
the Stylus XQuery processor. It needs Saxon so that you can create the
object and pass as a parameter to every function invocation.
For the moment, we don't want to follow Saxon on this road, as it implies
extending the XQuery data model to include a "Java object" datatype, or
fake it using some workaround (for instance, Saxon uses a xs:QName object).
If you know that you will be using Saxon 8.1 as your deployment processor,
design your query so that it uses all the extensions it provides; if you
want to design a query that can run on multiple processors, you will need
to avoid using Java extensions completely, and use external variables to
bring data in the query from Java.