Add a constant for the gerrit plugin name

We use "gerrit" as a plugin name when a plugin extension point is
implemented by Gerrit core. The string for this plugin name was
hard-coded in many places. It is better to have a constant for this.

Change-Id: I032812d4f6e8d63197cd36e3b0399f60094725cf
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-08-30 20:34:06 +02:00
parent 1609a936d2
commit 5b337c20e8
16 changed files with 64 additions and 25 deletions

View File

@@ -18,6 +18,7 @@ import com.google.common.cache.Cache;
import com.google.common.cache.CacheStats;
import com.google.common.collect.ImmutableSet;
import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.registration.PluginName;
import com.google.gerrit.metrics.CallbackMetric;
import com.google.gerrit.metrics.CallbackMetric1;
import com.google.gerrit.metrics.Description;
@@ -95,7 +96,7 @@ public class CacheMetrics {
}
private static String metricNameOf(DynamicMap.Entry<Cache<?, ?>> e) {
if ("gerrit".equals(e.getPluginName())) {
if (PluginName.GERRIT.equals(e.getPluginName())) {
return e.getExportName();
}
return String.format("plugin/%s/%s", e.getPluginName(), e.getExportName());

View File

@@ -18,6 +18,7 @@ import com.google.common.base.Strings;
import com.google.common.cache.RemovalListener;
import com.google.common.cache.RemovalNotification;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.extensions.registration.PluginName;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
@@ -36,7 +37,7 @@ public class ForwardingRemovalListener<K, V> implements RemovalListener<K, V> {
private final DynamicSet<CacheRemovalListener> listeners;
private final String cacheName;
private String pluginName = "gerrit";
private String pluginName = PluginName.GERRIT;
@Inject
ForwardingRemovalListener(