From 907c96b21eb211e7fa79a2f2888ee31b60de2ebe Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Mon, 26 Sep 2022 07:24:19 +0900 Subject: [PATCH] Polish "Deprecate support for theme" changes See gh-29202 --- .../AbstractRefreshableWebApplicationContext.java | 2 +- .../context/support/GenericWebApplicationContext.java | 2 +- .../web/context/support/StaticWebApplicationContext.java | 2 +- .../springframework/web/servlet/DispatcherServlet.java | 7 ++++++- .../web/servlet/support/RequestContext.java | 9 +++++++++ .../config/annotation/InterceptorRegistryTests.java | 1 - 6 files changed, 18 insertions(+), 5 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/context/support/AbstractRefreshableWebApplicationContext.java b/spring-web/src/main/java/org/springframework/web/context/support/AbstractRefreshableWebApplicationContext.java index 5c369ddc10..da82e189b3 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/AbstractRefreshableWebApplicationContext.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/AbstractRefreshableWebApplicationContext.java @@ -57,7 +57,7 @@ import org.springframework.web.context.ServletContextAware; * {@link org.springframework.context.support.AbstractApplicationContext}, * this class detects a bean of type {@link org.springframework.ui.context.ThemeSource} * in the context, under the special bean name "themeSource". - * Theme support is deprecated as of 6.0 + * Theme support is deprecated as of 6.0 with no direct replacement. * *

This is the web context to be subclassed for a different bean definition format. * Such a context implementation can be specified as "contextClass" context-param diff --git a/spring-web/src/main/java/org/springframework/web/context/support/GenericWebApplicationContext.java b/spring-web/src/main/java/org/springframework/web/context/support/GenericWebApplicationContext.java index 9f473ab600..87009a3ca5 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/GenericWebApplicationContext.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/GenericWebApplicationContext.java @@ -52,7 +52,7 @@ import org.springframework.web.context.ServletContextAware; *

In addition to the special beans detected by * {@link org.springframework.context.support.AbstractApplicationContext AbstractApplicationContext}, * this class detects a {@link ThemeSource} bean in the context, with the name "themeSource". - * Theme support is deprecated as of 6.0 + * Theme support is deprecated as of 6.0 with no direct replacement. * *

