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


Java Modules类代码示例

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


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

示例1: setUpClass

import com.google.inject.util.Modules; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
  faker = new Faker();
  String ip = esContainer.getContainerIpAddress();
  Integer transportPort = esContainer.getMappedPort(9300);
  MapConfiguration memoryParams = new MapConfiguration(new HashMap<>());
  memoryParams.setProperty(CONFIG_ES_CLUSTER_HOST, ip);
  memoryParams.setProperty(CONFIG_ES_CLUSTER_PORT, transportPort);
  memoryParams.setProperty(CONFIG_ES_CLUSTER_NAME, "elasticsearch");
  injector = Guice.createInjector(
      Modules.override(new ElasticSearchModule())
          .with(binder -> {
            binder.bind(Configuration.class).toProvider(() -> memoryParams);
          })
  );
  productDao = injector.getInstance(ProductDao.class);
  esClient = injector.getInstance(TransportClient.class);
}
 
开发者ID:email2liyang,项目名称:grpc-mate,代码行数:19,代码来源:ProductDaoTest.java

示例2: newIsisWicketModule

import com.google.inject.util.Modules; //导入依赖的package包/类
@Override
protected Module newIsisWicketModule() {
    final Module isisDefaults = super.newIsisWicketModule();
    
    final Module overrides = new AbstractModule() {
        @Override
        protected void configure() {
            bind(ComponentFactoryRegistrar.class).to(MyComponentFactoryRegistrar.class);

            bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("RotaBuilder");
            bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
            bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
            bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
            bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("RotaBuilder");
            bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(
                    Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
            // if uncommented, then overrides isis.appManifest in config file.
            // bind(AppManifest.class).toInstance(new DomainAppAppManifest());
        }
    };

    return Modules.override(isisDefaults).with(overrides);
}
 
开发者ID:bibryam,项目名称:rotabuilder,代码行数:24,代码来源:DomainApplication.java

示例3: setUp

import com.google.inject.util.Modules; //导入依赖的package包/类
@BeforeEach
public void setUp() {
  Injector injector =
      Guice.createInjector(
          Modules.override(
                  new DatasetModule(), new CannedDatasetsModule(), new ConfigurationModule())
              .with(
                  new MongoOverrideModule(),
                  new AbstractModule() {
                    @Override
                    protected void configure() {
                      bind(CannedDatasetsLoader.class)
                          .toInstance(Mockito.mock(CannedDatasetsLoader.class));
                    }
                  }));
  injector.injectMembers(this);

  when(mongoProvider.provide()).thenReturn(getMongoClient());
}
 
开发者ID:glytching,项目名称:dragoman,代码行数:20,代码来源:MongoCannedDatasetsWriterTest.java

示例4: setUp

import com.google.inject.util.Modules; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  String ip = esContainer.getContainerIpAddress();
  Integer transportPort = esContainer.getMappedPort(9300);
  MapConfiguration memoryParams = new MapConfiguration(new HashMap<>());
  memoryParams.setProperty(CONFIG_ES_CLUSTER_HOST, ip);
  memoryParams.setProperty(CONFIG_ES_CLUSTER_PORT, transportPort);
  memoryParams.setProperty(CONFIG_ES_CLUSTER_NAME, "elasticsearch");
  Injector injector = Guice.createInjector(
      Modules.override(new ElasticSearchModule()).with(
          binder -> {
            binder.bind(Configuration.class).toInstance(memoryParams);
          }
      )
  );
  transportClientProvider = injector.getInstance(TransportClientProvider.class);
}
 
开发者ID:email2liyang,项目名称:grpc-mate,代码行数:18,代码来源:TransportClientProviderTest.java

示例5: setUp

import com.google.inject.util.Modules; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  faker = new Faker();
  productDao = mock(ProductDao.class);
  injector = Guice.createInjector(
      Modules.override(new ElasticSearchModule())
          .with(binder -> {
            binder.bind(ProductDao.class).toProvider(() -> productDao);
          })
  );

  productUpdateService = injector.getInstance(ProductUpdateService.class);
  grpcServerRule.getServiceRegistry().addService(productUpdateService);

  stub = ProductUpdateServiceGrpc.newStub(grpcServerRule.getChannel());
}
 
开发者ID:email2liyang,项目名称:grpc-mate,代码行数:17,代码来源:ProductUpdateServiceTest.java

示例6: setup

import com.google.inject.util.Modules; //导入依赖的package包/类
@Before
public void setup() {
    Injector injector = Guice.createInjector(
            Modules.override(new PolicyModule()
            ).with(new AbstractModule() {
                @Override
                protected void configure() {
                    bind(EventSinkProxy.class).toInstance(mock(EventSinkProxy.class));
                    bind(IdentityProvidersConfigProxy.class).toInstance(mock(IdentityProvidersConfigProxy.class));
                    bind(Client.class).toInstance(mock(Client.class));
                    bind(Environment.class).toInstance(mock(Environment.class));
                    bind(PolicyConfiguration.class).toInstance(aPolicyConfiguration().build());
                    InfinispanCacheManager infinispanCacheManager = anInfinispanCacheManager().build(InfinispanJunitRunner.EMBEDDED_CACHE_MANAGER);
                    bind(InfinispanCacheManager.class).toInstance(infinispanCacheManager);
                    bind(EventSinkHubEventLogger.class).toInstance(mock(EventSinkHubEventLogger.class));
                    bind(JsonClient.class).annotatedWith(Names.named("samlSoapProxyClient")).toInstance(mock(JsonClient.class));
                    bind(JsonClient.class).toInstance(mock(JsonClient.class));
                }
            })
    );

    factory = new StateControllerFactory(injector);
}
 
