Allow plugins to provide additional settings.

This commit is contained in:
Igor Motov 2011-04-14 20:32:44 -04:00 committed by kimchy
parent 85aeaaedd0
commit 785fb11f2a
3 changed files with 20 additions and 1 deletions

View File

@ -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<String, String> additionalSettings() {
return Collections.emptyMap();
}
}

View File

@ -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<Class<? extends CloseableIndexComponent>> shardServices();
void processModule(Module module);
/**
* Additional node settings loaded by the plugin
*/
Map<String, String> additionalSettings();
}

View File

@ -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<Class<? extends Module>> modules() {