本文整理汇总了Java中com.google.inject.Injector.createChildInjector方法的典型用法代码示例。如果您正苦于以下问题:Java Injector.createChildInjector方法的具体用法?Java Injector.createChildInjector怎么用?Java Injector.createChildInjector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.inject.Injector
的用法示例。
在下文中一共展示了Injector.createChildInjector方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import com.google.inject.Injector; //导入方法依赖的package包/类
@Override
public Injector load(final String moduleId) throws Exception {
if (N4_TESTER_UI_MODULE_ID.equals(moduleId)) {
final Injector parentInjector = N4JSActivator.getInstance().getInjector(
N4JSActivator.ORG_ECLIPSE_N4JS_N4JS);
return parentInjector.createChildInjector(Modules.override(new TesterModule()).with(
new N4TesterUiModule()));
}
throw new IllegalArgumentException("Unknown module ID: " + moduleId);
}
示例2: load
import com.google.inject.Injector; //导入方法依赖的package包/类
@Override
public Injector load(final String moduleId) throws Exception {
if (RUNNER_UI_MODULE_ID.equals(moduleId)) {
final Injector parentInjector = N4JSActivator.getInstance().getInjector(
N4JSActivator.ORG_ECLIPSE_N4JS_N4JS);
return parentInjector.createChildInjector(new RunnerUiModule());
}
throw new IllegalArgumentException("Unknown module ID: " + moduleId);
}
示例3: createInjector
import com.google.inject.Injector; //导入方法依赖的package包/类
public static Injector createInjector(Module... modules) {
final Injector injector = Guice.createInjector(Stage.PRODUCTION, new CollectorModule() {
@Override
protected void configure() {
binder().requireExplicitBindings();
}
});
return injector.createChildInjector(modules);
}
示例4: MinefanaSponge
import com.google.inject.Injector; //导入方法依赖的package包/类
@Inject
MinefanaSponge(Logger logger, Injector injector) {
this.logger = logger;
this.core = new AnalyticsCore(this, logger);
this.playerCollector = new SpongePlayerCollector(core);
this.injector = injector.createChildInjector(binder -> {
binder.bind(AnalyticsCore.class).toInstance(core);
binder.bind(InfluxConnector.class).toInstance(core.getConnector());
});
}
示例5: onEnable
import com.google.inject.Injector; //导入方法依赖的package包/类
@Override public void onEnable() {
Injector injector;
log.info("Enabling plugin");
try {
RegisteredServiceProvider<Providers> rsp = checkNotNull(getServer().getServicesManager()
.getRegistration(Providers.class));
injector = checkNotNull(rsp.getProvider()).getInjector();
} catch (NullPointerException e){
log.error("Failed to get ProvidersLib providers");
getServer().getPluginManager().disablePlugin(this);
return;
}
itemFactory = injector.getInstance(SimpleItemFactory.class);
MiniWynnPlugin.injector = injector.createChildInjector(binder -> {
binder.bind(Server.class).toInstance(getServer());
binder.bind(Plugin.class).toInstance(this);
binder.bind(ItemFactory.class).toInstance(itemFactory);
binder.bind(PlayerManager.class).to(SimplePlayerManager.class).asEagerSingleton();
});
listeners.forEach(listener->{
Listener listenerInst = getInjector().getInstance(listener);
getServer().getPluginManager().registerEvents(listenerInst, this);
});
}
示例6: main
import com.google.inject.Injector; //导入方法依赖的package包/类
public static void main(String[] args) {
Injector inject = Guice.createInjector(binder -> {
binder.bind(A.class).toInstance(new A().set("p"));
});
Injector c1 = inject.createChildInjector(binder -> {
binder.bind(A.class).annotatedWith(Names.named("a")).toInstance(new A());
});
Injector c2 = inject.createChildInjector();
System.out.println(c1.getInstance(Key.get(A.class, Names.named("a"))));
System.out.println(c2.getInstance(A.class));
}
示例7: load
import com.google.inject.Injector; //导入方法依赖的package包/类
@Override
public Injector load(final String id) throws Exception {
final Injector parentInjector = getParentInjector(id);
return parentInjector.createChildInjector(getModules());
}
示例8: createChildInjector
import com.google.inject.Injector; //导入方法依赖的package包/类
public Injector createChildInjector(Injector parent, Iterable<? extends Module> modules) {
return parent.createChildInjector(Iterables.concat(this.modules, modules));
}