Vincent,
I am now close to a working version of a background task.
I am launching a thread that has as Runnable an AbstractWikiRunnable.
This process can run and read objects but seems not miss some.
The same code, in using xwiki and context of a page obtains an empty objects
list in the background task and one quite full in the page.
Would this be related to the way I build my AbstractWikiRunnable?
E.g. should I use LucenePlugin's runnable super("xcontext", xcontext) ?
Or would there be another reason that makes the call
xwiki.getDocument("space.name") fail?
For the information, i'm doing:
> XWikiContext xcontext = (XWikiContext)
> Utils.getComponent(Execution.class).getContext()
> .getProperty(XWikiContext.EXECUTIONCONTEXT_KEY);
> Context context = new Context(xcontext);
> XWiki xwiki = new com.xpn.xwiki.api.XWiki(context.getXWiki(),
> xcontext);
thanks in advance
Paul
>> My current conclusion is that context.getContext() fails (with an NPE trying
>> to check programming rights) but others work.
>>
>> Is this the intended behavior?
>> Is there a way for me to get another context to run in the background?
>
> You need to set up the correct environment in your thread as otherwise all
> bets are off :)
>
> We do that in lots of places; just to name a few:
> * The main Servlet thread
> * Stats
> * Lucene Updater and Rebuilder
> * Linkchecker
> * IRCBot thread
>
> In the future I'd like to have common initialization code that can be easily
> reused. We have a bit of this already with AbstractXWikiRunnable which are
> extended by Lucene Updater and Rebuilder threads for example.
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs