This commit is contained in:
Rossen Stoyanchev
2017-09-27 21:48:35 -04:00
parent 869b818e96
commit 13c959296a
3 changed files with 10 additions and 5 deletions

View File

@@ -129,7 +129,8 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa
/**
* 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}.
* <p>By default this is set to
* {@link org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver}.
* @param localeContextResolver the locale context resolver to use
*/
public void setLocaleContextResolver(LocaleContextResolver localeContextResolver) {
@@ -147,7 +148,8 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa
* Return the configured {@link LocaleContextResolver}.
*/
public LocaleContextResolver getLocaleContextResolver() {
return (this.localeContextResolver != null ? this.localeContextResolver : new AcceptHeaderLocaleContextResolver());
return (this.localeContextResolver != null ?
this.localeContextResolver : new AcceptHeaderLocaleContextResolver());
}
@@ -164,7 +166,8 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa
}
protected ServerWebExchange createExchange(ServerHttpRequest request, ServerHttpResponse response) {
return new DefaultServerWebExchange(request, response, this.sessionManager, getCodecConfigurer(), getLocaleContextResolver());
return new DefaultServerWebExchange(request, response, this.sessionManager,
getCodecConfigurer(), getLocaleContextResolver());
}
private void logHandleFailure(Throwable ex) {

View File

@@ -97,7 +97,8 @@ public class AcceptHeaderLocaleContextResolver implements LocaleContextResolver
if (supportedLocale != null) {
return new SimpleLocaleContext(supportedLocale);
}
return (defaultLocale != null ? new SimpleLocaleContext(defaultLocale) : new SimpleLocaleContext(requestLocale));
return (this.defaultLocale != null ? new SimpleLocaleContext(this.defaultLocale) :
new SimpleLocaleContext(requestLocale));
}
private boolean isSupportedLocale(@Nullable Locale locale) {

View File

@@ -88,7 +88,8 @@ public class FixedLocaleContextResolver implements LocaleContextResolver {
@Override
public void setLocaleContext(ServerWebExchange exchange, @Nullable LocaleContext localeContext) {
throw new UnsupportedOperationException("Cannot change fixed locale - use a different locale context resolution strategy");
throw new UnsupportedOperationException(
"Cannot change fixed locale - use a different locale context resolution strategy");
}
}