當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。