From 5e5add48625e19bf7080957b69f4a6554fad106d Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 20 Jan 2014 21:49:36 +0100 Subject: [PATCH] Locale/ThemeChangeInterceptor alignment and javadoc polishing Issue: SPR-11128 --- .../web/servlet/i18n/AcceptHeaderLocaleResolver.java | 5 ++--- .../web/servlet/i18n/LocaleChangeInterceptor.java | 4 ++-- .../web/servlet/i18n/SessionLocaleResolver.java | 7 ++++--- .../web/servlet/theme/FixedThemeResolver.java | 7 ++++--- .../web/servlet/theme/ThemeChangeInterceptor.java | 12 ++++++------ 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.java index b736a94575..c28f686e5a 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,14 +17,13 @@ package org.springframework.web.servlet.i18n; import java.util.Locale; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.web.servlet.LocaleResolver; /** - * Implementation of LocaleResolver that simply uses the primary locale + * {@link LocaleResolver} implementation that simply uses the primary locale * specified in the "accept-language" header of the HTTP request (that is, * the locale sent by the client browser, normally that of the client's OS). * diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/LocaleChangeInterceptor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/LocaleChangeInterceptor.java index a39919c3e8..833c296235 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/LocaleChangeInterceptor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/LocaleChangeInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ import org.springframework.web.servlet.support.RequestContextUtils; /** * Interceptor that allows for changing the current locale on every request, - * via a configurable request parameter. + * via a configurable request parameter (default parameter name: "locale"). * * @author Juergen Hoeller * @since 20.06.2003 diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/SessionLocaleResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/SessionLocaleResolver.java index 8b3a602f1d..1aa94df609 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/SessionLocaleResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/i18n/SessionLocaleResolver.java @@ -26,9 +26,10 @@ import org.springframework.context.i18n.TimeZoneAwareLocaleContext; import org.springframework.web.util.WebUtils; /** - * Implementation of LocaleResolver that uses a locale attribute in the user's - * session in case of a custom setting, with a fallback to the specified default - * locale or the request's accept-header locale. + * {@link org.springframework.web.servlet.LocaleResolver} implementation that + * uses a locale attribute in the user's session in case of a custom setting, + * with a fallback to the specified default locale or the request's + * accept-header locale. * *

This is most appropriate if the application needs user sessions anyway, * that is, when the HttpSession does not have to be created for the locale. diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/theme/FixedThemeResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/theme/FixedThemeResolver.java index c02bc45aa5..031950c2aa 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/theme/FixedThemeResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/theme/FixedThemeResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** - * Implementation of ThemeResolver that simply uses a fixed theme. - * The fixed name can be defined via the "defaultThemeName" property. + * {@link org.springframework.web.servlet.ThemeResolver} implementation + * that simply uses a fixed theme. The fixed name can be defined via + * the "defaultThemeName" property; out of the box, it is "theme". * *

Note: Does not support {@code setThemeName}, as the fixed theme * cannot be changed. diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/theme/ThemeChangeInterceptor.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/theme/ThemeChangeInterceptor.java index c3b389c09e..9dad679c87 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/theme/ThemeChangeInterceptor.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/theme/ThemeChangeInterceptor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2008 the original author or authors. + * Copyright 2002-2013 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,7 @@ import org.springframework.web.servlet.support.RequestContextUtils; /** * Interceptor that allows for changing the current theme on every request, - * via a configurable request parameter. + * via a configurable request parameter (default parameter name: "theme"). * * @author Juergen Hoeller * @since 20.06.2003 @@ -63,12 +63,12 @@ public class ThemeChangeInterceptor extends HandlerInterceptorAdapter { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws ServletException { - ThemeResolver themeResolver = RequestContextUtils.getThemeResolver(request); - if (themeResolver == null) { - throw new IllegalStateException("No ThemeResolver found: not in a DispatcherServlet request?"); - } String newTheme = request.getParameter(this.paramName); if (newTheme != null) { + ThemeResolver themeResolver = RequestContextUtils.getThemeResolver(request); + if (themeResolver == null) { + throw new IllegalStateException("No ThemeResolver found: not in a DispatcherServlet request?"); + } themeResolver.setThemeName(request, response, newTheme); } // Proceed in any case.