Skip to content

Deprecate support for theme #29114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
*
* @author Jean-Pierre Pawlak
* @author Juergen Hoeller
* @deprecated as of 6.0, with no concrete replacement
*/
@Deprecated
public interface HierarchicalThemeSource extends ThemeSource {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
* @since 17.06.2003
* @see ThemeSource
* @see org.springframework.web.servlet.ThemeResolver
* @deprecated as of 6.0, with no direct replacement
*/
@Deprecated
public interface Theme {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
* @author Jean-Pierre Pawlak
* @author Juergen Hoeller
* @see Theme
* @deprecated as of 6.0, with no direct replacement
*/
@Deprecated
public interface ThemeSource {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
* @author Juergen Hoeller
* @since 1.2.4
* @see UiApplicationContextUtils
* @deprecated as of 6.0, with no direct replacement
*/
@Deprecated
public class DelegatingThemeSource implements HierarchicalThemeSource {

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
* @see #setBasenamePrefix
* @see java.util.ResourceBundle
* @see org.springframework.context.support.ResourceBundleMessageSource
* @deprecated as of 6.0, with no direct replacement
*/
@Deprecated
public class ResourceBundleThemeSource implements HierarchicalThemeSource, BeanClassLoaderAware {

protected final Log logger = LogFactory.getLog(getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
*
* @author Juergen Hoeller
* @since 17.06.2003
* @deprecated as of 6.0, with no concrete replacement
*/
@Deprecated
public class SimpleTheme implements Theme {

private final String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
* @author Jean-Pierre Pawlak
* @author Juergen Hoeller
* @since 17.06.2003
* @deprecated as of 6.0, with no direct replacement
*/
@Deprecated
public abstract class UiApplicationContextUtils {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
import org.springframework.web.servlet.resource.ResourceUrlProvider;
import org.springframework.web.servlet.support.SessionFlashMapManager;
import org.springframework.web.servlet.theme.FixedThemeResolver;
import org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.util.UrlPathHelper;
Expand Down Expand Up @@ -394,6 +393,7 @@ protected WebApplicationContext initWebAppContext() {
return wac;
}

@SuppressWarnings("deprecation")
private void registerMvcSingletons(StubWebApplicationContext wac) {
StandaloneConfiguration config = new StandaloneConfiguration();
config.setApplicationContext(wac);
Expand Down Expand Up @@ -432,8 +432,10 @@ private void registerMvcSingletons(StubWebApplicationContext wac) {

wac.addBeans(initViewResolvers(wac));
wac.addBean(DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME, this.localeResolver);
wac.addBean(DispatcherServlet.THEME_RESOLVER_BEAN_NAME, new FixedThemeResolver());
wac.addBean(DispatcherServlet.REQUEST_TO_VIEW_NAME_TRANSLATOR_BEAN_NAME, new DefaultRequestToViewNameTranslator());
wac.addBean(DispatcherServlet.THEME_RESOLVER_BEAN_NAME,
new org.springframework.web.servlet.theme.FixedThemeResolver());
wac.addBean(DispatcherServlet.REQUEST_TO_VIEW_NAME_TRANSLATOR_BEAN_NAME,
new DefaultRequestToViewNameTranslator());

this.flashMapManager = new SessionFlashMapManager();
wac.addBean(DispatcherServlet.FLASH_MAP_MANAGER_BEAN_NAME, this.flashMapManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
* {@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
*
* <p><b>This is the web context to be subclassed for a different bean definition format.</b>
* Such a context implementation can be specified as "contextClass" context-param
Expand All @@ -75,9 +76,9 @@
* @since 1.1.3
* @see #loadBeanDefinitions
* @see org.springframework.web.context.ConfigurableWebApplicationContext#setConfigLocations
* @see org.springframework.ui.context.ThemeSource
* @see XmlWebApplicationContext
*/
@SuppressWarnings("deprecation")
public abstract class AbstractRefreshableWebApplicationContext extends AbstractRefreshableConfigApplicationContext
implements ConfigurableWebApplicationContext, ThemeSource {

Expand All @@ -95,6 +96,7 @@ public abstract class AbstractRefreshableWebApplicationContext extends AbstractR

/** the ThemeSource for this ApplicationContext. */
@Nullable
@Deprecated
private ThemeSource themeSource;


Expand Down Expand Up @@ -197,6 +199,7 @@ protected ResourcePatternResolver getResourcePatternResolver() {
* Initialize the theme capability.
*/
@Override
@Deprecated
protected void onRefresh() {
this.themeSource = UiApplicationContextUtils.initThemeSource(this);
}
Expand All @@ -215,6 +218,7 @@ protected void initPropertySources() {

@Override
@Nullable
@Deprecated
public Theme getTheme(String themeName) {
Assert.state(this.themeSource != null, "No ThemeSource available");
return this.themeSource.getTheme(themeName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
* <p>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
*
* <p>If you wish to register annotated <em>component classes</em> with a
* {@code GenericWebApplicationContext}, you can use an
Expand All @@ -77,13 +78,15 @@
* @author Sam Brannen
* @since 1.2
*/
@SuppressWarnings("deprecation")
public class GenericWebApplicationContext extends GenericApplicationContext
implements ConfigurableWebApplicationContext, ThemeSource {

@Nullable
private ServletContext servletContext;

@Nullable
@Deprecated
private ThemeSource themeSource;


Expand Down Expand Up @@ -195,6 +198,7 @@ protected ResourcePatternResolver getResourcePatternResolver() {
* Initialize the theme capability.
*/
@Override
@Deprecated
protected void onRefresh() {
this.themeSource = UiApplicationContextUtils.initThemeSource(this);
}
Expand All @@ -213,6 +217,7 @@ protected void initPropertySources() {

@Override
@Nullable
@Deprecated
public Theme getTheme(String themeName) {
Assert.state(this.themeSource != null, "No ThemeSource available");
return this.themeSource.getTheme(themeName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@
* {@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
*
* @author Rod Johnson
* @author Juergen Hoeller
* @see org.springframework.ui.context.ThemeSource
*/
@SuppressWarnings("deprecation")
public class StaticWebApplicationContext extends StaticApplicationContext
implements ConfigurableWebApplicationContext, ThemeSource {

Expand All @@ -68,6 +70,7 @@ public class StaticWebApplicationContext extends StaticApplicationContext
private String namespace;

@Nullable
@Deprecated
private ThemeSource themeSource;


Expand Down Expand Up @@ -186,6 +189,7 @@ protected ConfigurableEnvironment createEnvironment() {
* Initialize the theme capability.
*/
@Override
@Deprecated
protected void onRefresh() {
this.themeSource = UiApplicationContextUtils.initThemeSource(this);
}
Expand All @@ -198,6 +202,7 @@ protected void initPropertySources() {

@Override
@Nullable
@Deprecated
public Theme getTheme(String themeName) {
Assert.state(this.themeSource != null, "No ThemeSource available");
return this.themeSource.getTheme(themeName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.springframework.http.server.RequestPath;
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.lang.Nullable;
import org.springframework.ui.context.ThemeSource;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.context.WebApplicationContext;
Expand Down Expand Up @@ -130,6 +129,7 @@
* Implementations for a fixed theme and for cookie and session storage are included.
* The ThemeResolver bean name is "themeResolver"; default is
* {@link org.springframework.web.servlet.theme.FixedThemeResolver}.
* Theme support is deprecated as of 6.0
* </ul>
*
* <p><b>NOTE: The {@code @RequestMapping} annotation will only be processed if a
Expand Down Expand Up @@ -170,6 +170,7 @@ public class DispatcherServlet extends FrameworkServlet {
public static final String LOCALE_RESOLVER_BEAN_NAME = "localeResolver";

/** Well-known name for the ThemeResolver object in the bean factory for this namespace. */
@Deprecated
public static final String THEME_RESOLVER_BEAN_NAME = "themeResolver";

/**
Expand Down Expand Up @@ -227,12 +228,14 @@ public class DispatcherServlet extends FrameworkServlet {
* Request attribute to hold the current ThemeResolver, retrievable by views.
* @see org.springframework.web.servlet.support.RequestContextUtils#getThemeResolver
*/
@Deprecated
public static final String THEME_RESOLVER_ATTRIBUTE = DispatcherServlet.class.getName() + ".THEME_RESOLVER";

/**
* Request attribute to hold the current ThemeSource, retrievable by views.
* @see org.springframework.web.servlet.support.RequestContextUtils#getThemeSource
*/
@Deprecated
public static final String THEME_SOURCE_ATTRIBUTE = DispatcherServlet.class.getName() + ".THEME_SOURCE";

/**
Expand Down Expand Up @@ -311,6 +314,7 @@ public class DispatcherServlet extends FrameworkServlet {

/** ThemeResolver used by this servlet. */
@Nullable
@Deprecated
private ThemeResolver themeResolver;

/** List of HandlerMappings used by this servlet. */
Expand Down Expand Up @@ -557,6 +561,7 @@ else if (logger.isDebugEnabled()) {
* <p>If no bean is defined with the given name in the BeanFactory for this namespace,
* we default to a FixedThemeResolver.
*/
@Deprecated
private void initThemeResolver(ApplicationContext context) {
try {
this.themeResolver = context.getBean(THEME_RESOLVER_BEAN_NAME, ThemeResolver.class);
Expand Down Expand Up @@ -799,8 +804,10 @@ else if (logger.isDebugEnabled()) {
* @see #getWebApplicationContext()
*/
@Nullable
public final ThemeSource getThemeSource() {
return (getWebApplicationContext() instanceof ThemeSource ? (ThemeSource) getWebApplicationContext() : null);
@Deprecated
public final org.springframework.ui.context.ThemeSource getThemeSource() {
return (getWebApplicationContext() instanceof org.springframework.ui.context.ThemeSource ?
(org.springframework.ui.context.ThemeSource) getWebApplicationContext() : null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
* @since 17.06.2003
* @see org.springframework.ui.context.Theme
* @see org.springframework.ui.context.ThemeSource
* @deprecated as of 6.0, with no direct replacement
*/
@Deprecated
public interface ThemeResolver {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter;
import org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter;
import org.springframework.web.servlet.support.SessionFlashMapManager;
import org.springframework.web.servlet.theme.FixedThemeResolver;
import org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator;
import org.springframework.web.util.UrlPathHelper;

Expand Down Expand Up @@ -236,9 +235,10 @@ private static void registerLocaleResolver(ParserContext context, @Nullable Obje
* Registers an {@link FixedThemeResolver} under a well-known name
* unless already registered.
*/
@Deprecated
private static void registerThemeResolver(ParserContext context, @Nullable Object source) {
if (!containsBeanInHierarchy(context, DispatcherServlet.THEME_RESOLVER_BEAN_NAME)) {
RootBeanDefinition beanDef = new RootBeanDefinition(FixedThemeResolver.class);
RootBeanDefinition beanDef = new RootBeanDefinition(org.springframework.web.servlet.theme.FixedThemeResolver.class);
beanDef.setSource(source);
beanDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
context.getRegistry().registerBeanDefinition(DispatcherServlet.THEME_RESOLVER_BEAN_NAME, beanDef);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.RequestToViewNameTranslator;
import org.springframework.web.servlet.ThemeResolver;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.function.support.HandlerFunctionAdapter;
import org.springframework.web.servlet.function.support.RouterFunctionMapping;
Expand All @@ -107,7 +106,6 @@
import org.springframework.web.servlet.resource.ResourceUrlProvider;
import org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor;
import org.springframework.web.servlet.support.SessionFlashMapManager;
import org.springframework.web.servlet.theme.FixedThemeResolver;
import org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.ViewResolverComposite;
Expand Down Expand Up @@ -1168,8 +1166,9 @@ public LocaleResolver localeResolver() {
}

@Bean
public ThemeResolver themeResolver() {
return new FixedThemeResolver();
@Deprecated
public org.springframework.web.servlet.ThemeResolver themeResolver() {
return new org.springframework.web.servlet.theme.FixedThemeResolver();
}

@Bean
Expand Down
Loading