本文整理匯總了Java中org.elasticsearch.common.inject.Injector類的典型用法代碼示例。如果您正苦於以下問題:Java Injector類的具體用法?Java Injector怎麽用?Java Injector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Injector類屬於org.elasticsearch.common.inject包,在下文中一共展示了Injector類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initialize
import org.elasticsearch.common.inject.Injector; //導入依賴的package包/類
/**
* Invoked by Guice at Injector-creation time to prepare providers for each
* element in this set. At this time the set's size is known, but its
* contents are only evaluated when get() is invoked.
*/
@Inject
public void initialize(Injector injector) {
providers = new ArrayList<>();
Set<Dependency<?>> dependencies = new HashSet<>();
for (Binding<?> entry : injector.findBindingsByType(elementType)) {
if (keyMatches(entry.getKey())) {
@SuppressWarnings("unchecked") // protected by findBindingsByType()
Binding<T> binding = (Binding<T>) entry;
providers.add(binding.getProvider());
dependencies.add(Dependency.get(binding.getKey()));
}
}
this.dependencies = unmodifiableSet(dependencies);
this.binder = null;
}
示例2: initialize
import org.elasticsearch.common.inject.Injector; //導入依賴的package包/類
/**
* At injector-creation time, we initialize the invocation handler. At this time we make sure
* all factory methods will be able to build the target types.
*/
@Inject
public void initialize(Injector injector) {
if (this.injector != null) {
throw new ConfigurationException(Collections.singletonList(new Message(FactoryProvider2.class,
"Factories.create() factories may only be used in one Injector!")));
}
this.injector = injector;
for (Method method : returnTypesByMethod.keySet()) {
Object[] args = new Object[method.getParameterTypes().length];
Arrays.fill(args, "dummy object for validating Factories");
getBindingFromNewInjector(method, args); // throws if the binding isn't properly configured
}
}
示例3: initialize
import org.elasticsearch.common.inject.Injector; //導入依賴的package包/類
/**
* Invoked by Guice at Injector-creation time to prepare providers for each
* element in this set. At this time the set's size is known, but its
* contents are only evaluated when get() is invoked.
*/
@Inject
public void initialize(Injector injector) {
providers = new ArrayList<>();
List<Dependency<?>> dependencies = new ArrayList<>();
for (Binding<?> entry : injector.findBindingsByType(elementType)) {
if (keyMatches(entry.getKey())) {
@SuppressWarnings("unchecked") // protected by findBindingsByType()
Binding<T> binding = (Binding<T>) entry;
providers.add(binding.getProvider());
dependencies.add(Dependency.get(binding.getKey()));
}
}
this.dependencies = ImmutableSet.copyOf(dependencies);
this.binder = null;
}
示例4: createAnalysisService
import org.elasticsearch.common.inject.Injector; //導入依賴的package包/類
private AnalysisService createAnalysisService() {
Settings settings = Settings.settingsBuilder()
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.put("path.home", System.getProperty("path.home"))
.loadFromStream("icu_folding.json", getClass().getResourceAsStream("/org/xbib/elasticsearch/index/analysis/icu/icu_folding.json")).build();
Index index = new Index("test");
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings),
new EnvironmentModule(new Environment(settings)))
.createInjector();
AnalysisModule analysisModule = new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class));
new IcuPlugin(settings).onModule(analysisModule);
Injector injector = new ModulesBuilder().add(
new IndexSettingsModule(index, settings),
new IndexNameModule(index),
analysisModule)
.createChildInjector(parentInjector);
return injector.getInstance(AnalysisService.class);
}
示例5: createAnalysisService
import org.elasticsearch.common.inject.Injector; //導入依賴的package包/類
private AnalysisService createAnalysisService() {
Settings settings = Settings.settingsBuilder()
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.put("path.home", System.getProperty("path.home"))
.loadFromStream("icu_tokenizer.json", getClass().getResourceAsStream("/org/xbib/elasticsearch/index/analysis/icu/icu_tokenizer.json")).build();
Index index = new Index("test");
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings),
new EnvironmentModule(new Environment(settings)))
.createInjector();
AnalysisModule analysisModule = new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class));
new IcuPlugin(settings).onModule(analysisModule);
Injector injector = new ModulesBuilder().add(
new IndexSettingsModule(index, settings),
new IndexNameModule(index),
analysisModule)
.createChildInjector(parentInjector);
return injector.getInstance(AnalysisService.class);
}
示例6: testDefaultsIcuAnalysis
import org.elasticsearch.common.inject.Injector; //導入依賴的package包/類
@Test
public void testDefaultsIcuAnalysis() {
Index index = new Index("test");
Settings settings = settingsBuilder()
.put("path.home", createTempDir())
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.build();
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(EMPTY_SETTINGS), new EnvironmentModule(new Environment(settings))).createInjector();
Injector injector = new ModulesBuilder().add(
new IndexSettingsModule(index, settings),
new IndexNameModule(index),
new AnalysisModule(EMPTY_SETTINGS, parentInjector.getInstance(IndicesAnalysisService.class)).addProcessor(new HanLpAnalysisBinderProcessor()))
.createChildInjector(parentInjector);
AnalysisService analysisService = injector.getInstance(AnalysisService.class);
TokenizerFactory tokenizerFactory = analysisService.tokenizer("smartcn_tokenizer");
MatcherAssert.assertThat(tokenizerFactory, instanceOf(HanLpTokenizerTokenizerFactory.class));
}
示例7: provideWith
import org.elasticsearch.common.inject.Injector; //導入依賴的package包/類
public AnalysisService provideWith(Index index, Settings settings) {
Settings indexSettings = settingsBuilder().put(settings)
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.build();
Injector parentInjector = new ModulesBuilder().add(
new SettingsModule(settings),
new EnvironmentModule(new Environment(settings))).createInjector();
Injector injector = new ModulesBuilder().add(
new IndexSettingsModule(index, indexSettings),
new IndexNameModule(index),
new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class))
.addProcessor(new UkrainianLemmatizerBinderProcessor()))
.createChildInjector(parentInjector);
return injector.getInstance(AnalysisService.class);
}
開發者ID:mrgambal,項目名稱:elasticsearch-ukrainian-lemmatizer,代碼行數:17,代碼來源:TestAnalysisServiceProvider.java
示例8: startServices
import org.elasticsearch.common.inject.Injector; //導入依賴的package包/類
private void startServices(Injector injector, Plugin plugin, Settings settings, ClassLoader classLoader, URL url)
throws IOException {
for (Class<? extends LifecycleComponent> service : plugin.nodeServices()) {
logger.info("found service {} {} to start", service, service.getClass());
LifecycleComponent t = injector.getInstance(service);
if (t instanceof DeployableComponent) {
DeployableComponent component = (DeployableComponent) t;
logger.info("before init component {}", component);
// add custom settings from elasticsearch.yml
URL settingsUrl = classLoader.getResource("elasticsearch.yml");
if (settingsUrl != null) {
Settings customSettings = settingsBuilder()
.put(settings)
.loadFromStream("elasticsearch.yml", settingsUrl.openStream())
.build();
logger.info("custom settings = {}", customSettings.getAsMap());
component.init(customSettings, classLoader, url);
logger.info("after component {}", component);
}
}
logger.info("starting service {}", service);
t.start();
logger.info("service {} started", service);
}
}
示例9: getAnalysisService
import org.elasticsearch.common.inject.Injector; //導入依賴的package包/類
private AnalysisService getAnalysisService() {
Index index = new Index("test");
Settings settings = ImmutableSettings.settingsBuilder().put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).build();
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings),
new EnvironmentModule(new Environment(settings)), new IndicesAnalysisModule()).createInjector();
Injector injector = new ModulesBuilder().add(
new IndexSettingsModule(index, settings),
new IndexNameModule(index),
new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class))
.addProcessor(new RosetteAnalysisBinderProcessor()))
.createChildInjector(parentInjector);
return injector.getInstance(AnalysisService.class);
}
開發者ID:basis-technology-corp,項目名稱:elasticsearch-analysis-rosette,代碼行數:17,代碼來源:SimpleRosetteAnalysisTests.java
示例10: createAnalysisService
import org.elasticsearch.common.inject.Injector; //導入依賴的package包/類
private AnalysisService createAnalysisService() {
Settings settings = ImmutableSettings.settingsBuilder()
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.loadFromClasspath("org/xbib/elasticsearch/index/analysis/decompound/decompound_analysis.json").build();
Index index = new Index("test");
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings),
new EnvironmentModule(new Environment(settings)),
new IndicesAnalysisModule())
.createInjector();
AnalysisModule analysisModule = new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class));
new AnalysisGermanPlugin().onModule(analysisModule);
Injector injector = new ModulesBuilder().add(
new IndexSettingsModule(index, settings),
new IndexNameModule(index),
analysisModule)
.createChildInjector(parentInjector);
return injector.getInstance(AnalysisService.class);
}
示例11: createAnalysisService
import org.elasticsearch.common.inject.Injector; //導入依賴的package包/類
private AnalysisService createAnalysisService() {
Settings settings = ImmutableSettings.settingsBuilder()
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.loadFromClasspath("org/xbib/elasticsearch/index/analysis/german/test-settings.json").build();
Index index = new Index("test");
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings),
new EnvironmentModule(new Environment(settings)),
new IndicesAnalysisModule())
.createInjector();
AnalysisModule analysisModule = new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class));
new AnalysisGermanPlugin().onModule(analysisModule);
Injector injector = new ModulesBuilder().add(
new IndexSettingsModule(index, settings),
new IndexNameModule(index),
analysisModule)
.createChildInjector(parentInjector);
return injector.getInstance(AnalysisService.class);
}
示例12: createAnalysisService
import org.elasticsearch.common.inject.Injector; //導入依賴的package包/類
private AnalysisService createAnalysisService() {
Settings settings = ImmutableSettings.settingsBuilder()
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.loadFromClasspath("org/xbib/elasticsearch/index/analysis/german/german_normalization_analysis.json").build();
Index index = new Index("test");
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings),
new EnvironmentModule(new Environment(settings)),
new IndicesAnalysisModule())
.createInjector();
AnalysisModule analysisModule = new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class));
new AnalysisGermanPlugin().onModule(analysisModule);
Injector injector = new ModulesBuilder().add(
new IndexSettingsModule(index, settings),
new IndexNameModule(index),
analysisModule)
.createChildInjector(parentInjector);
return injector.getInstance(AnalysisService.class);
}
示例13: createAnalysisService
import org.elasticsearch.common.inject.Injector; //導入依賴的package包/類
private AnalysisService createAnalysisService() {
Settings settings = ImmutableSettings.settingsBuilder()
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.loadFromClasspath("org/xbib/elasticsearch/index/analysis/icu/icu_tokenizer.json").build();
Index index = new Index("test");
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings),
new EnvironmentModule(new Environment(settings)),
new IndicesAnalysisModule())
.createInjector();
AnalysisModule analysisModule = new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class));
new AnalysisGermanPlugin().onModule(analysisModule);
Injector injector = new ModulesBuilder().add(
new IndexSettingsModule(index, settings),
new IndexNameModule(index),
analysisModule)
.createChildInjector(parentInjector);
return injector.getInstance(AnalysisService.class);
}
示例14: createAnalysisService
import org.elasticsearch.common.inject.Injector; //導入依賴的package包/類
private AnalysisService createAnalysisService() {
Settings settings = ImmutableSettings.settingsBuilder()
.put(IndexMetaData.SETTING_VERSION_CREATED, org.elasticsearch.Version.CURRENT)
.build();
Index index = new Index("test");
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings),
new EnvironmentModule(new Environment(settings)),
new IndicesAnalysisModule())
.createInjector();
AnalysisModule analysisModule = new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class));
new AnalysisGermanPlugin().onModule(analysisModule);
Injector injector = new ModulesBuilder().add(
new IndexSettingsModule(index, settings),
new IndexNameModule(index),
analysisModule)
.createChildInjector(parentInjector);
return injector.getInstance(AnalysisService.class);
}
示例15: createAnalysisService
import org.elasticsearch.common.inject.Injector; //導入依賴的package包/類
private AnalysisService createAnalysisService() {
Settings settings = ImmutableSettings.settingsBuilder()
.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
.loadFromClasspath("org/xbib/elasticsearch/index/analysis/hyphen/hyphen_tokenizer.json").build();
Index index = new Index("test");
Injector parentInjector = new ModulesBuilder().add(new SettingsModule(settings),
new EnvironmentModule(new Environment(settings)),
new IndicesAnalysisModule())
.createInjector();
AnalysisModule analysisModule = new AnalysisModule(settings, parentInjector.getInstance(IndicesAnalysisService.class));
new AnalysisGermanPlugin().onModule(analysisModule);
Injector injector = new ModulesBuilder().add(
new IndexSettingsModule(index, settings),
new IndexNameModule(index),
analysisModule)
.createChildInjector(parentInjector);
return injector.getInstance(AnalysisService.class);
}