开发者ID:alphagov,项目名称:verify-hub,代码行数:24,代码来源:StateControllerFactoryTest.java

示例7: createModule

import com.google.inject.util.Modules; //导入依赖的package包/类
@Override
public Module createModule(ITestContext context, Class<?> testClass){

	Module globalModule = new AbstractModule(){

		@Override
		protected void configure(){
			for(Module module : modules){
				install(module);
			}
		}

	};
	Iterable<? extends Module> overriders = getOverriders();
	return Modules.override(globalModule).with(overriders);
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:17,代码来源:ModuleFactory.java

示例8: newIsisWicketModule

import com.google.inject.util.Modules; //导入依赖的package包/类
@Override
 protected Module newIsisWicketModule() {
     final Module isisDefaults = super.newIsisWicketModule();
     
     final Module overrides = new AbstractModule() {
         @Override
         protected void configure() {
             bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("SiGeSe");
             bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
             bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
	bind(String.class).annotatedWith(Names.named("brandLogoSignin")).toInstance("/about/images/login.png");
	bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
	bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("SiGeSe");
	bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
}
     };

     return Modules.override(isisDefaults).with(overrides);
 }
 
开发者ID:leandrogonqn,项目名称:Proyecto2017Seguros,代码行数:20,代码来源:PacinetesApplication.java

示例9: configModuleWithOverrides

import com.google.inject.util.Modules; //导入依赖的package包/类
private static <C> Module configModuleWithOverrides(final Class<C> configInterface, final Optional<Named> nameOpt, final Optional<OverrideConsumer<C>> overrideOpt)
{
    checkNotNull(configInterface);
    checkNotNull(nameOpt);
    checkNotNull(overrideOpt);

    if (overrideOpt.isPresent()) {
        return Modules.override(ConfigBuilder.configModule(configInterface, nameOpt))
            .with(new OverrideModule<C>(configInterface, nameOpt.map(n -> n.value()))
            {
                @Override
                protected void configure()
                {
                    overrideOpt.get().accept(this);
                }
            });
    }
    else {
        return ConfigBuilder.configModule(configInterface, nameOpt);
    }
}
 
开发者ID:kikinteractive,项目名称:ice,代码行数:22,代码来源:ConfigSystem.java

示例10: testExample1

import com.google.inject.util.Modules; //导入依赖的package包/类
@Test(timeout = 5000)
@SuppressWarnings("UnnecessaryUnboxing")
public void testExample1() throws Exception
{
    Injector injector = Guice.createInjector(Modules.override(
        ConfigConfigurator.standardModules(),
        Example1.module())
        .with(new AbstractModule()
        {
            @Override
            protected void configure()
            {
                bind(String.class).annotatedWith(named(FileDynamicConfigSource.FILENAME_NAME)).toInstance(getClass().getResource("Example1.config").getFile());
            }
        })
    );

    injector.injectMembers(this);

    assertNotNull(example);
    example.doStuff();

    assertEquals("testFoo", example.config.connectionString());
    assertEquals(123L, example.config.connectionTimeout().longValue());
    assertEquals(Duration.parse("P1DT2H32M18S"), example.config.delayTime());
}
 
开发者ID:kikinteractive,项目名称:ice,代码行数:27,代码来源:Example1Test.java

示例11: setup

import com.google.inject.util.Modules; //导入依赖的package包/类
@Before
public void setup()
{
    final Named name = Names.named("provider-test");

    Module module = Modules.override(
        ConfigConfigurator.testModules(),
        ProviderExample.module(name)
    ).with(new AbstractModule()
    {
        @Override
        protected void configure()
        {
            install(ConfigSystem.overrideModule(ProviderExample.Config.class, name, om -> {
                om.override(om.id().connectionString()).withValue("foo bar");
                om.override(om.id().keyspaceName()).withValue("keyspace baz");
            }));
        }
    });

    Guice.createInjector(module).injectMembers(this);
}
 
开发者ID:kikinteractive,项目名称:ice,代码行数:23,代码来源:ProviderExampleTest.java

示例12: 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

示例13: 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

示例14: setUp

import com.google.inject.util.Modules; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  stateManager = createMock(StateManager.class);
  storage = DbUtil.createStorage();
  auroraCronJob = createMock(AuroraCronJob.class);

  injector = Guice.createInjector(
      // Override to verify that Guice is actually used for construction of the AuroraCronJob.
      // TODO(ksweeney): Use the production class here.
      Modules.override(new CronModule()).with(new AbstractModule() {
        @Override
        protected void configure() {
          bind(AuroraCronJob.class).toInstance(auroraCronJob);
        }
      }), new AbstractModule() {
        @Override
        protected void configure() {
          bind(ConfigurationManager.class).toInstance(TaskTestUtil.CONFIGURATION_MANAGER);
          bind(Clock.class).toInstance(Clock.SYSTEM_CLOCK);
          bind(StateManager.class).toInstance(stateManager);
          bind(Storage.class).toInstance(storage);
        }
      });
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:25,代码来源:CronIT.java

示例15: 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


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