本文整理匯總了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));
}