hello fellow developers,
at Curriki, we are starting to process XWiki objects in the background using subclasses of
AbstractXWikiRunnable.
Currently I do the following:
// setup
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);
// fetch background info
Document d = xwiki.getDocument(DOCNAME_x);
Object obj = d.getObject("DOCNAME_class");
// modify something
// save
d.save("comment");
However, I wonder if this is the best practice:
- is it expensive to construct a context and xwiki supposing this setup code is run
multiple times?
- is it preferrable to work with the com.xpn.xwiki.* classes?
- is DocReference behaving much differently than fullName if we have a single wiki?
Thanks in advance.
Paul