Hi all BaseX users ,
Inside a RESTXQ function, I would like to get InitParameters of the ServletContext or ServletConfig instances, I cannot find that in a module. Did I miss something ?
Best regards, Fabrice Etanchaud
Hi Fabrice,
I would like to get InitParameters of the ServletContext or ServletConfig instances,
The servlet init parameters are currently accessed by the BaseX itself [1,2], but there is no way to retrieve them from RESTXQ.
Well, that's only partially true. One way to reach the ServletContext init parrameters is to:
• Write a Java class that extends QueryModule [3] • Access queryContext.http in that class (see e.g. [4]) • Call http.req.getServletContext().getInitParameterNames()
I am not sure, though, if that also works for the ServletConfig parameters (maybe you know?).
What do you want to do with that information? What parameters are you interested in? Christian
[1] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/org/bas... [2] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/org/bas... [3] http://docs.basex.org/wiki/Java_Bindings#Context-Awareness [4] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/org/bas...
Dear Christian, Thank you !
I use RESTXQ to easily transform RDBMS data into XML, And am looking for a way to retrieve configuration parameters like jdbc url, username and password, for example.
How would you initialize persisting variables like a jdbc connection ?
Thank you again for your fantastic job.
Bien à vous, Fabrice
-----Message d'origine----- De : Christian Grün [mailto:christian.gruen@gmail.com] Envoyé : lundi 15 décembre 2014 20:25 À : Fabrice Etanchaud Cc : basex-talk@mailman.uni-konstanz.de Objet : Re: [basex-talk] RESTXQ - access to InitParameters of ServletContext and/or ServletConfig
Hi Fabrice,
I would like to get InitParameters of the ServletContext or ServletConfig instances,
The servlet init parameters are currently accessed by the BaseX itself [1,2], but there is no way to retrieve them from RESTXQ.
Well, that's only partially true. One way to reach the ServletContext init parrameters is to:
• Write a Java class that extends QueryModule [3] • Access queryContext.http in that class (see e.g. [4]) • Call http.req.getServletContext().getInitParameterNames()
I am not sure, though, if that also works for the ServletConfig parameters (maybe you know?).
What do you want to do with that information? What parameters are you interested in? Christian
[1] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/org/bas... [2] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/org/bas... [3] http://docs.basex.org/wiki/Java_Bindings#Context-Awareness [4] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/org/bas...
Hi Fabrice,
How would you initialize persisting variables like a jdbc connection ?
You could simply use the doc(...) function in XQuery and access the document from your web application directory. One more way would be to store the data in a database instance, but this is probably too much of an overhead in your case.
J'espère avoir pu t'aider, Christian
Thank you again for your fantastic job.
Bien à vous, Fabrice
-----Message d'origine----- De : Christian Grün [mailto:christian.gruen@gmail.com] Envoyé : lundi 15 décembre 2014 20:25 À : Fabrice Etanchaud Cc : basex-talk@mailman.uni-konstanz.de Objet : Re: [basex-talk] RESTXQ - access to InitParameters of ServletContext and/or ServletConfig
Hi Fabrice,
I would like to get InitParameters of the ServletContext or ServletConfig instances,
The servlet init parameters are currently accessed by the BaseX itself [1,2], but there is no way to retrieve them from RESTXQ.
Well, that's only partially true. One way to reach the ServletContext init parrameters is to:
• Write a Java class that extends QueryModule [3] • Access queryContext.http in that class (see e.g. [4]) • Call http.req.getServletContext().getInitParameterNames()
I am not sure, though, if that also works for the ServletConfig parameters (maybe you know?).
What do you want to do with that information? What parameters are you interested in? Christian
[1] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/org/bas... [2] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/org/bas... [3] http://docs.basex.org/wiki/Java_Bindings#Context-Awareness [4] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/org/bas...
Merci Christian, I coded my first java module extending QueryModule, and installed it in the repository !
Sorry, I can't speak German, you know how French people are :-(
Best regards, Fabrice
-----Message d'origine----- De : Christian Grün [mailto:christian.gruen@gmail.com] Envoyé : mardi 16 décembre 2014 16:10 À : Fabrice Etanchaud Cc : basex-talk@mailman.uni-konstanz.de Objet : Re: [basex-talk] RESTXQ - access to InitParameters of ServletContext and/or ServletConfig
Hi Fabrice,
How would you initialize persisting variables like a jdbc connection ?
You could simply use the doc(...) function in XQuery and access the document from your web application directory. One more way would be to store the data in a database instance, but this is probably too much of an overhead in your case.
J'espère avoir pu t'aider, Christian
Thank you again for your fantastic job.
Bien à vous, Fabrice
-----Message d'origine----- De : Christian Grün [mailto:christian.gruen@gmail.com] Envoyé : lundi 15 décembre 2014 20:25 À : Fabrice Etanchaud Cc : basex-talk@mailman.uni-konstanz.de Objet : Re: [basex-talk] RESTXQ - access to InitParameters of ServletContext and/or ServletConfig
Hi Fabrice,
I would like to get InitParameters of the ServletContext or ServletConfig instances,
The servlet init parameters are currently accessed by the BaseX itself [1,2], but there is no way to retrieve them from RESTXQ.
Well, that's only partially true. One way to reach the ServletContext init parrameters is to:
• Write a Java class that extends QueryModule [3] • Access queryContext.http in that class (see e.g. [4]) • Call http.req.getServletContext().getInitParameterNames()
I am not sure, though, if that also works for the ServletConfig parameters (maybe you know?).
What do you want to do with that information? What parameters are you interested in? Christian
[1] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/o rg/basex/http/BaseXServlet.java#L38 [2] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/o rg/basex/http/HTTPContext.java#L421 [3] http://docs.basex.org/wiki/Java_Bindings#Context-Awareness [4] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/o rg/basex/modules/Session.java#L142
Sorry, I can't speak German, you know how French people are :-(
But something must have gone wrong: Your English is pretty good ;)
Cheers, Christian
-----Message d'origine----- De : Christian Grün [mailto:christian.gruen@gmail.com] Envoyé : mardi 16 décembre 2014 16:10 À : Fabrice Etanchaud Cc : basex-talk@mailman.uni-konstanz.de Objet : Re: [basex-talk] RESTXQ - access to InitParameters of ServletContext and/or ServletConfig
Hi Fabrice,
How would you initialize persisting variables like a jdbc connection ?
You could simply use the doc(...) function in XQuery and access the document from your web application directory. One more way would be to store the data in a database instance, but this is probably too much of an overhead in your case.
J'espère avoir pu t'aider, Christian
Thank you again for your fantastic job.
Bien à vous, Fabrice
-----Message d'origine----- De : Christian Grün [mailto:christian.gruen@gmail.com] Envoyé : lundi 15 décembre 2014 20:25 À : Fabrice Etanchaud Cc : basex-talk@mailman.uni-konstanz.de Objet : Re: [basex-talk] RESTXQ - access to InitParameters of ServletContext and/or ServletConfig
Hi Fabrice,
I would like to get InitParameters of the ServletContext or ServletConfig instances,
The servlet init parameters are currently accessed by the BaseX itself [1,2], but there is no way to retrieve them from RESTXQ.
Well, that's only partially true. One way to reach the ServletContext init parrameters is to:
• Write a Java class that extends QueryModule [3] • Access queryContext.http in that class (see e.g. [4]) • Call http.req.getServletContext().getInitParameterNames()
I am not sure, though, if that also works for the ServletConfig parameters (maybe you know?).
What do you want to do with that information? What parameters are you interested in? Christian
[1] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/o rg/basex/http/BaseXServlet.java#L38 [2] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/o rg/basex/http/HTTPContext.java#L421 [3] http://docs.basex.org/wiki/Java_Bindings#Context-Awareness [4] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/o rg/basex/modules/Session.java#L142
Maybe it could help other BaseX users :
package questel.basex.modules;
import org.basex.http.HTTPContext; import org.basex.query.*;
public class Parameter extends QueryModule {
@Requires(Permission.NONE) @Deterministic @ContextDependent public String get(String key) { return ((HTTPContext) queryContext.http).req.getServletContext().getInitParameter(key); }
}
Don't forget to add the Main-Class: questel.basex.modules.Parameter line in the jar's MANIFEST. And finally install it in the repository : REPO INSTALL 'your jar filepath'
Best regards, Fabrice
-----Message d'origine----- De : Christian Grün [mailto:christian.gruen@gmail.com] Envoyé : mardi 16 décembre 2014 16:10 À : Fabrice Etanchaud Cc : basex-talk@mailman.uni-konstanz.de Objet : Re: [basex-talk] RESTXQ - access to InitParameters of ServletContext and/or ServletConfig
Hi Fabrice,
How would you initialize persisting variables like a jdbc connection ?
You could simply use the doc(...) function in XQuery and access the document from your web application directory. One more way would be to store the data in a database instance, but this is probably too much of an overhead in your case.
J'espère avoir pu t'aider, Christian
Thank you again for your fantastic job.
Bien à vous, Fabrice
-----Message d'origine----- De : Christian Grün [mailto:christian.gruen@gmail.com] Envoyé : lundi 15 décembre 2014 20:25 À : Fabrice Etanchaud Cc : basex-talk@mailman.uni-konstanz.de Objet : Re: [basex-talk] RESTXQ - access to InitParameters of ServletContext and/or ServletConfig
Hi Fabrice,
I would like to get InitParameters of the ServletContext or ServletConfig instances,
The servlet init parameters are currently accessed by the BaseX itself [1,2], but there is no way to retrieve them from RESTXQ.
Well, that's only partially true. One way to reach the ServletContext init parrameters is to:
• Write a Java class that extends QueryModule [3] • Access queryContext.http in that class (see e.g. [4]) • Call http.req.getServletContext().getInitParameterNames()
I am not sure, though, if that also works for the ServletConfig parameters (maybe you know?).
What do you want to do with that information? What parameters are you interested in? Christian
[1] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/o rg/basex/http/BaseXServlet.java#L38 [2] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/o rg/basex/http/HTTPContext.java#L421 [3] http://docs.basex.org/wiki/Java_Bindings#Context-Awareness [4] https://github.com/BaseXdb/basex/blob/master/basex-api/src/main/java/o rg/basex/modules/Session.java#L142
basex-talk@mailman.uni-konstanz.de