org.springframework.web.server.i18n.LocaleContextResolver Java Examples
The following examples show how to use
org.springframework.web.server.i18n.LocaleContextResolver.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultServerWebExchange.java From java-technology-stack with MIT License | 6 votes |
DefaultServerWebExchange(ServerHttpRequest request, ServerHttpResponse response, WebSessionManager sessionManager, ServerCodecConfigurer codecConfigurer, LocaleContextResolver localeContextResolver, @Nullable ApplicationContext applicationContext) { Assert.notNull(request, "'request' is required"); Assert.notNull(response, "'response' is required"); Assert.notNull(sessionManager, "'sessionManager' is required"); Assert.notNull(codecConfigurer, "'codecConfigurer' is required"); Assert.notNull(localeContextResolver, "'localeContextResolver' is required"); // Initialize before first call to getLogPrefix() this.attributes.put(ServerWebExchange.LOG_ID_ATTRIBUTE, request.getId()); this.request = request; this.response = response; this.sessionMono = sessionManager.getSession(this).cache(); this.localeContextResolver = localeContextResolver; this.formDataMono = initFormData(request, codecConfigurer, getLogPrefix()); this.multipartDataMono = initMultipartData(request, codecConfigurer, getLogPrefix()); this.applicationContext = applicationContext; }
Example #2
Source File: DefaultServerWebExchange.java From spring-analysis-note with MIT License | 6 votes |
DefaultServerWebExchange(ServerHttpRequest request, ServerHttpResponse response, WebSessionManager sessionManager, ServerCodecConfigurer codecConfigurer, LocaleContextResolver localeContextResolver, @Nullable ApplicationContext applicationContext) { Assert.notNull(request, "'request' is required"); Assert.notNull(response, "'response' is required"); Assert.notNull(sessionManager, "'sessionManager' is required"); Assert.notNull(codecConfigurer, "'codecConfigurer' is required"); Assert.notNull(localeContextResolver, "'localeContextResolver' is required"); // Initialize before first call to getLogPrefix() this.attributes.put(ServerWebExchange.LOG_ID_ATTRIBUTE, request.getId()); this.request = request; this.response = response; this.sessionMono = sessionManager.getSession(this).cache(); this.localeContextResolver = localeContextResolver; this.formDataMono = initFormData(request, codecConfigurer, getLogPrefix()); this.multipartDataMono = initMultipartData(request, codecConfigurer, getLogPrefix()); this.applicationContext = applicationContext; }
Example #3
Source File: DefaultHandlerStrategiesBuilder.java From spring-analysis-note with MIT License | 5 votes |
public DefaultHandlerStrategies( List<HttpMessageReader<?>> messageReaders, List<HttpMessageWriter<?>> messageWriters, List<ViewResolver> viewResolvers, List<WebFilter> webFilters, List<WebExceptionHandler> exceptionHandlers, LocaleContextResolver localeContextResolver) { this.messageReaders = unmodifiableCopy(messageReaders); this.messageWriters = unmodifiableCopy(messageWriters); this.viewResolvers = unmodifiableCopy(viewResolvers); this.webFilters = unmodifiableCopy(webFilters); this.exceptionHandlers = unmodifiableCopy(exceptionHandlers); this.localeContextResolver = localeContextResolver; }
Example #4
Source File: ReactiveWebServerInitializer.java From spring-fu with Apache License 2.0 | 5 votes |
@Override public void initialize(GenericApplicationContext context) { context.registerBean("webServerFactoryCustomizerBeanPostProcessor", WebServerFactoryCustomizerBeanPostProcessor.class, WebServerFactoryCustomizerBeanPostProcessor::new); context.registerBean(ReactiveWebServerFactoryCustomizer.class, () -> new ReactiveWebServerFactoryCustomizer(this.serverProperties)); context.registerBean(ConfigurableReactiveWebServerFactory.class, () -> serverFactory); //noinspection deprecation context.registerBean(ErrorAttributes.class, () -> new DefaultErrorAttributes(serverProperties.getError().isIncludeException())); context.registerBean(ErrorWebExceptionHandler.class, () -> { ErrorWebFluxAutoConfiguration errorConfiguration = new ErrorWebFluxAutoConfiguration(this.serverProperties); return errorConfiguration.errorWebExceptionHandler(context.getBean(ErrorAttributes.class), this.resourceProperties, context.getBeanProvider(ViewResolver.class), context.getBean(SERVER_CODEC_CONFIGURER_BEAN_NAME, ServerCodecConfigurer.class), context); }); context.registerBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class, () -> new EnableWebFluxConfigurationWrapper(context, webFluxProperties)); context.registerBean(LOCALE_CONTEXT_RESOLVER_BEAN_NAME, LocaleContextResolver.class, () -> context.getBean(EnableWebFluxConfigurationWrapper.class).localeContextResolver()); context.registerBean("responseStatusExceptionHandler", WebExceptionHandler.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).responseStatusExceptionHandler()); context.registerBean(RouterFunctionMapping.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).routerFunctionMapping(context.getBean(SERVER_CODEC_CONFIGURER_BEAN_NAME, ServerCodecConfigurer.class))); context.registerBean(SERVER_CODEC_CONFIGURER_BEAN_NAME, ServerCodecConfigurer.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).serverCodecConfigurer()); context.registerBean("webFluxAdapterRegistry", ReactiveAdapterRegistry.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).webFluxAdapterRegistry()); context.registerBean("handlerFunctionAdapter", HandlerFunctionAdapter.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).handlerFunctionAdapter()); context.registerBean("webFluxContentTypeResolver", RequestedContentTypeResolver.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).webFluxContentTypeResolver()); context.registerBean("webFluxConversionService", FormattingConversionService.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).webFluxConversionService()); context.registerBean("serverResponseResultHandler", ServerResponseResultHandler.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).serverResponseResultHandler(context.getBean(SERVER_CODEC_CONFIGURER_BEAN_NAME, ServerCodecConfigurer.class))); context.registerBean("simpleHandlerAdapter", SimpleHandlerAdapter.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).simpleHandlerAdapter()); context.registerBean("viewResolutionResultHandler", ViewResolutionResultHandler.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).viewResolutionResultHandler(context.getBean("webFluxAdapterRegistry", ReactiveAdapterRegistry.class), context.getBean("webFluxContentTypeResolver", RequestedContentTypeResolver.class))); context.registerBean("webFluxValidator", Validator.class, () -> context.getBean("fuWebFluxConfiguration", EnableWebFluxConfigurationWrapper.class).webFluxValidator()); context.registerBean(HttpHandler.class, () -> applicationContext(context).build()); context.registerBean(WEB_HANDLER_BEAN_NAME, DispatcherHandler.class, (Supplier<DispatcherHandler>) DispatcherHandler::new); context.registerBean(WebFluxConfig.class, () -> new WebFluxConfig(resourceProperties, webFluxProperties, context, context.getBeanProvider(HandlerMethodArgumentResolver.class), context.getBeanProvider(CodecCustomizer.class), context.getBeanProvider(ResourceHandlerRegistrationCustomizer.class), context.getBeanProvider(ViewResolver.class))); }
Example #5
Source File: DefaultHandlerStrategiesBuilder.java From java-technology-stack with MIT License | 5 votes |
public DefaultHandlerStrategies( List<HttpMessageReader<?>> messageReaders, List<HttpMessageWriter<?>> messageWriters, List<ViewResolver> viewResolvers, List<WebFilter> webFilters, List<WebExceptionHandler> exceptionHandlers, LocaleContextResolver localeContextResolver) { this.messageReaders = unmodifiableCopy(messageReaders); this.messageWriters = unmodifiableCopy(messageWriters); this.viewResolvers = unmodifiableCopy(viewResolvers); this.webFilters = unmodifiableCopy(webFilters); this.exceptionHandlers = unmodifiableCopy(exceptionHandlers); this.localeContextResolver = localeContextResolver; }
Example #6
Source File: LocaleContextResolverIntegrationTests.java From spring-analysis-note with MIT License | 4 votes |
@Override protected LocaleContextResolver createLocaleContextResolver() { return new FixedLocaleContextResolver(Locale.GERMANY); }
Example #7
Source File: HttpWebHandlerAdapter.java From spring-analysis-note with MIT License | 4 votes |
/** * Return the configured {@link LocaleContextResolver}. */ public LocaleContextResolver getLocaleContextResolver() { return this.localeContextResolver; }
Example #8
Source File: DefaultServerWebExchange.java From spring-analysis-note with MIT License | 4 votes |
public DefaultServerWebExchange(ServerHttpRequest request, ServerHttpResponse response, WebSessionManager sessionManager, ServerCodecConfigurer codecConfigurer, LocaleContextResolver localeContextResolver) { this(request, response, sessionManager, codecConfigurer, localeContextResolver, null); }
Example #9
Source File: WebFluxConfigurationSupport.java From spring-analysis-note with MIT License | 4 votes |
@Bean public LocaleContextResolver localeContextResolver() { return createLocaleContextResolver(); }
Example #10
Source File: WebFluxConfigurationSupport.java From spring-analysis-note with MIT License | 4 votes |
/** * Override to plug a sub-class of {@link LocaleContextResolver}. */ protected LocaleContextResolver createLocaleContextResolver() { return new AcceptHeaderLocaleContextResolver(); }
Example #11
Source File: DefaultHandlerStrategiesBuilder.java From java-technology-stack with MIT License | 4 votes |
@Override public LocaleContextResolver localeContextResolver() { return this.localeContextResolver; }
Example #12
Source File: WebFluxConfigurationSupport.java From java-technology-stack with MIT License | 4 votes |
/** * Override to plug a sub-class of {@link LocaleContextResolver}. */ protected LocaleContextResolver createLocaleContextResolver() { return new AcceptHeaderLocaleContextResolver(); }
Example #13
Source File: WebFluxConfigurationSupport.java From java-technology-stack with MIT License | 4 votes |
@Bean public LocaleContextResolver localeContextResolver() { return createLocaleContextResolver(); }
Example #14
Source File: LocaleContextResolverIntegrationTests.java From java-technology-stack with MIT License | 4 votes |
@Override protected LocaleContextResolver createLocaleContextResolver() { return new FixedLocaleContextResolver(Locale.GERMANY); }
Example #15
Source File: HttpWebHandlerAdapter.java From java-technology-stack with MIT License | 4 votes |
/** * Return the configured {@link LocaleContextResolver}. */ public LocaleContextResolver getLocaleContextResolver() { return this.localeContextResolver; }
Example #16
Source File: DefaultServerWebExchange.java From java-technology-stack with MIT License | 4 votes |
public DefaultServerWebExchange(ServerHttpRequest request, ServerHttpResponse response, WebSessionManager sessionManager, ServerCodecConfigurer codecConfigurer, LocaleContextResolver localeContextResolver) { this(request, response, sessionManager, codecConfigurer, localeContextResolver, null); }
Example #17
Source File: DefaultHandlerStrategiesBuilder.java From spring-analysis-note with MIT License | 4 votes |
@Override public LocaleContextResolver localeContextResolver() { return this.localeContextResolver; }
Example #18
Source File: HttpWebHandlerAdapter.java From spring-analysis-note with MIT License | 2 votes |
/** * Configure a custom {@link LocaleContextResolver}. The provided instance is set on * each created {@link DefaultServerWebExchange}. * <p>By default this is set to * {@link org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver}. * @param resolver the locale context resolver to use */ public void setLocaleContextResolver(LocaleContextResolver resolver) { Assert.notNull(resolver, "LocaleContextResolver is required"); this.localeContextResolver = resolver; }
Example #19
Source File: HandlerStrategies.java From java-technology-stack with MIT License | 2 votes |
/** * Return the {@link LocaleContextResolver} to be used for resolving locale context. * @return the locale context resolver */ LocaleContextResolver localeContextResolver();
Example #20
Source File: HttpWebHandlerAdapter.java From java-technology-stack with MIT License | 2 votes |
/** * Configure a custom {@link LocaleContextResolver}. The provided instance is set on * each created {@link DefaultServerWebExchange}. * <p>By default this is set to * {@link org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver}. * @param resolver the locale context resolver to use */ public void setLocaleContextResolver(LocaleContextResolver resolver) { Assert.notNull(resolver, "LocaleContextResolver is required"); this.localeContextResolver = resolver; }
Example #21
Source File: HandlerStrategies.java From spring-analysis-note with MIT License | 2 votes |
/** * Return the {@link LocaleContextResolver} to be used for resolving locale context. * @return the locale context resolver */ LocaleContextResolver localeContextResolver();