Search in sources :

Example 11 with Api

use of org.apache.solr.api.Api in project lucene-solr by apache.

the class PluginBag method put.

PluginHolder<T> put(String name, PluginHolder<T> plugin) {
    Boolean registerApi = null;
    Boolean disableHandler = null;
    if (plugin.pluginInfo != null) {
        String registerAt = plugin.pluginInfo.attributes.get("registerPath");
        if (registerAt != null) {
            List<String> strs = StrUtils.splitSmart(registerAt, ',');
            disableHandler = !strs.contains("/solr");
            registerApi = strs.contains("/v2");
        }
    }
    if (apiBag != null) {
        if (plugin.isLoaded()) {
            T inst = plugin.get();
            if (inst instanceof ApiSupport) {
                ApiSupport apiSupport = (ApiSupport) inst;
                if (registerApi == null)
                    registerApi = apiSupport.registerV2();
                if (disableHandler == null)
                    disableHandler = !apiSupport.registerV1();
                if (registerApi) {
                    Collection<Api> apis = apiSupport.getApis();
                    if (apis != null) {
                        Map<String, String> nameSubstitutes = singletonMap(HANDLER_NAME, name);
                        for (Api api : apis) {
                            apiBag.register(api, nameSubstitutes);
                        }
                    }
                }
            }
        } else {
            if (registerApi != null && registerApi)
                apiBag.registerLazy((PluginHolder<SolrRequestHandler>) plugin, plugin.pluginInfo);
        }
    }
    if (disableHandler == null)
        disableHandler = Boolean.FALSE;
    PluginHolder<T> old = null;
    if (!disableHandler)
        old = registry.put(name, plugin);
    if (plugin.pluginInfo != null && plugin.pluginInfo.isDefault())
        setDefault(name);
    if (plugin.isLoaded())
        registerMBean(plugin.get(), core, name);
    return old;
}
Also used : ApiSupport(org.apache.solr.api.ApiSupport) Api(org.apache.solr.api.Api)

Aggregations

Api (org.apache.solr.api.Api)11 SolrQueryResponse (org.apache.solr.response.SolrQueryResponse)7 HashMap (java.util.HashMap)5 ApiBag (org.apache.solr.api.ApiBag)5 CompositeApi (org.apache.solr.api.V2HttpCall.CompositeApi)3 CommandOperation (org.apache.solr.common.util.CommandOperation)3 LocalSolrQueryRequest (org.apache.solr.request.LocalSolrQueryRequest)3 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)3 Map (java.util.Map)2 SolrException (org.apache.solr.common.SolrException)2 SolrParams (org.apache.solr.common.params.SolrParams)2 Utils.fromJSONString (org.apache.solr.common.util.Utils.fromJSONString)2 CoreContainer (org.apache.solr.core.CoreContainer)2 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 ReqHandlerToApi (org.apache.solr.api.ApiBag.ReqHandlerToApi)1 ApiSupport (org.apache.solr.api.ApiSupport)1 SpecProvider (org.apache.solr.api.SpecProvider)1 SolrRequest (org.apache.solr.client.solrj.SolrRequest)1