Java Code Examples for org.springframework.web.server.i18n.LocaleContextResolver

The following examples show how to use org.springframework.web.server.i18n.LocaleContextResolver. These examples are extracted from open source projects. 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 Project: spring-analysis-note   Source File: DefaultServerWebExchange.java    License: MIT License 6 votes vote down vote up
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 Project: java-technology-stack   Source File: DefaultServerWebExchange.java    License: MIT License 6 votes vote down vote up
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
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
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 5
Source Project: spring-fu   Source File: ReactiveWebServerInitializer.java    License: Apache License 2.0 5 votes vote down vote up
@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 6
@Override
public LocaleContextResolver localeContextResolver() {
	return this.localeContextResolver;
}
 
Example 7
Source Project: spring-analysis-note   Source File: WebFluxConfigurationSupport.java    License: MIT License 4 votes vote down vote up
/**
 * Override to plug a sub-class of {@link LocaleContextResolver}.
 */
protected LocaleContextResolver createLocaleContextResolver() {
	return new AcceptHeaderLocaleContextResolver();
}
 
Example 8
Source Project: spring-analysis-note   Source File: WebFluxConfigurationSupport.java    License: MIT License 4 votes vote down vote up
@Bean
public LocaleContextResolver localeContextResolver() {
	return createLocaleContextResolver();
}
 
Example 9
@Override
protected LocaleContextResolver createLocaleContextResolver() {
	return new FixedLocaleContextResolver(Locale.GERMANY);
}
 
Example 10
Source Project: spring-analysis-note   Source File: HttpWebHandlerAdapter.java    License: MIT License 4 votes vote down vote up
/**
 * Return the configured {@link LocaleContextResolver}.
 */
public LocaleContextResolver getLocaleContextResolver() {
	return this.localeContextResolver;
}
 
Example 11
Source Project: spring-analysis-note   Source File: DefaultServerWebExchange.java    License: MIT License 4 votes vote down vote up
public DefaultServerWebExchange(ServerHttpRequest request, ServerHttpResponse response,
		WebSessionManager sessionManager, ServerCodecConfigurer codecConfigurer,
		LocaleContextResolver localeContextResolver) {

	this(request, response, sessionManager, codecConfigurer, localeContextResolver, null);
}
 
Example 12
@Override
public LocaleContextResolver localeContextResolver() {
	return this.localeContextResolver;
}
 
Example 13
/**
 * Override to plug a sub-class of {@link LocaleContextResolver}.
 */
protected LocaleContextResolver createLocaleContextResolver() {
	return new AcceptHeaderLocaleContextResolver();
}
 
Example 14
@Bean
public LocaleContextResolver localeContextResolver() {
	return createLocaleContextResolver();
}
 
Example 15
@Override
protected LocaleContextResolver createLocaleContextResolver() {
	return new FixedLocaleContextResolver(Locale.GERMANY);
}
 
Example 16
Source Project: java-technology-stack   Source File: HttpWebHandlerAdapter.java    License: MIT License 4 votes vote down vote up
/**
 * Return the configured {@link LocaleContextResolver}.
 */
public LocaleContextResolver getLocaleContextResolver() {
	return this.localeContextResolver;
}
 
Example 17
Source Project: java-technology-stack   Source File: DefaultServerWebExchange.java    License: MIT License 4 votes vote down vote up
public DefaultServerWebExchange(ServerHttpRequest request, ServerHttpResponse response,
		WebSessionManager sessionManager, ServerCodecConfigurer codecConfigurer,
		LocaleContextResolver localeContextResolver) {

	this(request, response, sessionManager, codecConfigurer, localeContextResolver, null);
}
 
Example 18
Source Project: spring-analysis-note   Source File: HandlerStrategies.java    License: MIT License 2 votes vote down vote up
/**
 * Return the {@link LocaleContextResolver} to be used for resolving locale context.
 * @return the locale context resolver
 */
LocaleContextResolver localeContextResolver();
 
Example 19
Source Project: spring-analysis-note   Source File: HttpWebHandlerAdapter.java    License: MIT License 2 votes vote down vote up
/**
 * 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 20
Source Project: java-technology-stack   Source File: HandlerStrategies.java    License: MIT License 2 votes vote down vote up
/**
 * Return the {@link LocaleContextResolver} to be used for resolving locale context.
 * @return the locale context resolver
 */
LocaleContextResolver localeContextResolver();
 
Example 21
Source Project: java-technology-stack   Source File: HttpWebHandlerAdapter.java    License: MIT License 2 votes vote down vote up
/**
 * 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;
}