Hi Johannes,

> m1 is a Java module, with de.interactive_instruments.module.MyQueryModule 
> being the Java class that extends QueryModule.
> …
> We end up having multiple instances, i.e. Java objects, of class 
> MyQueryModule, …

So the solution which I would recommend (and which I would generally
recommend when importing Java classes) is to write an XQuery wrapper
module for m1, and place the Java imports in that module (see [1] for
an example). This module will only exist once in your query context.
This approach has various other advantages: For example, you can work
with XQuery data types in all other modules, and only the wrapper
needs to ensure that the XQuery parameters will be correctly converted
into and back from Java types.

Does that sound like an option?
Christian

[1] http://docs.basex.org/wiki/Repository#Combined



> -----Ursprüngliche Nachricht-----
> Von: Christian Grün [mailto:christian.gr...@gmail.com]
> Gesendet: Mittwoch, 18. Dezember 2019 15:59
> An: Johannes Echterhoff <echterh...@interactive-instruments.de>
> Cc: BaseX <basex-talk@mailman.uni-konstanz.de>
> Betreff: Re: [basex-talk] How many QueryModule instances can be created?
>
> > It may also answer my second question, where I was referring to expath 
> > packaging and if that would make any difference - when compared to having a 
> > pure JAR with the Java classes (and required libraries). It sounds like 
> > expath packaging does not make a difference. Please correct me if I got 
> > this wrong.
>
> Right: EXPath is just another way of packaging the code. The XQuery parser 
> will handle all modules equally, no matter if they have initially been 
> packaged as XAR or via our own packaging mechanisms.
>
> After having read your initial mail for a second time, I noticed I may have 
> got your setup a little wrong. I think it will be easier to find a solution 
> if we manage to construct a little example that shows the behavior you 
> reported. Otherwise, there may be too many open questions to solve (how do 
> you import and initialize your Java Code? is initialization identical to 
> creating a class instance? is the initialization code embedded in global 
> variables? etc).
>
> I have attached a basic set of files that (I believe) simulates your setup. 
> Could you extend it for me, or comment back what I may have wrongly 
> understood?

Reply via email to