当前位置: 首页>>代码示例>>Java>>正文


Java Injector.createChildInjector方法代码示例

本文整理汇总了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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:11,代码来源:N4TesterUiModule.java

示例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);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:10,代码来源:RunnerUiModule.java

示例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);
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:11,代码来源:CollectorInjector.java

示例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());
    });
}
 
开发者ID:games647,项目名称:Minefana,代码行数:12,代码来源:MinefanaSponge.java

示例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);
    });
}
 
开发者ID:mikroskeem,项目名称:MiniWynn,代码行数:28,代码来源:MiniWynnPlugin.java

示例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));
}
 
开发者ID:mayabot,项目名称:mynlp,代码行数:12,代码来源:GuiceTest.java

示例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());
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:6,代码来源:AbstractGuiceUIPlugin.java

示例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));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:ChildInjectorFactory.java


注:本文中的com.google.inject.Injector.createChildInjector方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。