org.elasticsearch.common.inject.Module Java Examples
The following examples show how to use
org.elasticsearch.common.inject.Module.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CrateComponentLoader.java From Elasticsearch with Apache License 2.0 | 6 votes |
public void processModule(Module module) { for (Plugin plugin : plugins) { // see if there are onModule references List<OnModuleReference> references = onModuleReferences.get(plugin); if (references != null) { for (OnModuleReference reference : references) { if (reference.moduleClass.isAssignableFrom(module.getClass())) { try { reference.onModuleMethod.invoke(plugin, module); } catch (Exception e) { logger.warn("plugin {}, failed to invoke custom onModule method", e, plugin.name()); } } } } } }
Example #2
Source File: PluginLoader.java From Elasticsearch with Apache License 2.0 | 6 votes |
public void processModule(Module module) { for (Plugin plugin : plugins) { // see if there are onModule references List<CrateComponentLoader.OnModuleReference> references = onModuleReferences.get(plugin); if (references != null) { for (CrateComponentLoader.OnModuleReference reference : references) { if (reference.moduleClass.isAssignableFrom(module.getClass())) { try { reference.onModuleMethod.invoke(plugin, module); } catch (Exception e) { logger.warn("Plugin {}, failed to invoke custom onModule method", e, plugin.name()); } } } } } }
Example #3
Source File: FactoryProvider2.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Creates a child injector that binds the args, and returns the binding for the method's result. */ public Binding<?> getBindingFromNewInjector(final Method method, final Object[] args) { checkState(injector != null, "Factories.create() factories cannot be used until they're initialized by Guice."); final Key<?> returnType = returnTypesByMethod.get(method); Module assistedModule = new AbstractModule() { @Override @SuppressWarnings("unchecked") // raw keys are necessary for the args array and return value protected void configure() { Binder binder = binder().withSource(method); int p = 0; for (Key<?> paramKey : paramTypes.get(method)) { // Wrap in a Provider to cover null, and to prevent Guice from injecting the parameter binder.bind((Key) paramKey).toProvider(Providers.of(args[p++])); } if (producedType != null && !returnType.equals(producedType)) { binder.bind(returnType).to((Key) producedType); } else { binder.bind(returnType); } } }; Injector forCreate = injector.createChildInjector(assistedModule); return forCreate.getBinding(returnType); }
Example #4
Source File: PluginsService.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Collection<Module> shardModules(Settings indexSettings) { List<Module> modules = new ArrayList<>(); for (Tuple<PluginInfo, Plugin> plugin : plugins) { modules.addAll(plugin.v2().shardModules(indexSettings)); } return modules; }
Example #5
Source File: PluginsService.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Collection<Module> nodeModules() { List<Module> modules = new ArrayList<>(); for (Tuple<PluginInfo, Plugin> plugin : plugins) { modules.addAll(plugin.v2().nodeModules()); } return modules; }
Example #6
Source File: SirenJoinPlugin.java From siren-join with GNU Affero General Public License v3.0 | 5 votes |
@Override public Collection<Module> nodeModules() { if (isEnabled) { return Collections.singletonList((Module) new SirenJoinNodeModule()); } else { return Collections.emptyList(); } }
Example #7
Source File: ReindexingPlugin.java From elasticsearch-reindexing with Apache License 2.0 | 5 votes |
/** * extend node level modules * @return */ @Override public Collection<Module> nodeModules() { final Collection<Module> modules =new ArrayList<>(); modules.add(new ReindexingModule()); return modules; }
Example #8
Source File: BlobPlugin.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public Collection<Module> nodeModules() { Collection<Module> modules = Lists.newArrayList(); if (!settings.getAsBoolean("node.client", false)) { modules.add(new BlobModule()); modules.add(new BlobIndicesModule()); } return modules; }
Example #9
Source File: GathererModule.java From elasticsearch-gatherer with Apache License 2.0 | 5 votes |
@Override public Iterable<? extends Module> spawnModules() { Collection<Module> modules = newLinkedList(); for (Map.Entry<String, Class<? extends Module>> me : gathererModules.entrySet()) { modules.add(Modules.createModule(me.getValue(), settings)); } return modules; }
Example #10
Source File: PluginsService.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Collection<Module> indexModules(Settings indexSettings) { List<Module> modules = new ArrayList<>(); for (Tuple<PluginInfo, Plugin> plugin : plugins) { modules.addAll(plugin.v2().indexModules(indexSettings)); } return modules; }
Example #11
Source File: PluginLoader.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Collection<Module> nodeModules() { List<Module> modules = Lists.newArrayList(); for (Plugin plugin : plugins) { modules.addAll(plugin.nodeModules()); // deprecated methods support Collection<Class<? extends Module>> modulesClasses = Lists.newArrayList(); modulesClasses.addAll(plugin.modules()); modulesClasses.addAll(plugin.modules(settings)); for (Class<? extends Module> moduleClass : modulesClasses) { modules.add(createModule(moduleClass, settings)); } } return modules; }
Example #12
Source File: PluginLoader.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Collection<Module> indexModules(Settings indexSettings) { List<Module> modules = Lists.newArrayList(); for (Plugin plugin : plugins) { modules.addAll(plugin.indexModules(indexSettings)); // deprecated methods support for (Class<? extends Module> moduleClass : plugin.indexModules()) { modules.add(createModule(moduleClass, settings)); } } return modules; }
Example #13
Source File: PluginLoader.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Collection<Module> shardModules(Settings indexSettings) { List<Module> modules = Lists.newArrayList(); for (Plugin plugin : plugins) { modules.addAll(plugin.shardModules(indexSettings)); // deprecated methods support for (Class<? extends Module> moduleClass : plugin.shardModules()) { modules.add(createModule(moduleClass, settings)); } } return modules; }
Example #14
Source File: SQLPlugin.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public Collection<Module> indexModules(Settings indexSettings) { Collection<Module> modules = newArrayList(); if (!settings.getAsBoolean("node.client", false)) { modules.add(new CrateIndexModule()); } return modules; }
Example #15
Source File: SQLPlugin.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public Collection<Module> shardModules(Settings indexSettings) { Collection<Module> modules = newArrayList(); if (!settings.getAsBoolean("node.client", false)) { modules.add(new MetaDataShardModule()); modules.add(new SysShardExpressionModule()); modules.add(new BlobShardExpressionModule(indexSettings)); modules.add(new CollectShardModule()); } return modules; }
Example #16
Source File: CrateCorePlugin.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public Collection<Module> nodeModules() { Collection<Module> modules = new ArrayList<>(); CrateCoreModule crateCoreModule = new CrateCoreModule(settings, crateComponentLoader, pluginLoader); modules.add(crateCoreModule); modules.addAll(pluginLoader.nodeModules()); modules.addAll(crateComponentLoader.nodeModules()); modules.add(new AuthModule()); return modules; }
Example #17
Source File: CrateCorePlugin.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public Collection<Module> shardModules(Settings indexSettings) { Collection<Module> modules = new ArrayList<>(); if (!settings.getAsBoolean("node.client", false)) { modules.addAll(pluginLoader.shardModules(indexSettings)); modules.addAll(crateComponentLoader.shardModules(indexSettings)); } return modules; }
Example #18
Source File: CrateComponentLoader.java From Elasticsearch with Apache License 2.0 | 5 votes |
private CrateComponentLoader(Settings settings) { ServiceLoader<CrateComponent> crateComponents = ServiceLoader.load(CrateComponent.class); plugins = new ArrayList<>(); MapBuilder<Plugin, List<OnModuleReference>> onModuleReferences = MapBuilder.newMapBuilder(); for (CrateComponent crateComponent : crateComponents) { logger.trace("Loading crateComponent: {}", crateComponent); Plugin plugin = crateComponent.createPlugin(settings); plugins.add(plugin); List<OnModuleReference> list = Lists.newArrayList(); for (Method method : plugin.getClass().getDeclaredMethods()) { if (!method.getName().equals("onModule")) { continue; } if (method.getParameterTypes().length == 0 || method.getParameterTypes().length > 1) { logger.warn("Plugin: {} implementing onModule with no parameters or more than one parameter", plugin.name()); continue; } Class moduleClass = method.getParameterTypes()[0]; if (!Module.class.isAssignableFrom(moduleClass)) { logger.warn("Plugin: {} implementing onModule by the type is not of Module type {}", plugin.name(), moduleClass); continue; } method.setAccessible(true); //noinspection unchecked list.add(new OnModuleReference(moduleClass, method)); } if (!list.isEmpty()) { onModuleReferences.put(plugin, list); } } this.onModuleReferences = onModuleReferences.immutableMap(); }
Example #19
Source File: CrateComponentLoader.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Collection<Module> nodeModules() { List<Module> modules = Lists.newArrayList(); for (Plugin plugin : plugins) { modules.addAll(plugin.nodeModules()); } return modules; }
Example #20
Source File: CrateComponentLoader.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Collection<Module> indexModules(Settings indexSettings) { Collection<Module> modules = new ArrayList<>(); for (Plugin plugin : plugins) { modules.addAll(plugin.indexModules(indexSettings)); } return modules; }
Example #21
Source File: CrateComponentLoader.java From Elasticsearch with Apache License 2.0 | 5 votes |
public Collection<Module> shardModules(Settings indexSettings) { List<Module> modules = Lists.newArrayList(); for (Plugin plugin : plugins) { modules.addAll(plugin.shardModules(indexSettings)); } return modules; }
Example #22
Source File: BundlePlugin.java From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 | 5 votes |
@Override public Collection<Module> createGuiceModules() { Collection<Module> extra = new ArrayList<>(); if (settings.getAsBoolean("plugins.xbib.reference.enabled", true)) { extra.add(new ReferenceMapperModule(referenceMapperTypeParser)); } if (settings.getAsBoolean("plugins.xbib.standardnumber.enabled", true)) { extra.add(new StandardnumberMapperModule(standardNumberTypeParser)); } return extra; }
Example #23
Source File: Modules.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Returns a new module that installs all of {@code modules}. */ public static Module combine(Iterable<? extends Module> modules) { // TODO: infer type once JI-9019884 is fixed final Set<Module> modulesSet = ImmutableSet.<Module>copyOf(modules); return new Module() { @Override public void configure(Binder binder) { binder = binder.skipSources(getClass()); for (Module module : modulesSet) { binder.install(module); } } }; }
Example #24
Source File: Elements.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Records the elements executed by {@code modules}. */ public static List<Element> getElements(Stage stage, Iterable<? extends Module> modules) { RecordingBinder binder = new RecordingBinder(stage); for (Module module : modules) { binder.install(module); } return Collections.unmodifiableList(binder.elements); }
Example #25
Source File: Elements.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Returns the module composed of {@code elements}. */ public static Module getModule(final Iterable<? extends Element> elements) { return new Module() { @Override public void configure(Binder binder) { for (Element element : elements) { element.applyTo(binder); } } }; }
Example #26
Source File: ProviderMethodsModule.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Returns a module which creates bindings for provider methods from the given object. * This is useful notably for <a href="http://code.google.com/p/google-gin/">GIN</a> */ public static Module forObject(Object object) { // avoid infinite recursion, since installing a module always installs itself if (object instanceof ProviderMethodsModule) { return Modules.EMPTY_MODULE; } return new ProviderMethodsModule(object); }
Example #27
Source File: SQLPlugin.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public Collection<Module> nodeModules() { Collection<Module> modules = newArrayList(); modules.add(new SQLModule()); modules.add(new CircuitBreakerModule()); modules.add(new TransportExecutorModule()); modules.add(new JobModule()); modules.add(new CollectOperationModule()); modules.add(new FileCollectModule()); modules.add(new MergeOperationModule()); modules.add(new MetaDataModule()); modules.add(new MetaDataSysModule()); modules.add(new MetaDataDocModule()); modules.add(new MetaDataBlobModule()); modules.add(new MetaDataInformationModule()); modules.add(new OperatorModule()); modules.add(new PredicateModule()); modules.add(new MonitorModule(settings)); modules.add(new SysClusterExpressionModule()); modules.add(new SysNodeExpressionModule()); modules.add(new AggregationImplModule()); modules.add(new ScalarFunctionModule()); modules.add(new TableFunctionModule()); modules.add(new BulkModule()); modules.add(new SysChecksModule()); modules.add(new RepositorySettingsModule()); return modules; }
Example #28
Source File: Plugin.java From Elasticsearch with Apache License 2.0 | 4 votes |
/** * Node level modules. */ public Collection<Module> nodeModules() { return Collections.emptyList(); }
Example #29
Source File: Modules.java From Elasticsearch with Apache License 2.0 | 4 votes |
private RealOverriddenModuleBuilder(Iterable<? extends Module> baseModules) { // TODO: infer type once JI-9019884 is fixed this.baseModules = ImmutableSet.<Module>copyOf(baseModules); }
Example #30
Source File: Modules.java From Elasticsearch with Apache License 2.0 | 4 votes |
@Override public Module with(Module... overrides) { return with(Arrays.asList(overrides)); }