本文整理匯總了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);
}
示例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);
}
示例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));
}
示例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()));
}
});
}
示例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);
}
示例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);
}
示例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);
}
};
}
示例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()));
}
}
});
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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);
}
示例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);
}
}