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;
}
Aggregations