本文整理匯總了Java中com.google.inject.multibindings.Multibinder類的典型用法代碼示例。如果您正苦於以下問題:Java Multibinder類的具體用法?Java Multibinder怎麽用?Java Multibinder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Multibinder類屬於com.google.inject.multibindings包,在下文中一共展示了Multibinder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: configure
import com.google.inject.multibindings.Multibinder; //導入依賴的package包/類
@Override
protected void configure() {
install(new ResteasyModule());
bind(HelloDao.class).in(Singleton.class);
bind(HelloResource.class);
BuildInfo buildInfo = BuildInfo.load(getClass().getResourceAsStream("build-info.properties"));
bind(BuildInfo.class).toInstance(buildInfo);
bind(ServiceMetadata.class).toInstance(
ServiceMetadata.builder()
.setBuildInfo(buildInfo)
.setHostName("bogusbox")
.setStartupTime(Instant.parse("2001-01-01T01:01:01Z"))
.build()); // In a real service, use ServiceMetadata.create instead of ServiceMetadata.builder
Multibinder<HealthDependency> healthDependencyBinder =
Multibinder.newSetBinder(binder(), HealthDependency.class);
healthDependencyBinder.addBinding().to(ImportantThingHealthDependency.class);
bind(FauxLifecycleHook.class).asEagerSingleton();
}
示例2: configure
import com.google.inject.multibindings.Multibinder; //導入依賴的package包/類
@Override
protected void configure() {
requireBinding(SwaggerConfig.class);
// Create empty multibinder in case no ModelConverter bindings exist
Multibinder<ModelConverter> swaggerModelConverterBinder = Multibinder.newSetBinder(
binder(), ModelConverter.class);
bind(SwaggerApiResource.class);
bind(SwaggerUiResource.class);
bind(ApiDeclarationProvider.class);
bind(ResourceListingProvider.class);
bind(JaxrsApiReader.class).to(DefaultJaxrsApiReader.class);
bind(JaxrsScanner.class).to(SwaggerGuiceJaxrsScanner.class);
bind(SwaggerLifecycleHook.class).asEagerSingleton();
install(MultibindingsScanner.asModule());
}
示例3: configure
import com.google.inject.multibindings.Multibinder; //導入依賴的package包/類
@Override
protected void configure() {
Multibinder.newSetBinder(binder(), Module.class, clientBindingAnnotation);
Multibinder.newSetBinder(binder(), SerializationFeatureFlag.class, clientBindingAnnotation);
Multibinder.newSetBinder(binder(), DeserializationFeatureFlag.class, clientBindingAnnotation);
Multibinder.newSetBinder(binder(), JsonGeneratorFeatureFlag.class, clientBindingAnnotation);
Multibinder.newSetBinder(binder(), JsonParserFeatureFlag.class, clientBindingAnnotation);
Multibinder.newSetBinder(binder(), MapperFeatureFlag.class, clientBindingAnnotation);
/**
* MultibindingsScanner will scan all modules for methods with the annotations @ProvidesIntoMap,
* @ProvidesIntoSet, and @ProvidesIntoOptional.
*/
install(MultibindingsScanner.asModule());
install(AnnotatedJacksonPrivateModule.with(clientBindingAnnotation));
}
示例4: configure
import com.google.inject.multibindings.Multibinder; //導入依賴的package包/類
@Override
protected void configure() {
requireBinding(ServiceMetadata.class);
requireBinding(UriInfo.class);
bind(AvailabilityResource.class).to(AvailabilityResourceImpl.class);
bind(HealthResource.class).to(HealthResourceImpl.class);
bind(DependenciesResource.class).to(DependenciesResourceImpl.class);
bind(DiagnosticResource.class).to(DiagnosticResourceImpl.class);
bind(VersionResource.class).to(VersionResourceImpl.class);
bind(HealthChecker.class);
//This is to provide a default binding for HealthDependency,
// so that services with no HealthDependency bindings can start
Multibinder<HealthDependency> healthDependencyModuleBinder = Multibinder.newSetBinder(binder(),
HealthDependency.class);
Multibinder<Module> jacksonModuleBinder = Multibinder.newSetBinder(binder(), Module.class);
jacksonModuleBinder.addBinding().to(Jdk8Module.class);
jacksonModuleBinder.addBinding().to(JavaTimeModule.class);
install(MultibindingsScanner.asModule());
}
示例5: configure
import com.google.inject.multibindings.Multibinder; //導入依賴的package包/類
@Override
protected void configure() {
// Empty multibindings for dependencies
Multibinder<Module> jacksonModuleBinder = Multibinder.newSetBinder(binder(), Module.class);
Multibinder<SerializationFeatureFlag> serializationFeatureBinder = Multibinder
.newSetBinder(binder(), SerializationFeatureFlag.class);
Multibinder<DeserializationFeatureFlag> deserializationFeatureBinder = Multibinder
.newSetBinder(binder(), DeserializationFeatureFlag.class);
Multibinder<JsonGeneratorFeatureFlag> jsonGeneratorFeatureBinder = Multibinder
.newSetBinder(binder(), JsonGeneratorFeatureFlag.class);
Multibinder<JsonParserFeatureFlag> jsonParserFeatureBinder = Multibinder
.newSetBinder(binder(), JsonParserFeatureFlag.class);
Multibinder<MapperFeatureFlag> mapperFeatureBinder = Multibinder
.newSetBinder(binder(), MapperFeatureFlag.class);
/**
* MultibindingsScanner will scan all modules for methods with the annotations @ProvidesIntoMap,
* @ProvidesIntoSet, and @ProvidesIntoOptional.
*/
install(MultibindingsScanner.asModule());
bind(ObjectMapper.class).toProvider(ObjectMapperProvider.class).asEagerSingleton();
}
示例6: bindRoutes
import com.google.inject.multibindings.Multibinder; //導入依賴的package包/類
private void bindRoutes() {
Multibinder<SparkRouter> routerBinder = Multibinder.newSetBinder(binder(), SparkRouter.class);
routerBinder.addBinding().to(SignUpRouter.class);
routerBinder.addBinding().to(LogInRouter.class);
routerBinder.addBinding().to(UserProfileRouter.class);
routerBinder.addBinding().to(ListMachinesRouter.class);
routerBinder.addBinding().to(AddMachineRouter.class);
routerBinder.addBinding().to(RemoveMachineRouter.class);
routerBinder.addBinding().to(EditMachineRouter.class);
routerBinder.addBinding().to(GetMachineRouter.class);
routerBinder.addBinding().to(EditPersonRouter.class);
routerBinder.addBinding().to(EditPasswordRouter.class);
routerBinder.addBinding().to(AddTechnicianRouter.class);
routerBinder.addBinding().to(ListTechniciansRouter.class);
routerBinder.addBinding().to(AssignMaintainerRouter.class);
routerBinder.addBinding().to(RemoveTechnicianRouter.class);
routerBinder.addBinding().to(GetPersonProfileRouter.class);
}
示例7: configure
import com.google.inject.multibindings.Multibinder; //導入依賴的package包/類
@Override
protected void configure() {
Multibinder<Constraint> constraintBinder = Multibinder.newSetBinder(binder(), Constraint.class);
String none = "NONE";
String constraints = getEnvironmentVariableOrPropertyIgnoreError(properties, CONSTRAINT_STRATEGIES_KEY, none);
if ("ALL".equalsIgnoreCase(constraints.trim())) {
ModuleHelper.bindAll(constraintBinder, Constraints::values);
} else if (none.equalsIgnoreCase(constraints.trim())) {
ModuleHelper.bindStrategies(constraintBinder, none, Constraints::valueOf);
} else {
try {
ModuleHelper.bindStrategies(constraintBinder, constraints.replace(none, ""), Constraints::valueOf);
} catch (IllegalArgumentException ex) {
addError(ex);
}
}
}
示例8: configure
import com.google.inject.multibindings.Multibinder; //導入依賴的package包/類
@Override
protected void configure() {
bind(CleanupService.class).to(CleanupServiceImpl.class);
bind(CleanupStrategy.class).to(ConfigurableCleanupStrategy.class);
bind(CleanupSettings.class).to(CleanupSettingsImpl.class);
String strategies = getEnvironmentVariableOrProperty(properties, CLEANUP_STRATEGY_KEY).toUpperCase(Locale.ENGLISH);
Multibinder<CleanupProcessor> cleanupBinder = Multibinder.newSetBinder(binder(), CleanupProcessor.class);
try {
ModuleHelper.bindStrategies(cleanupBinder, strategies, CleanupProcessors::valueOf);
} catch (IllegalArgumentException ex) {
addError(new InvalidConfigurationException("Invalid cleanup strategy: {}.", ex.getMessage()));
}
ModuleHelper.checkStrategiesForIncompatibilities(strategies, CLEANUP_STRATEGY_KEY,
CleanupProcessors.STRUCTURED_OUTPUT.name(), CleanupProcessors.UNIFIED_OUTPUT.name());
ModuleHelper.checkStrategiesForIncompatibilities(strategies, CLEANUP_STRATEGY_KEY,
CleanupProcessors.DELETE_SOURCE.name(), CleanupProcessors.MARK_SOURCE.name());
}
示例9: configure
import com.google.inject.multibindings.Multibinder; //導入依賴的package包/類
@Override
protected void configure() {
bind(TelegramWebhook.class).to(TelegramWebhookImpl.class);
bind(TelegramConfig.class).to(TelegramConfigImpl.class);
bind(TelegramConfigService.class).to(TelegramConfigServiceImpl.class);
bind(TelegramMessageSender.class).to(TelegramMessageSenderImpl.class);
bind(TelegramSendInlineKeyboardFactory.class).to(TelegramSendInlineKeyboardFactoryImpl.class);
bind(TelegramReceiveHandler.class).to(TelegramReceiveHandlerImpl.class);
bind(TelegramReceiveMessageFactory.class).to(TelegramReceiveMessageFactoryImpl.class);
bind(TelegramReceivePayloadFactory.class).to(TelegramReceivePayloadFactoryImpl.class);
bind(TelegramWebhook.class).to(TelegramWebhookImpl.class);
final Multibinder<TelegramSendRule> telegramSendRuleBinder = Multibinder.newSetBinder(binder(),
TelegramSendRule.class);
telegramSendRuleBinder.addBinding().to(BubbleRuleImpl.class);
telegramSendRuleBinder.addBinding().to(ButtonsRuleImpl.class);
telegramSendRuleBinder.addBinding().to(ImageRuleImpl.class);
telegramSendRuleBinder.addBinding().to(ListRuleImpl.class);
telegramSendRuleBinder.addBinding().to(NativeRuleImpl.class);
telegramSendRuleBinder.addBinding().to(TextRuleImpl.class);
telegramSendRuleBinder.addBinding().to(VideoRuleImpl.class);
}
示例10: configure
import com.google.inject.multibindings.Multibinder; //導入依賴的package包/類
@Override
protected void configure() {
bind(SlackActionWebhook.class).to(SlackActionWebhookImpl.class);
bind(SlackConfig.class).to(SlackConfigImpl.class);
bind(SlackConfigService.class).to(SlackConfigServiceImpl.class);
bind(SlackEventWebhook.class).to(SlackEventWebhookImpl.class);
bind(SlackMessageSender.class).to(SlackMessageSenderImpl.class);
bind(SlackOAuthClient.class).to(SlackOAuthClientImpl.class);
bind(SlackOAuthWebhook.class).to(SlackOAuthWebhookImpl.class);
bind(SlackReceiveHandler.class).to(SlackReceiveHandlerImpl.class);
bind(SlackReceiveActionMessageFactory.class).to(SlackReceiveActionMessageFactoryImpl.class);
bind(SlackReceiveEventMessageFactory.class).to(SlackReceiveEventMessageFactoryImpl.class);
bind(SlackReceivePayloadFactory.class).to(SlackReceivePayloadFactoryImpl.class);
bind(SlackSendActionFactory.class).to(SlackSendActionFactoryImpl.class);
bind(SlackSendAttachmentFactory.class).to(SlackSendAttachmentFactoryImpl.class);
final Multibinder<SlackSendRule> slackSendRuleBinder = Multibinder.newSetBinder(binder(), SlackSendRule.class);
slackSendRuleBinder.addBinding().to(NativeRuleImpl.class);
slackSendRuleBinder.addBinding().to(TextRuleImpl.class);
slackSendRuleBinder.addBinding().to(ButtonsRuleImpl.class);
slackSendRuleBinder.addBinding().to(ImageRuleImpl.class);
slackSendRuleBinder.addBinding().to(VideoRuleImpl.class);
slackSendRuleBinder.addBinding().to(BubbleRuleImpl.class);
slackSendRuleBinder.addBinding().to(ListRuleImpl.class);
}
示例11: configure
import com.google.inject.multibindings.Multibinder; //導入依賴的package包/類
@Override
protected void configure() {
bind(FacebookConfig.class).to(FacebookConfigImpl.class);
bind(FacebookConfigService.class).to(FacebookConfigServiceImpl.class);
bind(FacebookMessageSender.class).to(FacebookMessageSenderImpl.class);
bind(FacebookReceiveHandler.class).to(FacebookReceiveHandlerImpl.class);
bind(FacebookReceiveMessageFactory.class).to(FacebookReceiveMessageFactoryImpl.class);
bind(FacebookReceivePayloadFactory.class).to(FacebookReceivePayloadFactoryImpl.class);
bind(FacebookSendButtonFactory.class).to(FacebookSendButtonFactoryImpl.class);
bind(FacebookWebhook.class).to(FacebookWebhookImpl.class);
final Multibinder<FacebookSendRule> facebookSendRuleBinder = Multibinder.newSetBinder(binder(),
FacebookSendRule.class);
facebookSendRuleBinder.addBinding().to(NativeRuleImpl.class);
facebookSendRuleBinder.addBinding().to(TextRuleImpl.class);
facebookSendRuleBinder.addBinding().to(ButtonsRuleImpl.class);
facebookSendRuleBinder.addBinding().to(ImageRuleImpl.class);
facebookSendRuleBinder.addBinding().to(VideoRuleImpl.class);
facebookSendRuleBinder.addBinding().to(QuickRepliesRuleImpl.class);
facebookSendRuleBinder.addBinding().to(TypingRuleImpl.class);
facebookSendRuleBinder.addBinding().to(BubbleRuleImpl.class);
facebookSendRuleBinder.addBinding().to(ListRuleImpl.class);
}
示例12: module
import com.google.inject.multibindings.Multibinder; //導入依賴的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);
}
};
}
示例13: configure
import com.google.inject.multibindings.Multibinder; //導入依賴的package包/類
@Override
protected void configure() {
bind(FakeSlaves.class).in(Singleton.class);
Multibinder<Offer> offers = Multibinder.newSetBinder(binder(), Offer.class);
offers.addBinding()
.toInstance(baseOffer("slave-1", "a", 16, 16 * 1024, 100 * 1024));
offers.addBinding()
.toInstance(baseOffer("slave-2", "a", 16, 16 * 1024, 100 * 1024));
offers.addBinding()
.toInstance(baseOffer("slave-3", "b", 16, 16 * 1024, 100 * 1024));
offers.addBinding()
.toInstance(baseOffer("slave-4", "b", 16, 16 * 1024, 100 * 1024));
offers.addBinding()
.toInstance(dedicated(baseOffer("slave-5", "c", 24, 128 * 1024, 1824 * 1024), "database"));
offers.addBinding()
.toInstance(dedicated(baseOffer("slave-6", "c", 24, 128 * 1024, 1824 * 1024), "database"));
SchedulerServicesModule.addAppStartupServiceBinding(binder()).to(Register.class);
}
示例14: configure
import com.google.inject.multibindings.Multibinder; //導入依賴的package包/類
@Override
protected void configure() {
bind(ReportEntryLogger.class).to(ReportEntryLoggerImpl.class);
bind(TestEventCollector.class).to(TestEventCollectorImpl.class);
bind(ReportingHandler.ACTIVE_REPORTERS).toProvider(ReporterProvider.class).in(Singleton.class);
SubreportInterceptor subreportInterceptor = new SubreportInterceptor();
requestInjection(subreportInterceptor);
bindInterceptor(Matchers.any(), Matchers.annotatedWith(Subreport.class), subreportInterceptor);
Multibinder<WebDriverEventListener> webDriverListenerBinder = Multibinder.newSetBinder(binder(),
WebDriverEventListener.class);
webDriverListenerBinder.addBinding().to(WebDriverLogger.class);
Multibinder<ProxyEventListener> proxyListenerBinder = Multibinder.newSetBinder(binder(),
ProxyEventListener.class);
proxyListenerBinder.addBinding().to(ProxyLogger.class);
}
示例15: configure
import com.google.inject.multibindings.Multibinder; //導入依賴的package包/類
@Override
protected void configure() {
bindListener(any(), new PageObjectTypeListener());
bindListener(any(), new TestObjectTypeListener());
Multibinder<FieldProvider> fieldProviders =
Multibinder.newSetBinder(binder(), FieldProvider.class);
fieldProviders.addBinding().to(ScopedPageObjectProvider.class);
fieldProviders.addBinding().to(SelectorPageObjectProvider.class);
fieldProviders.addBinding().to(PageObjectListProxyProvider.class);
fieldProviders.addBinding().to(CurrentFrameProvider.class);
fieldProviders.addBinding().to(PageObjectSelectorListProxyProvider.class);
bind(Key.get(WebElement.class, CurrentScope.class)).toProvider(CurrentWebElementProvider.class);
bind(new TypeLiteral<List<WebElement>>() {
}).annotatedWith(CurrentScope.class).toProvider(CurrentScopeListProvider.class);
}