fix not called processModule on plugin for index and shard level modules

This commit is contained in:
kimchy 2010-09-03 19:06:11 +03:00
parent 1079941397
commit 3d30b9c034
6 changed files with 34 additions and 9 deletions

View File

@ -21,12 +21,13 @@ package org.elasticsearch.common.inject;
import org.elasticsearch.common.collect.Lists;
import java.util.Iterator;
import java.util.List;
/**
* @author kimchy (shay.banon)
*/
public class ModulesBuilder {
public class ModulesBuilder implements Iterable<Module> {
private final List<Module> modules = Lists.newArrayList();
@ -48,6 +49,10 @@ public class ModulesBuilder {
return this;
}
@Override public Iterator<Module> iterator() {
return modules.iterator();
}
public Injector createInjector() {
Modules.processModules(modules);
return Guice.createInjector(modules);

View File

@ -55,7 +55,7 @@ import org.elasticsearch.index.similarity.SimilarityModule;
import org.elasticsearch.index.store.IndexStoreModule;
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
import org.elasticsearch.indices.store.IndicesStore;
import org.elasticsearch.plugins.IndicesPluginsModule;
import org.elasticsearch.plugins.IndexPluginsModule;
import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.threadpool.ThreadPool;
@ -214,7 +214,7 @@ public class InternalIndicesService extends AbstractLifecycleComponent<IndicesSe
modules.add(new IndexNameModule(index));
modules.add(new LocalNodeIdModule(localNodeId));
modules.add(new IndexSettingsModule(indexSettings));
modules.add(new IndicesPluginsModule(indexSettings, pluginsService));
modules.add(new IndexPluginsModule(indexSettings, pluginsService));
modules.add(new IndexStoreModule(indexSettings));
modules.add(new IndexEngineModule(indexSettings));
modules.add(new AnalysisModule(indexSettings, indicesAnalysisService));

View File

@ -22,6 +22,7 @@ package org.elasticsearch.plugins;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.inject.PreProcessModule;
import org.elasticsearch.common.inject.SpawnModules;
import org.elasticsearch.common.settings.Settings;
@ -33,13 +34,13 @@ import static org.elasticsearch.common.inject.Modules.*;
/**
* @author kimchy (shay.banon)
*/
public class IndicesPluginsModule extends AbstractModule implements SpawnModules {
public class IndexPluginsModule extends AbstractModule implements SpawnModules, PreProcessModule {
private final Settings settings;
private final PluginsService pluginsService;
public IndicesPluginsModule(Settings settings, PluginsService pluginsService) {
public IndexPluginsModule(Settings settings, PluginsService pluginsService) {
this.settings = settings;
this.pluginsService = pluginsService;
}
@ -53,6 +54,10 @@ public class IndicesPluginsModule extends AbstractModule implements SpawnModules
return modules;
}
@Override public void processModule(Module module) {
pluginsService.processModule(module);
}
@Override protected void configure() {
}
}

View File

@ -55,9 +55,7 @@ public class PluginsModule extends AbstractModule implements SpawnModules, PrePr
}
@Override public void processModule(Module module) {
for (Plugin plugin : pluginsService.plugins().values()) {
plugin.processModule(module);
}
pluginsService.processModule(module);
}
@Override protected void configure() {

View File

@ -70,6 +70,18 @@ public class PluginsService extends AbstractComponent {
return plugins;
}
public void processModules(Iterable<Module> modules) {
for (Module module : modules) {
processModule(module);
}
}
public void processModule(Module module) {
for (Plugin plugin : plugins().values()) {
plugin.processModule(module);
}
}
public Settings updatedSettings() {
return this.settings;
}

View File

@ -22,6 +22,7 @@ package org.elasticsearch.plugins;
import org.elasticsearch.common.collect.Lists;
import org.elasticsearch.common.inject.AbstractModule;
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.common.inject.PreProcessModule;
import org.elasticsearch.common.inject.SpawnModules;
import org.elasticsearch.common.settings.Settings;
@ -33,7 +34,7 @@ import static org.elasticsearch.common.inject.Modules.*;
/**
* @author kimchy (shay.banon)
*/
public class ShardsPluginsModule extends AbstractModule implements SpawnModules {
public class ShardsPluginsModule extends AbstractModule implements SpawnModules, PreProcessModule {
private final Settings settings;
@ -53,6 +54,10 @@ public class ShardsPluginsModule extends AbstractModule implements SpawnModules
return modules;
}
@Override public void processModule(Module module) {
pluginsService.processModule(module);
}
@Override protected void configure() {
}
}