Deprecate support for theme

As seen in gh-28868, the support for Themes is now deprecated as of
Spring Framework 6.0 and will be removed in a future release.

Closes gh-29114
This commit is contained in:
Nheyll
2022-09-09 09:12:52 +02:00
committed by Brian Clozel
parent 5e1b5af0e0
commit 058109315d
33 changed files with 120 additions and 50 deletions

View File

@@ -57,6 +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
*
* <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
@@ -75,9 +76,9 @@ import org.springframework.web.context.ServletContextAware;
* @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 {
@@ -95,6 +96,7 @@ public abstract class AbstractRefreshableWebApplicationContext extends AbstractR
/** the ThemeSource for this ApplicationContext. */
@Nullable
@Deprecated
private ThemeSource themeSource;
@@ -197,6 +199,7 @@ public abstract class AbstractRefreshableWebApplicationContext extends AbstractR
* Initialize the theme capability.
*/
@Override
@Deprecated
protected void onRefresh() {
this.themeSource = UiApplicationContextUtils.initThemeSource(this);
}
@@ -215,6 +218,7 @@ public abstract class AbstractRefreshableWebApplicationContext extends AbstractR
@Override
@Nullable
@Deprecated
public Theme getTheme(String themeName) {
Assert.state(this.themeSource != null, "No ThemeSource available");
return this.themeSource.getTheme(themeName);

View File

@@ -52,6 +52,7 @@ import org.springframework.web.context.ServletContextAware;
* <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
@@ -77,6 +78,7 @@ import org.springframework.web.context.ServletContextAware;
* @author Sam Brannen
* @since 1.2
*/
@SuppressWarnings("deprecation")
public class GenericWebApplicationContext extends GenericApplicationContext
implements ConfigurableWebApplicationContext, ThemeSource {
@@ -84,6 +86,7 @@ public class GenericWebApplicationContext extends GenericApplicationContext
private ServletContext servletContext;
@Nullable
@Deprecated
private ThemeSource themeSource;
@@ -195,6 +198,7 @@ public class GenericWebApplicationContext extends GenericApplicationContext
* Initialize the theme capability.
*/
@Override
@Deprecated
protected void onRefresh() {
this.themeSource = UiApplicationContextUtils.initThemeSource(this);
}
@@ -213,6 +217,7 @@ public class GenericWebApplicationContext extends GenericApplicationContext
@Override
@Nullable
@Deprecated
public Theme getTheme(String themeName) {
Assert.state(this.themeSource != null, "No ThemeSource available");
return this.themeSource.getTheme(themeName);

View File

@@ -50,11 +50,13 @@ 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
*
* @author Rod Johnson
* @author Juergen Hoeller
* @see org.springframework.ui.context.ThemeSource
*/
@SuppressWarnings("deprecation")
public class StaticWebApplicationContext extends StaticApplicationContext
implements ConfigurableWebApplicationContext, ThemeSource {
@@ -68,6 +70,7 @@ public class StaticWebApplicationContext extends StaticApplicationContext
private String namespace;
@Nullable
@Deprecated
private ThemeSource themeSource;
@@ -186,6 +189,7 @@ public class StaticWebApplicationContext extends StaticApplicationContext
* Initialize the theme capability.
*/
@Override
@Deprecated
protected void onRefresh() {
this.themeSource = UiApplicationContextUtils.initThemeSource(this);
}
@@ -198,6 +202,7 @@ public class StaticWebApplicationContext extends StaticApplicationContext
@Override
@Nullable
@Deprecated
public Theme getTheme(String themeName) {
Assert.state(this.themeSource != null, "No ThemeSource available");
return this.themeSource.getTheme(themeName);