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


Java MapBinder类代码示例

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


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

示例1: registerInput

import com.google.inject.multibindings.MapBinder; //导入依赖的package包/类
public void registerInput(String type,
                          Class<? extends Input> inputClass,
                          Class<? extends Input.Factory<? extends Input, ? extends InputConfiguration>> inputFactoryClass,
                          Class<? extends InputConfiguration> inputConfigurationClass,
                          Class<? extends InputConfiguration.Factory<? extends InputConfiguration>> inputConfigurationFactoryClass) {
    if (inputsMapBinder == null) {
        this.inputsMapBinder = MapBinder.newMapBinder(binder(),
                TypeLiteral.get(String.class),
                new TypeLiteral<InputConfiguration.Factory<? extends InputConfiguration>>() {
                });
    }

    install(new FactoryModuleBuilder().implement(Input.class, inputClass).build(inputFactoryClass));
    install(new FactoryModuleBuilder().implement(Configuration.class, inputConfigurationClass).build(inputConfigurationFactoryClass));

    inputsMapBinder.addBinding(type).to(inputConfigurationFactoryClass);
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:18,代码来源:CollectorModule.java

示例2: registerOutput

import com.google.inject.multibindings.MapBinder; //导入依赖的package包/类
public void registerOutput(String type,
                           Class<? extends Output> outputClass,
                           Class<? extends Output.Factory<? extends Output, ? extends OutputConfiguration>> outputFactoryClass,
                           Class<? extends OutputConfiguration> outputConfigurationClass,
                           Class<? extends OutputConfiguration.Factory<? extends OutputConfiguration>> outputConfigurationFactoryClass) {

    if (outputsMapBinder == null) {
        this.outputsMapBinder = MapBinder.newMapBinder(binder(),
                TypeLiteral.get(String.class),
                new TypeLiteral<OutputConfiguration.Factory<? extends OutputConfiguration>>() {
                });
    }

    install(new FactoryModuleBuilder().implement(Output.class, outputClass).build(outputFactoryClass));
    install(new FactoryModuleBuilder().implement(Configuration.class, outputConfigurationClass).build(outputConfigurationFactoryClass));

    outputsMapBinder.addBinding(type).to(outputConfigurationFactoryClass);
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:19,代码来源:CollectorModule.java

示例3: configure

import com.google.inject.multibindings.MapBinder; //导入依赖的package包/类
@Override
protected void configure() {
  bind(Parameters.class).toInstance(params);
  // declare that people can provide scoring observer plugins, even though none are
  // provided by default
  MapBinder.newMapBinder(binder(), TypeLiteral.get(String.class),
      new TypeLiteral<ScoringEventObserver<DocLevelEventArg, DocLevelEventArg>>() {
      });
  try {
    bind(EREToKBPEventOntologyMapper.class)
        .toInstance(EREToKBPEventOntologyMapper.create2016Mapping());
  } catch (IOException ioe) {
    throw new TACKBPEALException(ioe);
  }
  install(new ResponsesAndLinkingFromEREExtractor.Module());
  install(new FactoryModuleBuilder()
      .build(ResponsesAndLinkingFromKBPExtractorFactory.class));
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:19,代码来源:ScoreKBPAgainstERE.java

示例4: TypeMapBinder

import com.google.inject.multibindings.MapBinder; //导入依赖的package包/类
public TypeMapBinder(Binder binder, @Nullable TypeLiteral<K> keyType, @Nullable TypeLiteral<V> valueType) {
    this.keyType = keyType != null ? keyType : new ResolvableType<K>(){}.in(getClass());
    this.valueType = valueType != null ? valueType : new ResolvableType<V>(){}.in(getClass());

    final TypeArgument<K> keyTypeArg = new TypeArgument<K>(this.keyType){};
    final TypeArgument<V> valueTypeArg = new TypeArgument<V>(this.valueType){};

    this.collectionKey = Key.get(new ResolvableType<TypeMap<K, V>>(){}.with(keyTypeArg, valueTypeArg));
    this.backingCollectionKey = Key.get(new ResolvableType<Map<TypeToken<? extends K>, Set<V>>>(){}.with(keyTypeArg, valueTypeArg));

    this.backingCollectionBinder = MapBinder.newMapBinder(
        binder,
        new ResolvableType<TypeToken<? extends K>>(){}.with(keyTypeArg),
        this.valueType
    ).permitDuplicates();

    binder.install(new KeyedManifest.Impl(collectionKey) {
        @Override
        public void configure() {
            final Provider<Map<TypeToken<? extends K>, Set<V>>> backingCollectionProvider = getProvider(backingCollectionKey);
            bind(collectionType()).toProvider(() -> ImmutableTypeMap.copyOf(backingCollectionProvider.get()));
        }
    });
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:25,代码来源:TypeMapBinder.java

示例5: configure

import com.google.inject.multibindings.MapBinder; //导入依赖的package包/类
@Override
protected void configure() {
    /*
     * Register your plugin types here.
     *
     * Examples:
     *
     * addMessageInput(Class<? extends MessageInput>);
     * addMessageFilter(Class<? extends MessageFilter>);
     * addMessageOutput(Class<? extends MessageOutput>);
     * addPeriodical(Class<? extends Periodical>);
     * addAlarmCallback(Class<? extends AlarmCallback>);
     * addInitializer(Class<? extends Service>);
     * addRestResource(Class<? extends PluginRestResource>);
     *
     *
     * Add all configuration beans returned by getConfigBeans():
     *
     * addConfigBeans();
     */

    MapBinder<String, Factory<? extends MessageOutput>> outputMapBinder = outputsMapBinder();
    installOutput(outputMapBinder, FileOutput.class, FileOutput.Factory.class);
}
 
开发者ID:scampuza,项目名称:graylog-plugin-file-output,代码行数:25,代码来源:FileOutputModule.java

示例6: configure

import com.google.inject.multibindings.MapBinder; //导入依赖的package包/类
@Override
protected void configure() {
	bind(DuplicateMessageFilter.class).to(DuplicateMessageFilterImpl.class);
	bind(MessageReceiver.class).to(MessageReceiverImpl.class);
	bind(MessageSender.class).to(MessageSenderImpl.class);
	bind(PostbackPayloadService.class).to(PostbackPayloadServiceImpl.class);
	bind(SessionManager.class).to(InMemorySessionManagerImpl.class);
	bind(InMemorySessionManager.class).to(InMemorySessionManagerImpl.class);

	final MapBinder<Platform, PlatformMessageSender> platformMessageSenderBinder = MapBinder.newMapBinder(binder(),
			Platform.class, PlatformMessageSender.class);
	platformMessageSenderBinder.addBinding(FacebookPlatformEnum.FACEBOOK).to(FacebookMessageSenderImpl.class);
	platformMessageSenderBinder.addBinding(SlackPlatformEnum.SLACK).to(SlackMessageSenderImpl.class);
	platformMessageSenderBinder.addBinding(TelegramPlatformEnum.TELEGRAM).to(TelegramMessageSenderImpl.class);
	platformMessageSenderBinder.addBinding(AlexaPlatformEnum.ALEXA).to(AlexaMessageSenderImpl.class);
	platformMessageSenderBinder.addBinding(ApiAiPlatformEnum.APIAI).to(ApiAiMessageSenderImpl.class);
}
 
开发者ID:nitroventures,项目名称:bot4j,代码行数:18,代码来源:MiddlewareModule.java

示例7: module

import com.google.inject.multibindings.MapBinder; //导入依赖的package包/类
public static Module module(final int configSourcePriority)
{
    return new AbstractModule()
    {
        @Override
        protected void configure()
        {
            MapBinder<Integer, DynamicConfigSource> mapBinder = MapBinder.newMapBinder(binder(), Integer.class, DynamicConfigSource.class);
            mapBinder.addBinding(configSourcePriority).to(FileDynamicConfigSource.class);
            bind(FileDynamicConfigSource.class);

            // Bind inner class as a service to ensure resource cleanup
            Multibinder.newSetBinder(binder(), Service.class).addBinding().to(FileDynamicConfigSourceService.class);
        }
    };
}
 
开发者ID:kikinteractive,项目名称:ice,代码行数:17,代码来源:FileDynamicConfigSource.java

示例8: getRootModule

import com.google.inject.multibindings.MapBinder; //导入依赖的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

示例9: configure

import com.google.inject.multibindings.MapBinder; //导入依赖的package包/类
@Override
protected void configure() {
    install(new JavaEngineModule());
    bind(ViewRegistry.class).toInstance(new ViewRegistry() {
        @Override
        public OperatorNode<SequenceOperator> getView(List<String> name) {
            return null;
        }
    });
    bind(TaskMetricEmitter.class).toInstance(
            new DummyStandardRequestEmitter(new MetricDimension(), new RequestMetricSink() {
                @Override
                public void emitRequest(final RequestEvent arg0) {
                }            
              }).start("program", "program"));
    MapBinder<String, Source> sourceBindings = MapBinder.newMapBinder(binder(), String.class, Source.class);
    sourceBindings.addBinding("weather").toInstance(new WeatherSource());
    sourceBindings.addBinding("geo").toInstance(new GeoSource());
}
 
开发者ID:yahoo,项目名称:yql-plus,代码行数:20,代码来源:SourceModule.java

示例10: configure

import com.google.inject.multibindings.MapBinder; //导入依赖的package包/类
@Override
protected void configure() {
    install(new JavaEngineModule());
    bind(ViewRegistry.class).toInstance(new ViewRegistry() {
        @Override
        public OperatorNode<SequenceOperator> getView(List<String> name) {
            return null;
        }
    });
    bind(TaskMetricEmitter.class).toInstance(
            new DummyStandardRequestEmitter(new MetricDimension(), new RequestMetricSink() {
                @Override
                public void emitRequest(final RequestEvent arg0) {
                }
            }).start("program", "program"));
    MapBinder<String, Source> sourceBindings = MapBinder.newMapBinder(binder(), String.class, Source.class);
    sourceBindings.addBinding("stocks").toInstance(new StockSource());
    sourceBindings.addBinding("putStock").toInstance(new StockPutSource());
    sourceBindings.addBinding("updateStocks").toInstance(new StockUpdateSource());
}
 
开发者ID:yahoo,项目名称:yql-plus,代码行数:21,代码来源:SourceModule.java

示例11: testSimplistWithBoxedParamSourceSource

import com.google.inject.multibindings.MapBinder; //导入依赖的package包/类
@Test
public void testSimplistWithBoxedParamSourceSource() throws Exception {
    String programStr = "PROGRAM (@category string); \n" +
                        "select id, category \n" +
                        "from sampleListWithBoxedParams(10, 5.0, \"program\") \n" +
                        "where category = @category order by id \n" + 
                        "output as sampleIds; \n";
    Injector injector = Guice.createInjector(new JavaTestModule(), new AbstractModule() {
        @Override
        protected void configure() {
            MapBinder<String, Source> sourceBindings = MapBinder.newMapBinder(binder(), String.class, Source.class);
            sourceBindings.addBinding("sampleListWithBoxedParams").toInstance(new SampleListSourceWithBoxedParams());
        }            
    });
    YQLPlusCompiler compiler = injector.getInstance(YQLPlusCompiler.class);
    CompiledProgram program = compiler.compile(programStr);
    ProgramResult myResult = program.run(new ImmutableMap.Builder<String, Object>().put("category", "test").build(), true);
    YQLResultSet result = myResult.getResult("sampleIds").get();
    List resultSet = result.getResult();
    assertEquals(10, resultSet.size());
}
 
开发者ID:yahoo,项目名称:yql-plus,代码行数:22,代码来源:JavaProgramCompilerTest.java

示例12: testSimplistWithUnBoxedParamSourceSource

import com.google.inject.multibindings.MapBinder; //导入依赖的package包/类
@Test
public void testSimplistWithUnBoxedParamSourceSource() throws Exception {
    String programStr = "PROGRAM (@category string); \n" +
                        "select id, category \n" +
                        "from sampleListWithUnBoxedParams(10, 5.0, \"program\") \n" +
                        "where category = @category order by id \n" + 
                        "output as sampleIds; \n";
    Injector injector = Guice.createInjector(new JavaTestModule(), new AbstractModule() {
        @Override
        protected void configure() {
            MapBinder<String, Source> sourceBindings = MapBinder.newMapBinder(binder(), String.class, Source.class);
            sourceBindings.addBinding("sampleListWithUnBoxedParams").toInstance(new SampleListSourceWithUnboxedParams());
        }            
    });
    YQLPlusCompiler compiler = injector.getInstance(YQLPlusCompiler.class);
    CompiledProgram program = compiler.compile(programStr);
    ProgramResult myResult = program.run(new ImmutableMap.Builder<String, Object>().put("category", "test").build(), true);
    YQLResultSet result = myResult.getResult("sampleIds").get();
    List resultSet = result.getResult();
    assertEquals(10, resultSet.size());
}
 
开发者ID:yahoo,项目名称:yql-plus,代码行数:22,代码来源:JavaProgramCompilerTest.java

示例13: testEmpytKeyList

import com.google.inject.multibindings.MapBinder; //导入依赖的package包/类
@Test
public void testEmpytKeyList() throws Exception {
    String programStr = "PROGRAM (@category array<string>); \n" +
        "select id, category \n" +
        "from sampleListWithBoxedParams(10, 5.0, \"program\") \n" +
        "where category in (@category) order by id \n" +
        "output as sampleIds; \n";
    Injector injector = Guice.createInjector(new JavaTestModule(), new AbstractModule() {
        @Override
        protected void configure() {
            MapBinder<String, Source> sourceBindings = MapBinder.newMapBinder(binder(), String.class, Source.class);
            sourceBindings.addBinding("sampleListWithBoxedParams").toInstance(new SampleListSourceWithBoxedParams());
        }
    });
    YQLPlusCompiler compiler = injector.getInstance(YQLPlusCompiler.class);
    CompiledProgram program = compiler.compile(programStr);
    ProgramResult myResult = program.run(new ImmutableMap.Builder<String, Object>().put("category", ImmutableList.of()).build(), true);
    YQLResultSet result = myResult.getResult("sampleIds").get();
    List<Record> resultSet = result.getResult();
    assertEquals(0, resultSet.size());
}
 
开发者ID:yahoo,项目名称:yql-plus,代码行数:22,代码来源:JavaProgramCompilerTest.java

示例14: configure

import com.google.inject.multibindings.MapBinder; //导入依赖的package包/类
@Override
protected void configure() {
    bind(IBehaviorDeserialization.class).to(BehaviorDeserialization.class).in(Scopes.SINGLETON);
    MapBinder<String, ILifecycleTask> lifecycleTaskPlugins
            = MapBinder.newMapBinder(binder(), String.class, ILifecycleTask.class);
    lifecycleTaskPlugins.addBinding("ai.labs.behavior").to(BehaviorRulesEvaluationTask.class);

    MapBinder<String, IBehaviorExtension> behaviorExtensionPlugins
            = MapBinder.newMapBinder(binder(), String.class, IBehaviorExtension.class);
    behaviorExtensionPlugins.addBinding("ai.labs.behavior.extension.inputmatcher").
            to(InputMatcher.class);
    behaviorExtensionPlugins.addBinding("ai.labs.behavior.extension.actionmatcher").
            to(ActionMatcher.class);
    behaviorExtensionPlugins.addBinding("ai.labs.behavior.extension.contextmatcher").
            to(ContextMatcher.class);
    behaviorExtensionPlugins.addBinding("ai.labs.behavior.extension.connector").
            to(Connector.class);
    behaviorExtensionPlugins.addBinding("ai.labs.behavior.extension.dependency").
            to(Dependency.class);
    behaviorExtensionPlugins.addBinding("ai.labs.behavior.extension.negation").
            to(Negation.class);
    behaviorExtensionPlugins.addBinding("ai.labs.behavior.extension.occurrence").
            to(Occurrence.class);
    behaviorExtensionPlugins.addBinding("ai.labs.behavior.extension.resultsize").
            to(ResultSize.class);
}
 
开发者ID:labsai,项目名称:EDDI,代码行数:27,代码来源:BehaviorModule.java

示例15: addBinding

import com.google.inject.multibindings.MapBinder; //导入依赖的package包/类
protected void addBinding(String operationName, Class<? extends AjaxHelper> clazz, String... paths)
{
    MapBinder<String, AjaxHelper> mapbinder = MapBinder.newMapBinder(binder(), String.class, AjaxHelper.class);
    mapbinder.addBinding(operationName).to(clazz);

    MapBinder<String, Set<String>> pathRestrictionBinder = MapBinder.newMapBinder(binder(),
                                                                                  new TypeLiteral<String>(){},
                                                                                  new TypeLiteral<Set<String>>(){});
    if(paths != null)
    {
        Set<String> pathSet = new HashSet<String>();
        for(String path : paths)
            pathSet.add(path);
        pathRestrictionBinder.addBinding(operationName).toInstance(pathSet);
    }
}
 
开发者ID:puppetlabs,项目名称:europa,代码行数:17,代码来源:AjaxHelperModule.java


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