If you wish to register annotated component classes with a * {@code GenericWebApplicationContext}, you can use an diff --git a/spring-web/src/main/java/org/springframework/web/context/support/StaticWebApplicationContext.java b/spring-web/src/main/java/org/springframework/web/context/support/StaticWebApplicationContext.java index 2e65cc0afe..d20ebf1274 100644 --- a/spring-web/src/main/java/org/springframework/web/context/support/StaticWebApplicationContext.java +++ b/spring-web/src/main/java/org/springframework/web/context/support/StaticWebApplicationContext.java @@ -50,7 +50,7 @@ import org.springframework.web.context.ServletContextAware; * {@link org.springframework.context.support.AbstractApplicationContext}, * this class detects a bean of type {@link org.springframework.ui.context.ThemeSource} * in the context, under the special bean name "themeSource". - * Theme support is deprecated as of 6.0 + * Theme support is deprecated as of 6.0 with no direct replacement. * * @author Rod Johnson * @author Juergen Hoeller diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java index 92f554a3f3..1ea651d3b8 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java @@ -169,7 +169,10 @@ public class DispatcherServlet extends FrameworkServlet { /** Well-known name for the LocaleResolver object in the bean factory for this namespace. */ public static final String LOCALE_RESOLVER_BEAN_NAME = "localeResolver"; - /** Well-known name for the ThemeResolver object in the bean factory for this namespace. */ + /** + * Well-known name for the ThemeResolver object in the bean factory for this namespace. + * @deprecated as of 6.0, with no direct replacement + */ @Deprecated public static final String THEME_RESOLVER_BEAN_NAME = "themeResolver"; @@ -227,6 +230,7 @@ public class DispatcherServlet extends FrameworkServlet { /** * Request attribute to hold the current ThemeResolver, retrievable by views. * @see org.springframework.web.servlet.support.RequestContextUtils#getThemeResolver + * @deprecated as of 6.0, with no direct replacement */ @Deprecated public static final String THEME_RESOLVER_ATTRIBUTE = DispatcherServlet.class.getName() + ".THEME_RESOLVER"; @@ -234,6 +238,7 @@ public class DispatcherServlet extends FrameworkServlet { /** * Request attribute to hold the current ThemeSource, retrievable by views. * @see org.springframework.web.servlet.support.RequestContextUtils#getThemeSource + * @deprecated as of 6.0, with no direct replacement */ @Deprecated public static final String THEME_SOURCE_ATTRIBUTE = DispatcherServlet.class.getName() + ".THEME_SOURCE"; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java index 64934c0d26..4167936b12 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java @@ -409,6 +409,7 @@ public class RequestContext { * Determine the fallback theme for this context. *

The default implementation returns the default theme (with name "theme"). * @return the fallback theme (never {@code null}) + * @deprecated as of 6.0, with no direct replacement */ @Deprecated protected org.springframework.ui.context.Theme getFallbackTheme() { @@ -447,6 +448,7 @@ public class RequestContext { * {@link org.springframework.web.servlet.ThemeResolver ThemeResolver}. * @param themeName the name of the new theme * @see org.springframework.web.servlet.ThemeResolver#setThemeName + * @deprecated as of 6.0, with no direct replacement */ @Deprecated public void changeTheme(String themeName) { @@ -740,6 +742,7 @@ public class RequestContext { * @param code the code of the message * @param defaultMessage the String to return if the lookup fails * @return the message + * @deprecated as of 6.0, with no direct replacement */ @Deprecated public String getThemeMessage(String code, String defaultMessage) { @@ -755,6 +758,7 @@ public class RequestContext { * @param args arguments for the message, or {@code null} if none * @param defaultMessage the String to return if the lookup fails * @return the message + * @deprecated as of 6.0, with no direct replacement */ @Deprecated public String getThemeMessage(String code, @Nullable Object[] args, String defaultMessage) { @@ -770,6 +774,7 @@ public class RequestContext { * @param args arguments for the message as a List, or {@code null} if none * @param defaultMessage the String to return if the lookup fails * @return the message + * @deprecated as of 6.0, with no direct replacement */ @Deprecated public String getThemeMessage(String code, @Nullable List args, String defaultMessage) { @@ -785,6 +790,7 @@ public class RequestContext { * @param code the code of the message * @return the message * @throws org.springframework.context.NoSuchMessageException if not found + * @deprecated as of 6.0, with no direct replacement */ @Deprecated public String getThemeMessage(String code) throws NoSuchMessageException { @@ -799,6 +805,7 @@ public class RequestContext { * @param args arguments for the message, or {@code null} if none * @return the message * @throws org.springframework.context.NoSuchMessageException if not found + * @deprecated as of 6.0, with no direct replacement */ @Deprecated public String getThemeMessage(String code, @Nullable Object[] args) throws NoSuchMessageException { @@ -813,6 +820,7 @@ public class RequestContext { * @param args arguments for the message as a List, or {@code null} if none * @return the message * @throws org.springframework.context.NoSuchMessageException if not found + * @deprecated as of 6.0, with no direct replacement */ @Deprecated public String getThemeMessage(String code, @Nullable List args) throws NoSuchMessageException { @@ -826,6 +834,7 @@ public class RequestContext { * @param resolvable the MessageSourceResolvable * @return the message * @throws org.springframework.context.NoSuchMessageException if not found + * @deprecated as of 6.0, with no direct replacement */ @Deprecated public String getThemeMessage(MessageSourceResolvable resolvable) throws NoSuchMessageException { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/InterceptorRegistryTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/InterceptorRegistryTests.java index e2c23b836b..0f641bfeab 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/InterceptorRegistryTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/InterceptorRegistryTests.java @@ -57,7 +57,6 @@ public class InterceptorRegistryTests { private final HandlerInterceptor interceptor1 = new LocaleChangeInterceptor(); - @Deprecated private final HandlerInterceptor interceptor2 = new ThemeChangeInterceptor(); private TestWebRequestInterceptor webInterceptor1;