Search in sources :

Example 1 with QueryExecutor

use of org.xwiki.query.QueryExecutor in project xwiki-platform by xwiki.

the class ConfiguredQueryExecutorProvider method init.

/**
 * Switch the queryExecutor based on what main store is being used. This is called lazily because the XWikiContext
 * might not yet exist when this class is instantiated.
 */
private void init() {
    final XWikiContext context;
    try {
        context = (XWikiContext) this.exec.getContext().getProperty("xwikicontext");
    } catch (NullPointerException e) {
        this.logger.warn("The QueryExecutor was called without an XWikiContext available. " + "This means the old core (and likely the storage engine) is probably " + "not yet initialized. The default QueryExecutor will be returned.", e);
        return;
    }
    final String storeName = context.getWiki().Param("xwiki.store.main.hint", "default");
    try {
        this.queryExecutor = this.manager.getInstance(QueryExecutor.class, storeName);
    } catch (ComponentLookupException e) {
        this.logger.warn("Could not find a QueryExecutor with hint [{}] which is the hint for the storage engine, " + "defined in your XWiki configuration under the [xwiki.store.main.hint] property. " + "The default QueryExecutor will be used instead. Reason: [{}]", storeName, ExceptionUtils.getRootCauseMessage(e));
    }
    this.initialized = true;
}
Also used : QueryExecutor(org.xwiki.query.QueryExecutor) XWikiContext(com.xpn.xwiki.XWikiContext) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException)

Aggregations

XWikiContext (com.xpn.xwiki.XWikiContext)1 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)1 QueryExecutor (org.xwiki.query.QueryExecutor)1