[xwiki-devs] Initialize XWikiContext in a servlet filter
Hi devs, I recently wrote a small servlet that receives GWT requests, calls the component that matches the request and sends back the result. It works fine with components that don't use the XWikiContext. For those components that use it, like DocumentAccessBridge, I need to initialize the XWikiContext. I looked in XWikiServiceImpl (web-gwt) and XWikiAction (xwiki-core) to see how it's done. Most of the initialization code is duplicated and since I don't want to increase the redundancy I was wondering if we could have a servlet filter to do the (generic) initialization instead. WDYT? Thanks, Marius
Marius Dumitru Florea wrote:
Hi devs,
I recently wrote a small servlet that receives GWT requests, calls the component that matches the request and sends back the result. It works fine with components that don't use the XWikiContext. For those components that use it, like DocumentAccessBridge, I need to initialize the XWikiContext. I looked in XWikiServiceImpl (web-gwt) and XWikiAction (xwiki-core) to see how it's done. Most of the initialization code is duplicated and since I don't want to increase the redundancy I was wondering if we could have a servlet filter to do the (generic) initialization instead. WDYT?
This http://pastebin.com/m49feb3a5 works fine for me right now. Marius
Thanks, Marius _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Hi Marius and all devs On 10/28/2009 09:44 AM, Marius Dumitru Florea wrote:
Marius Dumitru Florea wrote:
Hi devs,
I recently wrote a small servlet that receives GWT requests, calls the component that matches the request and sends back the result. It works fine with components that don't use the XWikiContext. For those components that use it, like DocumentAccessBridge, I need to initialize the XWikiContext. I looked in XWikiServiceImpl (web-gwt) and XWikiAction (xwiki-core) to see how it's done. Most of the initialization code is duplicated and since I don't want to increase the redundancy I was wondering if we could have a servlet filter to do the (generic) initialization instead. WDYT?
This http://pastebin.com/m49feb3a5 works fine for me right now.
so if this works fine, then it could also fix http://jira.xwiki.org/jira/browse/XWIKI-3009 _correctly_ (see last comment), wouldn't it? I thought this was a difficult problem, and this solution is obvious and simple, are we missing any implications? Thanks, Anca
Marius
Thanks, Marius _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
Anca Luca wrote:
Hi Marius and all devs
On 10/28/2009 09:44 AM, Marius Dumitru Florea wrote:
Marius Dumitru Florea wrote:
Hi devs,
I recently wrote a small servlet that receives GWT requests, calls the component that matches the request and sends back the result. It works fine with components that don't use the XWikiContext. For those components that use it, like DocumentAccessBridge, I need to initialize the XWikiContext. I looked in XWikiServiceImpl (web-gwt) and XWikiAction (xwiki-core) to see how it's done. Most of the initialization code is duplicated and since I don't want to increase the redundancy I was wondering if we could have a servlet filter to do the (generic) initialization instead. WDYT? This http://pastebin.com/m49feb3a5 works fine for me right now.
so if this works fine, then it could also fix http://jira.xwiki.org/jira/browse/XWIKI-3009 _correctly_ (see last comment), wouldn't it?
If we map the initialization filter to the action servlet and make sure it is called before the conversion filter then I'd say yes. We should keep only the specific context initialization in XWikiAction (e.g. setting the current document on the context and the current action based on the request URL). Thanks, Marius
I thought this was a difficult problem, and this solution is obvious and simple, are we missing any implications?
Thanks, Anca
On 10/28/2009 11:56 AM, Marius Dumitru Florea wrote:
Anca Luca wrote:
Hi Marius and all devs
On 10/28/2009 09:44 AM, Marius Dumitru Florea wrote:
Marius Dumitru Florea wrote:
Hi devs,
I recently wrote a small servlet that receives GWT requests, calls the component that matches the request and sends back the result. It works fine with components that don't use the XWikiContext. For those components that use it, like DocumentAccessBridge, I need to initialize the XWikiContext. I looked in XWikiServiceImpl (web-gwt) and XWikiAction (xwiki-core) to see how it's done. Most of the initialization code is duplicated and since I don't want to increase the redundancy I was wondering if we could have a servlet filter to do the (generic) initialization instead. WDYT? This http://pastebin.com/m49feb3a5 works fine for me right now.
so if this works fine, then it could also fix http://jira.xwiki.org/jira/browse/XWIKI-3009 _correctly_ (see last comment), wouldn't it?
If we map the initialization filter to the action servlet and make sure it is called before the conversion filter then I'd say yes. We should keep only the specific context initialization in XWikiAction (e.g. setting the current document on the context and the current action based on the request URL).
I think the fix for XWIKI-3009 would need the document set on the context as well, but that could be also moved in a filter since it can be computed only from the request, same for the action. Thanks, Anca
Thanks, Marius
I thought this was a difficult problem, and this solution is obvious and simple, are we missing any implications?
Thanks, Anca
devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
participants (2)
-
Anca Luca -
Marius Dumitru Florea