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


Java Modules.combine方法代码示例

本文整理汇总了Java中com.google.inject.util.Modules.combine方法的典型用法代码示例。如果您正苦于以下问题:Java Modules.combine方法的具体用法?Java Modules.combine怎么用?Java Modules.combine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.inject.util.Modules的用法示例。


在下文中一共展示了Modules.combine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testModuleWithWorkQueue

import com.google.inject.util.Modules; //导入方法依赖的package包/类
/**
 * Creates a module that will prepare a private in-memory database, using a specific task store
 * implementation bound within the key factory and provided module.
 *
 * @param keyFactory Key factory to use.
 * @param taskStoreModule Module providing task store bindings.
 * @return A new database module for testing.
 */
@VisibleForTesting
public static Module testModuleWithWorkQueue(
    KeyFactory keyFactory,
    Optional<Module> taskStoreModule) {

  return Modules.combine(
      new AbstractModule() {
        @Override
        protected void configure() {
          bind(GatedWorkQueue.class).annotatedWith(AsyncExecutor.class).toInstance(
              new GatedWorkQueue() {
                @Override
                public <T, E extends Exception> T closeDuring(
                    GatedOperation<T, E> operation) throws E {

                  return operation.doWithGateClosed();
                }
              });
        }
      },
      testModule(keyFactory, taskStoreModule)
  );
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:32,代码来源:DbModule.java

示例2: getChildServletModule

import com.google.inject.util.Modules; //导入方法依赖的package包/类
@Override
protected Module getChildServletModule() {
  return Modules.combine(
      new ApiModule(),
      new H2ConsoleModule(true),
      new HttpSecurityModule(
          new IniShiroRealmModule(ini),
          Key.get(Filter.class, SHIRO_AFTER_AUTH_FILTER_ANNOTATION)),
      new AbstractModule() {
        @Override
        protected void configure() {
          bind(Filter.class)
              .annotatedWith(SHIRO_AFTER_AUTH_FILTER_ANNOTATION)
              .toInstance(shiroAfterAuthFilter);
          MockDecoratedThrift.bindForwardedMock(binder(), auroraAdmin);
        }
      });
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:19,代码来源:HttpSecurityIT.java

示例3: getRootModule

import com.google.inject.util.Modules; //导入方法依赖的package包/类
public static Module getRootModule(final String webinfRoot) {
  return Modules.combine(
      Modules.combine(extraModules),
      new WalkaroundServerModule(),
      new ConvStoreModule(),
      new UdwStoreModule(),
      new AbstractModule() {
        @Override public void configure() {
          bind(String.class).annotatedWith(Names.named("webinf root")).toInstance(webinfRoot);

          // TODO(ohler): Find a way to create these bindings in StoreModuleHelper; but note that
          // http://code.google.com/p/google-guice/wiki/Multibindings says something about
          // private modules not interacting well with multibindings.  I don't know if that
          // refers to our situation here.
          MapBinder<String, SlobFacilities> mapBinder =
              MapBinder.newMapBinder(binder(), String.class, SlobFacilities.class);
          for (Entry<String, Class<? extends Annotation>> entry
              : ImmutableMap.of(ConvStoreModule.ROOT_ENTITY_KIND, ConvStore.class,
                  UdwStoreModule.ROOT_ENTITY_KIND, UdwStore.class).entrySet()) {
            mapBinder.addBinding(entry.getKey())
                .to(Key.get(SlobFacilities.class, entry.getValue()));
          }
        }
      });
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:26,代码来源:GuiceSetup.java

示例4: newConfigModule

import com.google.inject.util.Modules; //导入方法依赖的package包/类
@Override
public Module newConfigModule() {
    return Modules.combine(
            new AbstractModule() {
                @Override
                protected void configure() {
                    bind(FilterBindings.class)
                            .toInstance(new FilterBindings(
                                    new BindingRepository<>(),
                                    new BindingRepository<>()));
                    bind(ServerConfig.class)
                            .toInstance(new ServerConfig(new ServerConfig.Builder()));
                    bind(ServletPathsConfig.class)
                            .toInstance(new ServletPathsConfig(new ServletPathsConfig.Builder()));
                }
            },
            new ConnectorFactoryRegistryModule());
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:19,代码来源:HttpServerConformanceTest.java

示例5: newFilterModule

import com.google.inject.util.Modules; //导入方法依赖的package包/类
private static com.google.inject.Module newFilterModule(
        final BindingRepository<RequestFilter> requestFilters,
        final BindingRepository<ResponseFilter> responseFilters) {
    return Modules.combine(
            new AbstractModule() {
                @Override
                protected void configure() {
                    bind(FilterBindings.class).toInstance(
                            new FilterBindings(
                                    requestFilters != null ? requestFilters : EMPTY_REQUEST_FILTER_REPOSITORY,
                                    responseFilters != null ? responseFilters : EMPTY_RESPONSE_FILTER_REPOSITORY));
                    bind(ServerConfig.class).toInstance(new ServerConfig(new ServerConfig.Builder()));
                    bind(ConnectorConfig.class).toInstance(new ConnectorConfig(new ConnectorConfig.Builder()));
                    bind(ServletPathsConfig.class).toInstance(new ServletPathsConfig(new ServletPathsConfig.Builder()));
                }
            },
            new ConnectorFactoryRegistryModule());
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:19,代码来源:FilterTestCase.java

示例6: newConfigModule

import com.google.inject.util.Modules; //导入方法依赖的package包/类
private static Module newConfigModule(
        final ServerConfig.Builder serverConfig,
        final ConnectorConfig.Builder connectorConfigBuilder,
        final Module... guiceModules) {
    return Modules.combine(
            new AbstractModule() {
                @Override
                protected void configure() {
                    bind(ServletPathsConfig.class).toInstance(new ServletPathsConfig(new ServletPathsConfig.Builder()));
                    bind(ServerConfig.class).toInstance(new ServerConfig(serverConfig));
                    bind(ConnectorConfig.class).toInstance(new ConnectorConfig(connectorConfigBuilder));
                    bind(FilterBindings.class).toInstance(
                            new FilterBindings(
                                    new BindingRepository<RequestFilter>(),
                                    new BindingRepository<ResponseFilter>()));
                }
            },
            new ConnectorFactoryRegistryModule(connectorConfigBuilder),
            new ServletModule(),
            Modules.combine(guiceModules));
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:22,代码来源:TestDrivers.java

示例7: testCombineSources

import com.google.inject.util.Modules; //导入方法依赖的package包/类
/** The module returned by Modules.combine shouldn't show up in binder sources. */
public void testCombineSources() {
  final Module m1 = newModule(1);
  final Module m2 = newModule(2L);
  final Module combined1 = Modules.combine(m1, m2);
  Module skipSourcesModule =
      new AbstractModule() {
        @Override
        protected void configure() {
          install(combined1);
        }
      };
  final Module combined2 = Modules.combine(skipSourcesModule);
  Injector injector = Guice.createInjector(combined2);
  ElementSource source = (ElementSource) injector.getBinding(Integer.class).getSource();
  assertEquals(4, source.getModuleClassNames().size());
  assertEquals(
      ImmutableList.of(
          m1.getClass().getName(),
          combined1.getClass().getName(),
          skipSourcesModule.getClass().getName(),
          combined2.getClass().getName()),
      source.getModuleClassNames());
  StackTraceElement stackTraceElement = (StackTraceElement) source.getDeclaringSource();
  assertEquals(skipSourcesModule.getClass().getName(), stackTraceElement.getClassName());
}
 
开发者ID:google,项目名称:guice,代码行数:27,代码来源:ModulesTest.java

示例8: testCombineSources

import com.google.inject.util.Modules; //导入方法依赖的package包/类
/**
 * The module returned by Modules.combine shouldn't show up in binder sources.
 */
public void testCombineSources() {
  final Module m1 = newModule(1);
  final Module m2 = newModule(2L);
  final Module combined1 = Modules.combine(m1, m2);
  Module skipSourcesModule = new AbstractModule() {
    @Override protected void configure() {
      install(combined1);
    }
  };
  final Module combined2 = Modules.combine(skipSourcesModule);
  Injector injector = Guice.createInjector(combined2);
  ElementSource source = (ElementSource) injector.getBinding(Integer.class).getSource();
  assertEquals(source.getModuleClassNames().size(), 4);
  assertEquals(ImmutableList.of(m1.getClass().getName(),
      combined1.getClass().getName(), skipSourcesModule.getClass().getName(),
      combined2.getClass().getName()), source.getModuleClassNames());
  StackTraceElement stackTraceElement = (StackTraceElement) source.getDeclaringSource();
  assertEquals(skipSourcesModule.getClass().getName(), stackTraceElement.getClassName());
}
 
开发者ID:cgruber,项目名称:guice-old,代码行数:23,代码来源:ModulesTest.java

示例9: loadFromClasspath

import com.google.inject.util.Modules; //导入方法依赖的package包/类
public static Module loadFromClasspath(Site site, Class<? extends Module> moduleType) {
    List<Module> runtime = new LinkedList<Module>();
    List overrides = new LinkedList();

    runtime.add(new DefaultSiteModule(site));

    for (Module module : ServiceLoader.load(moduleType, site.getClassLoader())) {

        ClassUtils.apply(module, site);

        if (module.getClass().isAnnotationPresent(OverrideModule.class)) {
            overrides.add(module);
        } else {
            runtime.add(module);
        }
    }
    return overrides.isEmpty() ? Modules.combine(runtime) : Modules.override(runtime).with(overrides);
}
 
开发者ID:opoo,项目名称:opoopress,代码行数:19,代码来源:ServiceModules.java

示例10: onCreate

import com.google.inject.util.Modules; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    Module defaultModule = RoboGuice.newDefaultRoboModule(this);
    Module dbInspectorModule = new DBInspectorModule();
    Module combinedModule = Modules.combine(defaultModule, dbInspectorModule);

    Injector injector = RoboGuice.setBaseApplicationInjector(this, RoboGuice.DEFAULT_STAGE, combinedModule);

    Map<Key<?>, Binding<?>> bindings = injector.getAllBindings();
    for (Key<?> key : bindings.keySet()) {
        Binding<?> value = bindings.get(key);
        Ln.d("binding key '" + key + "', value '" + value + "'");
    }

    Ln.i("Application initialized.");
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-mobile-android,代码行数:19,代码来源:DBInspectorApplication.java

示例11: getRuntimeModule

import com.google.inject.util.Modules; //导入方法依赖的package包/类
private static Module getRuntimeModule(String transport, String host, int port, Properties joynrConfig) {
    Module runtimeModule;
    if (transport != null) {
        if (transport.contains("websocketcc")) {
            configureWebSocket(host, port, joynrConfig);
            runtimeModule = new CCWebSocketRuntimeModule();
        } else if (transport.contains("websocket")) {
            configureWebSocket(host, port, joynrConfig);
            runtimeModule = new LibjoynrWebSocketRuntimeModule();
        } else {
            runtimeModule = new CCInProcessRuntimeModule();
        }

        Module backendTransportModules = Modules.EMPTY_MODULE;
        if (transport.contains("http")) {
            backendTransportModules = Modules.combine(backendTransportModules, new AtmosphereMessagingModule());
        }

        if (transport.contains("mqtt")) {
            configureMqtt(joynrConfig);
            backendTransportModules = Modules.combine(backendTransportModules, new MqttPahoModule());
        }
        return Modules.override(runtimeModule).with(backendTransportModules);
    }
    return Modules.override(new CCInProcessRuntimeModule()).with(new MqttPahoModule());
}
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:27,代码来源:MyRadioProviderApplication.java

示例12: initInjection

import com.google.inject.util.Modules; //导入方法依赖的package包/类
/** Creates the injector for the test and injects all fields with the initialized injector. */
private void initInjection(Properties properties) {

	// STEP 1: set up language N4JS

	// the following is doing roughly the same as N4JSStandaloneSetup.doSetup(), but is using a custom-built
	// Guice module for injector creation:

	TypesPackage.eINSTANCE.getNsURI();
	TypeRefsPackage.eINSTANCE.getNsURI();
	N4JSPackage.eINSTANCE.getNsURI();
	N4mfPackage.eINSTANCE.getNsURI();
	XMLTypePackage.eINSTANCE.getNsURI();

	// combine all modules for N4JSC
	final Module combinedModule = Modules.combine(new N4JSRuntimeModule(), new TesterModule(),
			new N4JSHeadlessGeneratorModule(properties));

	// override with customized bindings
	final Module overridenModule = Modules.override(combinedModule).with(binder -> {
		binder.bind(TestTreeTransformer.class)
				.to(CliTestTreeTransformer.class);
		binder.bind(IHeadlessLogger.class)
				.toInstance(new ConfigurableHeadlessLogger(verbose, debug));
	});

	RegularExpressionStandaloneSetup.doSetup();
	TypesStandaloneSetup.doSetup();
	N4MFStandaloneSetup.doSetup();
	TypeExpressionsStandaloneSetup.doSetup();

	final Injector injector = Guice.createInjector(overridenModule);
	new N4JSStandaloneSetup().register(injector);
	injector.injectMembers(this);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:36,代码来源:N4jscBase.java

示例13: module

import com.google.inject.util.Modules; //导入方法依赖的package包/类
public static Module module(final Named name)
{
    return Modules.combine(
        new AbstractModule()
        {
            @Override
            protected void configure()
            {
                // ConfigSystem.configModule() creates a module with a lot of bindings that need to be non-private.
                // make sure you don't specify this within the PrivateModule.
                install(ConfigSystem.configModule(ProviderExample.Config.class, name));
            }
        },
        new PrivateModule()
        {
            @Override
            protected void configure()
            {
                // NOTE: MUST explicitly bind and expose this class within the private module for Guice to be able
                // to use the alias binding below during injection of this class.
                bind(ProviderExample.class).annotatedWith(name).to(ProviderExample.class);
                expose(Key.get(ProviderExample.class, name));

                // alias binding; only applies to other bind() or install() methods in this private module. Do not expose this.
                // This allows us to @Inject a Config instance into this class w/o knowing the bound name in advance.
                bind(Config.class).to(Key.get(Config.class, name));

                // Binding for the class being provided by the provider
                bind(ProviderExample.Foo.class)
                    .annotatedWith(name)
                    .toProvider(Key.get(ProviderExample.class, name))
                    .in(Scopes.SINGLETON);
                expose(Key.get(ProviderExample.Foo.class, name));
            }
        });
}
 
开发者ID:kikinteractive,项目名称:ice,代码行数:37,代码来源:ProviderExample.java

示例14: getUniversalModule

import com.google.inject.util.Modules; //导入方法依赖的package包/类
@VisibleForTesting
static Module getUniversalModule() {
  return Modules.combine(
      new LifecycleModule(),
      new StatsModule(),
      new AppModule(),
      new CronModule(),
      new DbModule.MigrationManagerModule(),
      DbModule.productionModule(Bindings.annotatedKeyFactory(Storage.Volatile.class)),
      new DbModule.GarbageCollectorModule());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:12,代码来源:SchedulerMain.java

示例15: getChildServletModule

import com.google.inject.util.Modules; //导入方法依赖的package包/类
@Override
protected Module getChildServletModule() {
  return Modules.combine(
      new ApiModule(),
      new AbstractModule() {
        @Override
        protected void configure() {
          bind(AnnotatedAuroraAdmin.class).toInstance(thrift);
        }
      });
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:12,代码来源:ApiIT.java


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