Hei hei,
The goal is to have this as an XWiki extension, so that it can be either bundled within a custom WAR, or installed through the extension manager.
Right now, I have a working PoC that uses an event listener on ApplicationStartedEvent
for initializing the main wiki. The listener will basically craft stub requests to initialize the context and the wiki.
ServletEnvironment servletEnvironment = (ServletEnvironment) environment;
XWikiEngineContext engineContext = new XWikiServletContext(servletEnvironment.getServletContext());
XWikiContext context = Utils.prepareContext(ACTION, new XWikiServletRequestStub(),
new XWikiServletResponseStub(), engineContext);
context.setMode(XWikiContext.MODE_SERVLET);
containerInitializer.initializeRequest(context.getRequest().getHttpServletRequest(), context);
containerInitializer.initializeResponse(context.getResponse());
containerInitializer.initializeSession(context.getRequest().getHttpServletRequest());
XWiki.getXWiki(false, context);
Right now, this solution works great for the initialization of local XWiki instances, but I need to check how the URLFactories get initialized.
Thanks,