From 785fb11f2ae3a6849fc71d67ffbeb271e5d33986 Mon Sep 17 00:00:00 2001 From: Igor Motov Date: Thu, 14 Apr 2011 20:32:44 -0400 Subject: [PATCH] Allow plugins to provide additional settings. --- .../java/org/elasticsearch/plugins/AbstractPlugin.java | 7 +++++++ .../src/main/java/org/elasticsearch/plugins/Plugin.java | 6 ++++++ .../java/org/elasticsearch/plugins/PluginsService.java | 8 +++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/plugins/AbstractPlugin.java b/modules/elasticsearch/src/main/java/org/elasticsearch/plugins/AbstractPlugin.java index f9e042e55ff..aa1bf8bf168 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/plugins/AbstractPlugin.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/plugins/AbstractPlugin.java @@ -25,6 +25,8 @@ import org.elasticsearch.common.inject.Module; import org.elasticsearch.index.CloseableIndexComponent; import java.util.Collection; +import java.util.Collections; +import java.util.Map; /** * A base class for a plugin. @@ -78,4 +80,9 @@ public abstract class AbstractPlugin implements Plugin { @Override public void processModule(Module module) { // nothing to do here } + + @Override public Map additionalSettings() { + return Collections.emptyMap(); + } + } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/plugins/Plugin.java b/modules/elasticsearch/src/main/java/org/elasticsearch/plugins/Plugin.java index 3c3eff83335..0c8366d23c8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/plugins/Plugin.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/plugins/Plugin.java @@ -24,6 +24,7 @@ import org.elasticsearch.common.inject.Module; import org.elasticsearch.index.CloseableIndexComponent; import java.util.Collection; +import java.util.Map; /** * An extension point allowing to plug in custom functionality. @@ -73,4 +74,9 @@ public interface Plugin { Collection> shardServices(); void processModule(Module module); + + /** + * Additional node settings loaded by the plugin + */ + Map additionalSettings(); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/plugins/PluginsService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/plugins/PluginsService.java index b1f46e433a6..03b03e63d9c 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/plugins/PluginsService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/plugins/PluginsService.java @@ -27,6 +27,7 @@ import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.component.LifecycleComponent; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.inject.Module; +import org.elasticsearch.common.settings.ImmutableSettings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.index.CloseableIndexComponent; @@ -81,7 +82,12 @@ public class PluginsService extends AbstractComponent { } public Settings updatedSettings() { - return this.settings; + ImmutableSettings.Builder builder = ImmutableSettings.settingsBuilder() + .put(this.settings); + for (Plugin plugin : plugins.values()) { + builder.put(plugin.additionalSettings()); + } + return builder.build(); } public Collection> modules() {