Remove deprecated ThemeResolver support

See gh-33809
This commit is contained in:
rstoyanchev
2025-01-14 15:26:44 +00:00
parent 9ddbf800b9
commit 9f77d5ff1f
54 changed files with 39 additions and 2163 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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.
@@ -25,9 +25,6 @@ import org.springframework.context.support.AbstractRefreshableConfigApplicationC
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.ui.context.Theme;
import org.springframework.ui.context.ThemeSource;
import org.springframework.ui.context.support.UiApplicationContextUtils;
import org.springframework.util.Assert;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.context.ConfigurableWebEnvironment;
@@ -53,12 +50,6 @@ import org.springframework.web.context.ServletContextAware;
* can be accessed via "file:" URLs, as implemented by
* {@link org.springframework.core.io.DefaultResourceLoader}.
*
* <p>In addition to the special beans detected by
* {@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 with no direct replacement.
*
* <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
* for {@link org.springframework.web.context.ContextLoader} or as "contextClass"
@@ -80,7 +71,7 @@ import org.springframework.web.context.ServletContextAware;
*/
@SuppressWarnings("deprecation")
public abstract class AbstractRefreshableWebApplicationContext extends AbstractRefreshableConfigApplicationContext
implements ConfigurableWebApplicationContext, ThemeSource {
implements ConfigurableWebApplicationContext {
/** Servlet context that this context runs in. */
private @Nullable ServletContext servletContext;
@@ -91,9 +82,6 @@ public abstract class AbstractRefreshableWebApplicationContext extends AbstractR
/** Namespace of this context, or {@code null} if root. */
private @Nullable String namespace;
/** the ThemeSource for this ApplicationContext. */
private @Nullable ThemeSource themeSource;
public AbstractRefreshableWebApplicationContext() {
setDisplayName("Root WebApplicationContext");
@@ -187,14 +175,6 @@ public abstract class AbstractRefreshableWebApplicationContext extends AbstractR
return new ServletContextResourcePatternResolver(this);
}
/**
* Initialize the theme capability.
*/
@Override
protected void onRefresh() {
this.themeSource = UiApplicationContextUtils.initThemeSource(this);
}
/**
* {@inheritDoc}
* <p>Replace {@code Servlet}-related property sources.
@@ -207,11 +187,4 @@ public abstract class AbstractRefreshableWebApplicationContext extends AbstractR
}
}
@Override
@Deprecated
public @Nullable Theme getTheme(String themeName) {
Assert.state(this.themeSource != null, "No ThemeSource available");
return this.themeSource.getTheme(themeName);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 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,9 +26,6 @@ import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.ui.context.Theme;
import org.springframework.ui.context.ThemeSource;
import org.springframework.ui.context.support.UiApplicationContextUtils;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
@@ -49,11 +46,6 @@ import org.springframework.web.context.ServletContextAware;
* the web app root &mdash; can be accessed via {@code file:} URLs, as implemented
* by {@code AbstractApplicationContext}.
*
* <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 with no direct replacement.
*
* <p>If you wish to register annotated <em>component classes</em> with a
* {@code GenericWebApplicationContext}, you can use an
* {@link org.springframework.context.annotation.AnnotatedBeanDefinitionReader
@@ -78,14 +70,11 @@ import org.springframework.web.context.ServletContextAware;
* @author Sam Brannen
* @since 1.2
*/
@SuppressWarnings("deprecation")
public class GenericWebApplicationContext extends GenericApplicationContext
implements ConfigurableWebApplicationContext, ThemeSource {
implements ConfigurableWebApplicationContext {
private @Nullable ServletContext servletContext;
private @Nullable ThemeSource themeSource;
/**
* Create a new {@code GenericWebApplicationContext}.
@@ -189,14 +178,6 @@ public class GenericWebApplicationContext extends GenericApplicationContext
return new ServletContextResourcePatternResolver(this);
}
/**
* Initialize the theme capability.
*/
@Override
protected void onRefresh() {
this.themeSource = UiApplicationContextUtils.initThemeSource(this);
}
/**
* {@inheritDoc}
* <p>Replace {@code Servlet}-related property sources.
@@ -209,13 +190,6 @@ public class GenericWebApplicationContext extends GenericApplicationContext
}
}
@Override
@Deprecated
public @Nullable Theme getTheme(String themeName) {
Assert.state(this.themeSource != null, "No ThemeSource available");
return this.themeSource.getTheme(themeName);
}
// ---------------------------------------------------------------------
// Pseudo-implementation of ConfigurableWebApplicationContext

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2025 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.
@@ -25,9 +25,6 @@ import org.springframework.context.support.StaticApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.ui.context.Theme;
import org.springframework.ui.context.ThemeSource;
import org.springframework.ui.context.support.UiApplicationContextUtils;
import org.springframework.util.Assert;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.context.ServletConfigAware;
@@ -46,19 +43,11 @@ import org.springframework.web.context.ServletContextAware;
* can be accessed via "file:" URLs, as implemented by
* {@link org.springframework.core.io.DefaultResourceLoader}.
*
* <p>In addition to the special beans detected by
* {@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 with no direct replacement.
*
* @author Rod Johnson
* @author Juergen Hoeller
* @see org.springframework.ui.context.ThemeSource
*/
@SuppressWarnings("deprecation")
public class StaticWebApplicationContext extends StaticApplicationContext
implements ConfigurableWebApplicationContext, ThemeSource {
implements ConfigurableWebApplicationContext {
private @Nullable ServletContext servletContext;
@@ -66,8 +55,6 @@ public class StaticWebApplicationContext extends StaticApplicationContext
private @Nullable String namespace;
private @Nullable ThemeSource themeSource;
public StaticWebApplicationContext() {
setDisplayName("Root WebApplicationContext");
@@ -177,25 +164,10 @@ public class StaticWebApplicationContext extends StaticApplicationContext
return new StandardServletEnvironment();
}
/**
* Initialize the theme capability.
*/
@Override
protected void onRefresh() {
this.themeSource = UiApplicationContextUtils.initThemeSource(this);
}
@Override
protected void initPropertySources() {
WebApplicationContextUtils.initServletPropertySources(getEnvironment().getPropertySources(),
this.servletContext, this.servletConfig);
}
@Override
@Deprecated
public @Nullable Theme getTheme(String themeName) {
Assert.state(this.themeSource != null, "No ThemeSource available");
return this.themeSource.getTheme(themeName);
}
}