Hi Paul,

On Aug 24, 2012, at 4:33 PM, Paul Libbrecht <[email protected]> wrote:

> 
> Hello developers,
> 
> I've been experimenting a little bit into running things in the background on 
> our xwiki 3.5: as part of a velocity delivered page, I am calling groovy 
> code. That code launches a thread in the background which runs for 1000 
> seconds checking if it can:
> - use the context's toString
> - call context.getContext()
> - use the xwiki object that was passed around
> 
> 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.

-Vincent


_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to