diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java index 580849ae478..11e693deb8d 100644 --- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java +++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java @@ -107,13 +107,13 @@ public class CoreContainer { public static final String COLLECTIONS_HANDLER_PATH = "/admin/collections"; public static final String INFO_HANDLER_PATH = "/admin/info"; - private PluginRegistry containerHandlers = new PluginRegistry<>(SolrRequestHandler.class, null); + private PluginBag containerHandlers = new PluginBag<>(SolrRequestHandler.class, null); public SolrRequestHandler getRequestHandler(String path) { return RequestHandlerBase.getRequestHandler(path, containerHandlers); } - public PluginRegistry getRequestHandlers() { + public PluginBag getRequestHandlers() { return this.containerHandlers; } diff --git a/solr/core/src/java/org/apache/solr/core/MemClassLoader.java b/solr/core/src/java/org/apache/solr/core/MemClassLoader.java index 6c28dafeeb4..2e6eb170a29 100644 --- a/solr/core/src/java/org/apache/solr/core/MemClassLoader.java +++ b/solr/core/src/java/org/apache/solr/core/MemClassLoader.java @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicReference; import org.apache.lucene.analysis.util.ResourceLoader; @@ -42,11 +41,11 @@ public class MemClassLoader extends ClassLoader implements AutoCloseable, Resour static final Logger log = LoggerFactory.getLogger(MemClassLoader.class); private boolean allJarsLoaded = false; private final SolrResourceLoader parentLoader; - private List libs = new ArrayList<>(); + private List libs = new ArrayList<>(); private Map classCache = new HashMap<>(); - public MemClassLoader(List libs, SolrResourceLoader resourceLoader) { + public MemClassLoader(List libs, SolrResourceLoader resourceLoader) { this.parentLoader = resourceLoader; this.libs = libs; } @@ -55,7 +54,7 @@ public class MemClassLoader extends ClassLoader implements AutoCloseable, Resour public synchronized void loadJars() { if (allJarsLoaded) return; - for (PluginRegistry.RuntimeLib lib : libs) { + for (PluginBag.RuntimeLib lib : libs) { try { lib.loadJar(); } catch (Exception exception) { @@ -113,7 +112,7 @@ public class MemClassLoader extends ClassLoader implements AutoCloseable, Resour String path = name.replace('.', '/').concat(".class"); ByteBuffer buf = null; - for (PluginRegistry.RuntimeLib lib : libs) { + for (PluginBag.RuntimeLib lib : libs) { try { buf = lib.getFileContent(path); if (buf != null) { @@ -130,7 +129,7 @@ public class MemClassLoader extends ClassLoader implements AutoCloseable, Resour @Override public void close() throws Exception { - for (PluginRegistry.RuntimeLib lib : libs) { + for (PluginBag.RuntimeLib lib : libs) { try { lib.close(); } catch (Exception e) { diff --git a/solr/core/src/java/org/apache/solr/core/PluginRegistry.java b/solr/core/src/java/org/apache/solr/core/PluginBag.java similarity index 98% rename from solr/core/src/java/org/apache/solr/core/PluginRegistry.java rename to solr/core/src/java/org/apache/solr/core/PluginBag.java index 850d44e26ee..059df44ca93 100644 --- a/solr/core/src/java/org/apache/solr/core/PluginRegistry.java +++ b/solr/core/src/java/org/apache/solr/core/PluginBag.java @@ -39,13 +39,11 @@ import org.apache.solr.util.plugin.SolrCoreAware; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static java.util.Collections.singletonList; - /** * This manages the lifecycle of a set of plugin of the same type . */ -public class PluginRegistry implements AutoCloseable { - public static Logger log = LoggerFactory.getLogger(PluginRegistry.class); +public class PluginBag implements AutoCloseable { + public static Logger log = LoggerFactory.getLogger(PluginBag.class); private Map> registry = new HashMap<>(); private Map> immutableRegistry = Collections.unmodifiableMap(registry); @@ -54,7 +52,7 @@ public class PluginRegistry implements AutoCloseable { private SolrCore core; private SolrConfig.SolrPluginInfo meta; - public PluginRegistry(Class klass, SolrCore core) { + public PluginBag(Class klass, SolrCore core) { this.core = core; this.klass = klass; meta = SolrConfig.classVsSolrPluginInfo.get(klass.getName()); diff --git a/solr/core/src/java/org/apache/solr/core/RequestHandlers.java b/solr/core/src/java/org/apache/solr/core/RequestHandlers.java index 5bd12093bb1..44fa89d5e0d 100644 --- a/solr/core/src/java/org/apache/solr/core/RequestHandlers.java +++ b/solr/core/src/java/org/apache/solr/core/RequestHandlers.java @@ -35,7 +35,7 @@ public final class RequestHandlers { protected final SolrCore core; - final PluginRegistry handlers; + final PluginBag handlers; /** * Trim the trailing '/' if it's there, and convert null to empty string. @@ -57,7 +57,7 @@ public final class RequestHandlers { public RequestHandlers(SolrCore core) { this.core = core; - handlers = new PluginRegistry<>(SolrRequestHandler.class, core); + handlers = new PluginBag<>(SolrRequestHandler.class, core); } /** @@ -88,7 +88,7 @@ public final class RequestHandlers { /** * Returns an unmodifiable Map containing the registered handlers */ - public PluginRegistry getRequestHandlers() { + public PluginBag getRequestHandlers() { return handlers; } diff --git a/solr/core/src/java/org/apache/solr/core/SolrConfig.java b/solr/core/src/java/org/apache/solr/core/SolrConfig.java index 408856a347d..04586358024 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrConfig.java +++ b/solr/core/src/java/org/apache/solr/core/SolrConfig.java @@ -26,7 +26,6 @@ import org.apache.solr.cloud.ZkSolrResourceLoader; import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.cloud.ZkNodeProps; -import org.apache.solr.common.util.NamedList; import org.apache.solr.handler.component.SearchComponent; import org.apache.solr.request.SolrRequestHandler; import org.apache.solr.response.QueryResponseWriter; @@ -76,14 +75,11 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import static java.util.Collections.unmodifiableMap; -import static org.apache.solr.common.params.CoreAdminParams.NAME; import static org.apache.solr.core.SolrConfig.PluginOpts.LAZY; import static org.apache.solr.core.SolrConfig.PluginOpts.MULTI_OK; import static org.apache.solr.core.SolrConfig.PluginOpts.NOOP; import static org.apache.solr.core.SolrConfig.PluginOpts.REQUIRE_CLASS; import static org.apache.solr.core.SolrConfig.PluginOpts.REQUIRE_NAME; -import static org.apache.solr.schema.FieldType.CLASS_NAME; /** @@ -311,7 +307,7 @@ public class SolrConfig extends Config implements MapSerializable{ // and even then -- only if there is a single SpellCheckComponent // because of queryConverter.setIndexAnalyzer .add(new SolrPluginInfo(QueryConverter.class, "queryConverter", REQUIRE_NAME, REQUIRE_CLASS)) - .add(new SolrPluginInfo(PluginRegistry.RuntimeLib.class, "runtimeLib", REQUIRE_NAME, MULTI_OK)) + .add(new SolrPluginInfo(PluginBag.RuntimeLib.class, "runtimeLib", REQUIRE_NAME, MULTI_OK)) // this is hackish, since it picks up all SolrEventListeners, // regardless of when/how/why they are used (or even if they are // declared outside of the appropriate context) but there's no nice diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java index 2ae596fd107..e1ae0ba87ae 100644 --- a/solr/core/src/java/org/apache/solr/core/SolrCore.java +++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java @@ -175,7 +175,7 @@ public final class SolrCore implements SolrInfoMBean, Closeable { private final long startTime; private final RequestHandlers reqHandlers; - private final PluginRegistry searchComponents = new PluginRegistry<>(SearchComponent.class, this); + private final PluginBag searchComponents = new PluginBag<>(SearchComponent.class, this); private final Map updateProcessorChains; private final Map infoRegistry; private IndexDeletionPolicyWrapper solrDelPolicy; @@ -788,7 +788,7 @@ public final class SolrCore implements SolrInfoMBean, Closeable { directoryFactory = solrCoreState.getDirectoryFactory(); this.isReloaded = true; } - memClassLoader = new MemClassLoader(PluginRegistry.RuntimeLib.getLibObjects(this, solrConfig.getPluginInfos(PluginRegistry.RuntimeLib.class.getName())), getResourceLoader()); + memClassLoader = new MemClassLoader(PluginBag.RuntimeLib.getLibObjects(this, solrConfig.getPluginInfos(PluginBag.RuntimeLib.class.getName())), getResourceLoader()); initIndex(prev != null); initWriters(); @@ -1249,7 +1249,7 @@ public final class SolrCore implements SolrInfoMBean, Closeable { /** * Returns an unmodifiable Map containing the registered handlers */ - public PluginRegistry getRequestHandlers() { + public PluginBag getRequestHandlers() { return reqHandlers.handlers; } @@ -1305,7 +1305,7 @@ public final class SolrCore implements SolrInfoMBean, Closeable { * Accessor for all the Search Components * @return An unmodifiable Map of Search Components */ - public PluginRegistry getSearchComponents() { + public PluginBag getSearchComponents() { return searchComponents; } @@ -2050,11 +2050,11 @@ public final class SolrCore implements SolrInfoMBean, Closeable { SolrException.log(log,null,e); } - public PluginRegistry getResponseWriters() { + public PluginBag getResponseWriters() { return responseWriters; } - private final PluginRegistry responseWriters = new PluginRegistry<>(QueryResponseWriter.class, this); + private final PluginBag responseWriters = new PluginBag<>(QueryResponseWriter.class, this); public static final Map DEFAULT_RESPONSE_WRITERS ; static{ HashMap m= new HashMap<>(); @@ -2119,15 +2119,15 @@ public final class SolrCore implements SolrInfoMBean, Closeable { } - private final PluginRegistry qParserPlugins = new PluginRegistry<>(QParserPlugin.class, this); + private final PluginBag qParserPlugins = new PluginBag<>(QParserPlugin.class, this); public QParserPlugin getQueryPlugin(String parserName) { return qParserPlugins.get(parserName); } - private final PluginRegistry valueSourceParsers = new PluginRegistry<>(ValueSourceParser.class, this); + private final PluginBag valueSourceParsers = new PluginBag<>(ValueSourceParser.class, this); - private final PluginRegistry transformerFactories = new PluginRegistry<>(TransformerFactory.class, this); + private final PluginBag transformerFactories = new PluginBag<>(TransformerFactory.class, this); Map createInstances(Map> map) { Map result = new LinkedHashMap<>(); diff --git a/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java b/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java index a1391dbc113..c79cea69035 100644 --- a/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java +++ b/solr/core/src/java/org/apache/solr/handler/RequestHandlerBase.java @@ -22,7 +22,7 @@ import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.SimpleOrderedMap; import org.apache.solr.core.PluginInfo; -import org.apache.solr.core.PluginRegistry; +import org.apache.solr.core.PluginBag; import org.apache.solr.core.SolrCore; import org.apache.solr.core.SolrInfoMBean; import org.apache.solr.request.SolrQueryRequest; @@ -35,7 +35,6 @@ import org.apache.solr.util.stats.Timer; import org.apache.solr.util.stats.TimerContext; import java.net.URL; -import java.util.Map; import java.util.concurrent.atomic.AtomicLong; import static org.apache.solr.core.RequestParams.USEPARAM; @@ -214,7 +213,7 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo * * This function is thread safe. */ - public static SolrRequestHandler getRequestHandler(String handlerName, PluginRegistry reqHandlers) { + public static SolrRequestHandler getRequestHandler(String handlerName, PluginBag reqHandlers) { if(handlerName == null) return null; SolrRequestHandler handler = reqHandlers.get(handlerName); int idx = 0; diff --git a/solr/core/src/test/org/apache/solr/OutputWriterTest.java b/solr/core/src/test/org/apache/solr/OutputWriterTest.java index f58b6cafbeb..26023758481 100644 --- a/solr/core/src/test/org/apache/solr/OutputWriterTest.java +++ b/solr/core/src/test/org/apache/solr/OutputWriterTest.java @@ -22,7 +22,7 @@ import java.io.Writer; import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.util.NamedList; -import org.apache.solr.core.PluginRegistry; +import org.apache.solr.core.PluginBag; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.response.QueryResponseWriter; import org.apache.solr.response.SolrQueryResponse; @@ -91,12 +91,12 @@ public class OutputWriterTest extends SolrTestCaseJ4 { } public void testLazy() { - PluginRegistry.PluginHolder qrw = h.getCore().getResponseWriters().getRegistry().get("useless"); - assertTrue("Should be a lazy class", qrw instanceof PluginRegistry.LazyPluginHolder); + PluginBag.PluginHolder qrw = h.getCore().getResponseWriters().getRegistry().get("useless"); + assertTrue("Should be a lazy class", qrw instanceof PluginBag.LazyPluginHolder); qrw = h.getCore().getResponseWriters().getRegistry().get("xml"); assertTrue("Should not be a lazy class", qrw.isLoaded()); - assertTrue("Should not be a lazy class", qrw.getClass() == PluginRegistry.PluginHolder.class); + assertTrue("Should not be a lazy class", qrw.getClass() == PluginBag.PluginHolder.class); } diff --git a/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java b/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java index 815aa6a479a..6d855dde1b0 100644 --- a/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java +++ b/solr/core/src/test/org/apache/solr/core/RequestHandlersTest.java @@ -48,7 +48,7 @@ public class RequestHandlersTest extends SolrTestCaseJ4 { @Test public void testLazyLoading() { SolrCore core = h.getCore(); - PluginRegistry.PluginHolder handler = core.getRequestHandlers().getRegistry().get("lazy"); + PluginBag.PluginHolder handler = core.getRequestHandlers().getRegistry().get("lazy"); assertFalse(handler.isLoaded()); assertU(adoc("id", "42",