Hello XWikiers, do I have a possibility for a plugin to access the classes of another webapp? Can this other webapp maybe offer some services shareable to others? (JNDI?) thanks in advance paul
Paul Libbrecht wrote:
Hello XWikiers,
do I have a possibility for a plugin to access the classes of another webapp? Can this other webapp maybe offer some services shareable to others? (JNDI?)
Can you look at ServletContext#getContext(String)? -- Sergiu Dumitriu http://purl.org/net/sergiu/
thanks Sergiu, yes, that's certainly a solution provided you empower the webapps, at least I know how to do such in tomcat. I was rather looking at something such as JNDI which would be more declarative and thus would escape the critique of Vincent: it would even something rather plexus-friendly where basically I would ask for the "service" of a given interface, and get it provided by the webapp- container because another webapp has installed it. I would know how to do this in plexus but I guess it would mean I need to put in tomcat/lib an amount of the plexus core and, at least, the java-interface I want to call. is that safe for xwiki? maybe... I think I'll do with getContext for now... paul Le 03-avr.-09 à 17:49, Sergiu Dumitriu a écrit :
Paul Libbrecht wrote:
Hello XWikiers,
do I have a possibility for a plugin to access the classes of another webapp? Can this other webapp maybe offer some services shareable to others? (JNDI?)
Can you look at ServletContext#getContext(String)?
-- Sergiu Dumitriu http://purl.org/net/sergiu/ _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Le 03-avr.-09 à 17:49, Sergiu Dumitriu a écrit :
do I have a possibility for a plugin to access the classes of another webapp? Can this other webapp maybe offer some services shareable to others? (JNDI?)
Can you look at ServletContext#getContext(String)?
Right, that would work, along with the crossContext attribute of the configuration of tomcat. But, erm, dumb question, how can I get the ServletContext? I found how to get the request and response but not the servlets or context yet. thanks paul
Paul Libbrecht wrote:
Le 03-avr.-09 à 17:49, Sergiu Dumitriu a écrit :
do I have a possibility for a plugin to access the classes of another webapp? Can this other webapp maybe offer some services shareable to others? (JNDI?)
Can you look at ServletContext#getContext(String)?
Right, that would work, along with the crossContext attribute of the configuration of tomcat.
But, erm, dumb question, how can I get the ServletContext? I found how to get the request and response but not the servlets or context yet.
getRequest().getSession().getServletContext() -- Sergiu Dumitriu http://purl.org/net/sergiu/
And without a request around? I need this for the indexer... that's getting more trick. I guess I could store the context in the plugin statics if I was sure a request would use it first but I am rather sure of the contrary: the indexer will fire first. Is there a way I can access the servlet-context from some xwiki or context objects? thanks in advance paul Le 08-avr.-09 à 11:21, Sergiu Dumitriu a écrit :
But, erm, dumb question, how can I get the ServletContext? I found how to get the request and response but not the servlets or context yet.
getRequest().getSession().getServletContext()
Hi Paul, On May 10, 2009, at 10:57 AM, Paul Libbrecht wrote:
And without a request around? I need this for the indexer... that's getting more trick.
If you mean the lucene indexer then you're inside a daemon thread which has no request/context/Servlet at all and is not supposed to. So you cannot and shouldn't access them. BTW note that if you got access to some request it'll probably be made invalid pretty soon by the servlet container since the container generally invalidates it when the request has been processed completely. The question is: why would you need access to those? Thanks -Vincent
I guess I could store the context in the plugin statics if I was sure a request would use it first but I am rather sure of the contrary: the indexer will fire first. Is there a way I can access the servlet-context from some xwiki or context objects?
thanks in advance
paul
Le 08-avr.-09 à 11:21, Sergiu Dumitriu a écrit :
But, erm, dumb question, how can I get the ServletContext? I found how to get the request and response but not the servlets or context yet.
getRequest().getSession().getServletContext()
Vincent, the reason is simply that the plugin provides services that are done by another web-app. That web-app, in this case, is an index which represents an ontology; it does have and need its own web-access. I only store the result of walking from the request, until the actual other-servlet-context's attribute which can then be stored untill a restart. I just found another surprising way: ((XWikiServletContext) context.getEngineContext()).getServletContext() The cast is potentially dangerous, that's true but it seems to work. I agree storing requests wouldn't be a good idea. paul Le 10-mai-09 à 11:08, Vincent Massol a écrit :
Hi Paul,
On May 10, 2009, at 10:57 AM, Paul Libbrecht wrote:
And without a request around? I need this for the indexer... that's getting more trick.
If you mean the lucene indexer then you're inside a daemon thread which has no request/context/Servlet at all and is not supposed to. So you cannot and shouldn't access them.
BTW note that if you got access to some request it'll probably be made invalid pretty soon by the servlet container since the container generally invalidates it when the request has been processed completely.
The question is: why would you need access to those?
Thanks -Vincent
I guess I could store the context in the plugin statics if I was sure a request would use it first but I am rather sure of the contrary: the indexer will fire first. Is there a way I can access the servlet-context from some xwiki or context objects?
thanks in advance
paul
Le 08-avr.-09 à 11:21, Sergiu Dumitriu a écrit :
But, erm, dumb question, how can I get the ServletContext? I found how to get the request and response but not the servlets or context yet.
getRequest().getSession().getServletContext()
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi Paul, On Apr 3, 2009, at 5:14 PM, Paul Libbrecht wrote:
Hello XWikiers,
do I have a possibility for a plugin to access the classes of another webapp?
AFAIK this is prohibited in the servlet spec. It used to be possible with getServlet() but has been deprecated a long time ago. Maybe there's something new in the new 3.0 spec. (I don't know it). I think it's not a good idea since webapp should be able to be deployed anywhere without making assumptions of deployments (would cause issue in clusters for ex). Thanks -Vincent
Can this other webapp maybe offer some services shareable to others? (JNDI?)
thanks in advance
paul
participants (3)
-
Paul Libbrecht -
Sergiu Dumitriu -
Vincent Massol