Search in sources :

Example 1 with ApiSupport

use of org.apache.solr.api.ApiSupport 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)1 ApiSupport (org.apache.solr.api.ApiSupport)1