You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2021/03/10 09:56:19 UTC
[lucene] 23/42: more cleanup
This is an automated email from the ASF dual-hosted git repository.
dweiss pushed a commit to branch jira/solr14155-1
in repository https://gitbox.apache.org/repos/asf/lucene.git
commit 30dd62dbd4ff0faf6e17c38b75d40046bc8e4476
Author: noblepaul <no...@gmail.com>
AuthorDate: Thu Jul 16 19:18:46 2020 +1000
more cleanup
---
.../src/java/org/apache/solr/core/SolrCore.java | 11 +++++------
.../org/apache/solr/pkg/PackagePluginHolder.java | 7 +++++++
.../java/org/apache/solr/update/UpdateHandler.java | 21 ++++++++++-----------
3 files changed, 22 insertions(+), 17 deletions(-)
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 5a06345..19516eb 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -176,6 +176,7 @@ import org.slf4j.LoggerFactory;
import static org.apache.solr.common.params.CommonParams.NAME;
import static org.apache.solr.common.params.CommonParams.PATH;
+import static org.apache.solr.pkg.PackagePluginHolder.createHolder;
/**
* SolrCore got its name because it represents the "core" of Solr -- one index and everything needed to make it work.
@@ -645,11 +646,11 @@ public final class SolrCore implements SolrInfoBean, Closeable {
for (PluginInfo info : solrConfig.getPluginInfos(SolrEventListener.class.getName())) {
final String event = info.attributes.get("event");
if ("firstSearcher".equals(event)) {
- PluginHolder<SolrEventListener> obj = PackagePluginHolder.createHolder(info, this, SolrEventListener.class, label);
+ PluginHolder<SolrEventListener> obj = createHolder(info, this, SolrEventListener.class, label);
firstSearcherListeners.add(obj);
log.debug("[{}] Added SolrEventListener for firstSearcher: [{}]", logid, obj);
} else if ("newSearcher".equals(event)) {
- PluginHolder<SolrEventListener> obj = PackagePluginHolder.createHolder(info, this, SolrEventListener.class, label);
+ PluginHolder<SolrEventListener> obj = createHolder(info, this, SolrEventListener.class, label);
newSearcherListeners.add(obj);
log.debug("[{}] Added SolrEventListener for newSearcher: [{}]", logid, obj);
}
@@ -667,8 +668,7 @@ public final class SolrCore implements SolrInfoBean, Closeable {
* @see SolrCoreAware
*/
public void registerFirstSearcherListener(SolrEventListener listener) {
- firstSearcherListeners.add(new PluginHolder<>(listener,
- SolrConfig.classVsSolrPluginInfo.get(SolrEventListener.class.getName())));
+ firstSearcherListeners.add(createHolder(listener, this, SolrEventListener.class, null));
}
/**
@@ -679,8 +679,7 @@ public final class SolrCore implements SolrInfoBean, Closeable {
* @see SolrCoreAware
*/
public void registerNewSearcherListener(SolrEventListener listener) {
- newSearcherListeners.add(
- new PluginHolder<>(listener, SolrConfig.classVsSolrPluginInfo.get(SolrEventListener.class.getName())));
+ newSearcherListeners.add(createHolder(listener, this, SolrEventListener.class, null));
}
/**
diff --git a/solr/core/src/java/org/apache/solr/pkg/PackagePluginHolder.java b/solr/core/src/java/org/apache/solr/pkg/PackagePluginHolder.java
index 0c6fd80..50afc71 100644
--- a/solr/core/src/java/org/apache/solr/pkg/PackagePluginHolder.java
+++ b/solr/core/src/java/org/apache/solr/pkg/PackagePluginHolder.java
@@ -19,6 +19,7 @@ package org.apache.solr.pkg;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
+import java.util.Collections;
import org.apache.lucene.analysis.util.ResourceLoaderAware;
import org.apache.solr.common.MapWriter;
@@ -74,6 +75,12 @@ public class PackagePluginHolder<T> extends PluginBag.PluginHolder<T> {
});
}
+ public static <T> PluginBag.PluginHolder<T> createHolder(T inst, SolrCore core, Class<T> type, String msg) {
+ SolrConfig.SolrPluginInfo plugin = SolrConfig.classVsSolrPluginInfo.get(type.getName());
+ PluginInfo info = new PluginInfo(plugin.tag, Collections.singletonMap("class", inst.getClass().getName()));
+ return createHolder(info, core, type, msg);
+
+ }
public static <T> PluginBag.PluginHolder<T> createHolder(PluginInfo info, SolrCore core, Class<T> type, String msg) {
if(info.cName.pkg == null) {
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateHandler.java b/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
index dd275dc..16d64b2 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
@@ -30,6 +30,8 @@ import org.apache.solr.util.plugin.SolrCoreAware;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.apache.solr.pkg.PackagePluginHolder.createHolder;
+
/**
* <code>UpdateHandler</code> handles requests to change the index
* (adds, deletes, commits, optimizes, etc).
@@ -60,11 +62,11 @@ public abstract class UpdateHandler implements SolrInfoBean {
for (PluginInfo info : core.getSolrConfig().getPluginInfos(SolrEventListener.class.getName())) {
String event = info.attributes.get("event");
if ("postCommit".equals(event)) {
- PluginHolder<SolrEventListener> obj = PackagePluginHolder.createHolder(info, core, SolrEventListener.class, label);
+ PluginHolder<SolrEventListener> obj = createHolder(info, core, SolrEventListener.class, label);
commitCallbacks.add(obj);
log.info("added SolrEventListener for postCommit: {}", obj);
} else if ("postOptimize".equals(event)) {
- PluginHolder<SolrEventListener> obj = PackagePluginHolder.createHolder(info, core, SolrEventListener.class, label);
+ PluginHolder<SolrEventListener> obj = createHolder(info, core, SolrEventListener.class, label);
optimizeCallbacks.add(obj);
log.info("added SolrEventListener for postOptimize: {}", obj);
}
@@ -170,9 +172,8 @@ public abstract class UpdateHandler implements SolrInfoBean {
*
* @see SolrCoreAware
*/
- public void registerCommitCallback( SolrEventListener listener )
- {
- commitCallbacks.add( new PluginHolder<>(listener, SolrConfig.classVsSolrPluginInfo.get(SolrEventListener.class.getName())) );
+ public void registerCommitCallback( SolrEventListener listener) {
+ commitCallbacks.add(createHolder(listener, core, SolrEventListener.class,null));
}
/**
@@ -182,9 +183,8 @@ public abstract class UpdateHandler implements SolrInfoBean {
*
* @see SolrCoreAware
*/
- public void registerSoftCommitCallback( SolrEventListener listener )
- {
- softCommitCallbacks.add( new PluginHolder<>(listener, SolrConfig.classVsSolrPluginInfo.get(SolrEventListener.class.getName())) );
+ public void registerSoftCommitCallback( SolrEventListener listener ) {
+ softCommitCallbacks.add(createHolder(listener, core, SolrEventListener.class,null));
}
/**
@@ -194,9 +194,8 @@ public abstract class UpdateHandler implements SolrInfoBean {
*
* @see SolrCoreAware
*/
- public void registerOptimizeCallback( SolrEventListener listener )
- {
- optimizeCallbacks.add( new PluginHolder<>(listener, SolrConfig.classVsSolrPluginInfo.get(SolrEventListener.class.getName())) );
+ public void registerOptimizeCallback( SolrEventListener listener ) {
+ optimizeCallbacks.add(createHolder(listener, core, SolrEventListener.class, null));
}
public abstract void split(SplitIndexCommand cmd) throws IOException;