This is an automated email from the ASF dual-hosted git repository. jamesfredley pushed a commit to branch spring-boot-4 in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 9f5f34df1b5f387d16981ac4501c126c3c3d4a37 Author: James Fredley <[email protected]> AuthorDate: Fri Mar 20 15:38:23 2026 -0400 fix: remove vendored Spring theme files reintroduced by 8.0.x merge These files were removed in #15457 (deprecated in Grails 7.1) but were reintroduced when merging 8.0.x into spring-boot-4. Spring 7 removed theme support from DispatcherServlet and Grails no longer vendors these classes. Assisted-by: Claude Code <[email protected]> --- .../ui/context/HierarchicalThemeSource.java | 47 ----- .../java/org/springframework/ui/context/Theme.java | 49 ----- .../springframework/ui/context/ThemeSource.java | 48 ----- .../ui/context/support/DelegatingThemeSource.java | 66 ------- .../context/support/ResourceBundleThemeSource.java | 204 --------------------- .../ui/context/support/SimpleTheme.java | 62 ------- .../context/support/UiApplicationContextUtils.java | 93 ---------- .../springframework/web/servlet/ThemeResolver.java | 71 ------- .../web/servlet/theme/AbstractThemeResolver.java | 56 ------ .../web/servlet/theme/SessionThemeResolver.java | 70 ------- 10 files changed, 766 deletions(-) diff --git a/grails-spring/src/main/java/org/springframework/ui/context/HierarchicalThemeSource.java b/grails-spring/src/main/java/org/springframework/ui/context/HierarchicalThemeSource.java deleted file mode 100644 index ab52272b0d..0000000000 --- a/grails-spring/src/main/java/org/springframework/ui/context/HierarchicalThemeSource.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2002-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ui.context; - -import org.springframework.lang.Nullable; - -/** - * Sub-interface of ThemeSource to be implemented by objects that - * can resolve theme messages hierarchically. - * - * @author Jean-Pierre Pawlak - * @author Juergen Hoeller - * @deprecated as of 6.0 in favor of using CSS, without direct replacement - */ -@Deprecated(since = "6.0") -public interface HierarchicalThemeSource extends ThemeSource { - - /** - * Set the parent that will be used to try to resolve theme messages - * that this object can't resolve. - * @param parent the parent ThemeSource that will be used to - * resolve messages that this object can't resolve. - * May be {@code null}, in which case no further resolution is possible. - */ - void setParentThemeSource(@Nullable ThemeSource parent); - - /** - * Return the parent of this ThemeSource, or {@code null} if none. - */ - @Nullable - ThemeSource getParentThemeSource(); - -} diff --git a/grails-spring/src/main/java/org/springframework/ui/context/Theme.java b/grails-spring/src/main/java/org/springframework/ui/context/Theme.java deleted file mode 100644 index 2b07910414..0000000000 --- a/grails-spring/src/main/java/org/springframework/ui/context/Theme.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2002-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ui.context; - -import org.springframework.context.MessageSource; - -/** - * A Theme can resolve theme-specific messages, codes, file paths, etc. - * (e.g. CSS and image files in a web environment). - * The exposed {@link org.springframework.context.MessageSource} supports - * theme-specific parameterization and internationalization. - * - * @author Juergen Hoeller - * @since 17.06.2003 - * @see ThemeSource - * @see org.springframework.web.servlet.ThemeResolver - * @deprecated as of 6.0 in favor of using CSS, without direct replacement - */ -@Deprecated(since = "6.0") -public interface Theme { - - /** - * Return the name of the theme. - * @return the name of the theme (never {@code null}) - */ - String getName(); - - /** - * Return the specific MessageSource that resolves messages - * with respect to this theme. - * @return the theme-specific MessageSource (never {@code null}) - */ - MessageSource getMessageSource(); - -} diff --git a/grails-spring/src/main/java/org/springframework/ui/context/ThemeSource.java b/grails-spring/src/main/java/org/springframework/ui/context/ThemeSource.java deleted file mode 100644 index e5374da4a1..0000000000 --- a/grails-spring/src/main/java/org/springframework/ui/context/ThemeSource.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2002-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ui.context; - -import org.springframework.lang.Nullable; - -/** - * Interface to be implemented by objects that can resolve {@link Theme Themes}. - * This enables parameterization and internationalization of messages - * for a given 'theme'. - * - * @author Jean-Pierre Pawlak - * @author Juergen Hoeller - * @see Theme - * @deprecated as of 6.0 in favor of using CSS, without direct replacement - */ -@Deprecated(since = "6.0") -public interface ThemeSource { - - /** - * Return the Theme instance for the given theme name. - * <p>The returned Theme will resolve theme-specific messages, codes, - * file paths, etc (e.g. CSS and image files in a web environment). - * @param themeName the name of the theme - * @return the corresponding Theme, or {@code null} if none defined. - * Note that, by convention, a ThemeSource should at least be able to - * return a default Theme for the default theme name "theme" but may also - * return default Themes for other theme names. - * @see org.springframework.web.servlet.theme.AbstractThemeResolver#ORIGINAL_DEFAULT_THEME_NAME - */ - @Nullable - Theme getTheme(String themeName); - -} diff --git a/grails-spring/src/main/java/org/springframework/ui/context/support/DelegatingThemeSource.java b/grails-spring/src/main/java/org/springframework/ui/context/support/DelegatingThemeSource.java deleted file mode 100644 index 9e79100a53..0000000000 --- a/grails-spring/src/main/java/org/springframework/ui/context/support/DelegatingThemeSource.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2002-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ui.context.support; - -import org.springframework.lang.Nullable; -import org.springframework.ui.context.HierarchicalThemeSource; -import org.springframework.ui.context.Theme; -import org.springframework.ui.context.ThemeSource; - -/** - * Empty ThemeSource that delegates all calls to the parent ThemeSource. - * If no parent is available, it simply won't resolve any theme. - * - * <p>Used as placeholder by UiApplicationContextUtils, if a context doesn't - * define its own ThemeSource. Not intended for direct use in applications. - * - * @author Juergen Hoeller - * @since 1.2.4 - * @see UiApplicationContextUtils - * @deprecated as of 6.0 in favor of using CSS, without direct replacement - */ -@Deprecated(since = "6.0") -public class DelegatingThemeSource implements HierarchicalThemeSource { - - @Nullable - private ThemeSource parentThemeSource; - - - @Override - public void setParentThemeSource(@Nullable ThemeSource parentThemeSource) { - this.parentThemeSource = parentThemeSource; - } - - @Override - @Nullable - public ThemeSource getParentThemeSource() { - return this.parentThemeSource; - } - - - @Override - @Nullable - public Theme getTheme(String themeName) { - if (this.parentThemeSource != null) { - return this.parentThemeSource.getTheme(themeName); - } - else { - return null; - } - } - -} diff --git a/grails-spring/src/main/java/org/springframework/ui/context/support/ResourceBundleThemeSource.java b/grails-spring/src/main/java/org/springframework/ui/context/support/ResourceBundleThemeSource.java deleted file mode 100644 index 2e858a355c..0000000000 --- a/grails-spring/src/main/java/org/springframework/ui/context/support/ResourceBundleThemeSource.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright 2002-2023 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ui.context.support; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.factory.BeanClassLoaderAware; -import org.springframework.context.HierarchicalMessageSource; -import org.springframework.context.MessageSource; -import org.springframework.context.support.ResourceBundleMessageSource; -import org.springframework.lang.Nullable; -import org.springframework.ui.context.HierarchicalThemeSource; -import org.springframework.ui.context.Theme; -import org.springframework.ui.context.ThemeSource; - -/** - * {@link ThemeSource} implementation that looks up an individual - * {@link java.util.ResourceBundle} per theme. The theme name gets - * interpreted as ResourceBundle basename, supporting a common - * basename prefix for all themes. - * - * @author Jean-Pierre Pawlak - * @author Juergen Hoeller - * @see #setBasenamePrefix - * @see java.util.ResourceBundle - * @see org.springframework.context.support.ResourceBundleMessageSource - * @deprecated as of 6.0 in favor of using CSS, without direct replacement - */ -@Deprecated(since = "6.0") -public class ResourceBundleThemeSource implements HierarchicalThemeSource, BeanClassLoaderAware { - - protected final Log logger = LogFactory.getLog(getClass()); - - @Nullable - private ThemeSource parentThemeSource; - - private String basenamePrefix = ""; - - @Nullable - private String defaultEncoding; - - @Nullable - private Boolean fallbackToSystemLocale; - - @Nullable - private ClassLoader beanClassLoader; - - /** Map from theme name to Theme instance. */ - private final Map<String, Theme> themeCache = new ConcurrentHashMap<>(); - - - @Override - public void setParentThemeSource(@Nullable ThemeSource parent) { - this.parentThemeSource = parent; - - // Update existing Theme objects. - // Usually there shouldn't be any at the time of this call. - synchronized (this.themeCache) { - for (Theme theme : this.themeCache.values()) { - initParent(theme); - } - } - } - - @Override - @Nullable - public ThemeSource getParentThemeSource() { - return this.parentThemeSource; - } - - /** - * Set the prefix that gets applied to the ResourceBundle basenames, - * i.e. the theme names. - * E.g.: basenamePrefix="test.", themeName="theme" → basename="test.theme". - * <p>Note that ResourceBundle names are effectively classpath locations: As a - * consequence, the JDK's standard ResourceBundle treats dots as package separators. - * This means that "test.theme" is effectively equivalent to "test/theme", - * just like it is for programmatic {@code java.util.ResourceBundle} usage. - * @see java.util.ResourceBundle#getBundle(String) - */ - public void setBasenamePrefix(@Nullable String basenamePrefix) { - this.basenamePrefix = (basenamePrefix != null ? basenamePrefix : ""); - } - - /** - * Set the default charset to use for parsing resource bundle files. - * <p>{@link ResourceBundleMessageSource}'s default is the - * {@code java.util.ResourceBundle} default encoding: ISO-8859-1. - * @since 4.2 - * @see ResourceBundleMessageSource#setDefaultEncoding - */ - public void setDefaultEncoding(@Nullable String defaultEncoding) { - this.defaultEncoding = defaultEncoding; - } - - /** - * Set whether to fall back to the system Locale if no files for a - * specific Locale have been found. - * <p>{@link ResourceBundleMessageSource}'s default is "true". - * @since 4.2 - * @see ResourceBundleMessageSource#setFallbackToSystemLocale - */ - public void setFallbackToSystemLocale(boolean fallbackToSystemLocale) { - this.fallbackToSystemLocale = fallbackToSystemLocale; - } - - @Override - public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader) { - this.beanClassLoader = beanClassLoader; - } - - - /** - * This implementation returns a SimpleTheme instance, holding a - * ResourceBundle-based MessageSource whose basename corresponds to - * the given theme name (prefixed by the configured "basenamePrefix"). - * <p>SimpleTheme instances are cached per theme name. Use a reloadable - * MessageSource if themes should reflect changes to the underlying files. - * @see #setBasenamePrefix - * @see #createMessageSource - */ - @Override - @Nullable - public Theme getTheme(String themeName) { - Theme theme = this.themeCache.get(themeName); - if (theme == null) { - synchronized (this.themeCache) { - theme = this.themeCache.get(themeName); - if (theme == null) { - String basename = this.basenamePrefix + themeName; - MessageSource messageSource = createMessageSource(basename); - theme = new SimpleTheme(themeName, messageSource); - initParent(theme); - this.themeCache.put(themeName, theme); - if (logger.isDebugEnabled()) { - logger.debug("Theme created: name '" + themeName + "', basename [" + basename + "]"); - } - } - } - } - return theme; - } - - /** - * Create a MessageSource for the given basename, - * to be used as MessageSource for the corresponding theme. - * <p>Default implementation creates a ResourceBundleMessageSource. - * for the given basename. A subclass could create a specifically - * configured ReloadableResourceBundleMessageSource, for example. - * @param basename the basename to create a MessageSource for - * @return the MessageSource - * @see org.springframework.context.support.ResourceBundleMessageSource - * @see org.springframework.context.support.ReloadableResourceBundleMessageSource - */ - protected MessageSource createMessageSource(String basename) { - ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); - messageSource.setBasename(basename); - if (this.defaultEncoding != null) { - messageSource.setDefaultEncoding(this.defaultEncoding); - } - if (this.fallbackToSystemLocale != null) { - messageSource.setFallbackToSystemLocale(this.fallbackToSystemLocale); - } - if (this.beanClassLoader != null) { - messageSource.setBeanClassLoader(this.beanClassLoader); - } - return messageSource; - } - - /** - * Initialize the MessageSource of the given theme with the - * one from the corresponding parent of this ThemeSource. - * @param theme the Theme to (re-)initialize - */ - protected void initParent(Theme theme) { - if (theme.getMessageSource() instanceof HierarchicalMessageSource messageSource) { - if (getParentThemeSource() != null && messageSource.getParentMessageSource() == null) { - Theme parentTheme = getParentThemeSource().getTheme(theme.getName()); - if (parentTheme != null) { - messageSource.setParentMessageSource(parentTheme.getMessageSource()); - } - } - } - } - -} diff --git a/grails-spring/src/main/java/org/springframework/ui/context/support/SimpleTheme.java b/grails-spring/src/main/java/org/springframework/ui/context/support/SimpleTheme.java deleted file mode 100644 index fed03d160c..0000000000 --- a/grails-spring/src/main/java/org/springframework/ui/context/support/SimpleTheme.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2002-2022 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ui.context.support; - -import org.springframework.context.MessageSource; -import org.springframework.ui.context.Theme; -import org.springframework.util.Assert; - -/** - * Default {@link Theme} implementation, wrapping a name and an - * underlying {@link org.springframework.context.MessageSource}. - * - * @author Juergen Hoeller - * @since 17.06.2003 - * @deprecated as of 6.0 in favor of using CSS, without direct replacement - */ -@Deprecated(since = "6.0") -public class SimpleTheme implements Theme { - - private final String name; - - private final MessageSource messageSource; - - - /** - * Create a SimpleTheme. - * @param name the name of the theme - * @param messageSource the MessageSource that resolves theme messages - */ - public SimpleTheme(String name, MessageSource messageSource) { - Assert.notNull(name, "Name must not be null"); - Assert.notNull(messageSource, "MessageSource must not be null"); - this.name = name; - this.messageSource = messageSource; - } - - - @Override - public final String getName() { - return this.name; - } - - @Override - public final MessageSource getMessageSource() { - return this.messageSource; - } - -} diff --git a/grails-spring/src/main/java/org/springframework/ui/context/support/UiApplicationContextUtils.java b/grails-spring/src/main/java/org/springframework/ui/context/support/UiApplicationContextUtils.java deleted file mode 100644 index 879ed4690e..0000000000 --- a/grails-spring/src/main/java/org/springframework/ui/context/support/UiApplicationContextUtils.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2002-2023 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.ui.context.support; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.context.ApplicationContext; -import org.springframework.ui.context.HierarchicalThemeSource; -import org.springframework.ui.context.ThemeSource; - -/** - * Utility class for UI application context implementations. - * Provides support for a special bean named "themeSource", - * of type {@link org.springframework.ui.context.ThemeSource}. - * - * @author Jean-Pierre Pawlak - * @author Juergen Hoeller - * @since 17.06.2003 - * @deprecated as of 6.0 in favor of using CSS, without direct replacement - */ -@Deprecated(since = "6.0") -public abstract class UiApplicationContextUtils { - - /** - * Name of the ThemeSource bean in the factory. - * If none is supplied, theme resolution is delegated to the parent. - * @see org.springframework.ui.context.ThemeSource - */ - public static final String THEME_SOURCE_BEAN_NAME = "themeSource"; - - - private static final Log logger = LogFactory.getLog(UiApplicationContextUtils.class); - - - /** - * Initialize the ThemeSource for the given application context, - * autodetecting a bean with the name "themeSource". If no such - * bean is found, a default (empty) ThemeSource will be used. - * @param context current application context - * @return the initialized theme source (will never be {@code null}) - * @see #THEME_SOURCE_BEAN_NAME - */ - public static ThemeSource initThemeSource(ApplicationContext context) { - if (context.containsLocalBean(THEME_SOURCE_BEAN_NAME)) { - ThemeSource themeSource = context.getBean(THEME_SOURCE_BEAN_NAME, ThemeSource.class); - // Make ThemeSource aware of parent ThemeSource. - if (context.getParent() instanceof ThemeSource pts && themeSource instanceof HierarchicalThemeSource hts) { - if (hts.getParentThemeSource() == null) { - // Only set parent context as parent ThemeSource if no parent ThemeSource - // registered already. - hts.setParentThemeSource(pts); - } - } - if (logger.isDebugEnabled()) { - logger.debug("Using ThemeSource [" + themeSource + "]"); - } - return themeSource; - } - else { - // Use default ThemeSource to be able to accept getTheme calls, either - // delegating to parent context's default or to local ResourceBundleThemeSource. - HierarchicalThemeSource themeSource = null; - if (context.getParent() instanceof ThemeSource pts) { - themeSource = new DelegatingThemeSource(); - themeSource.setParentThemeSource(pts); - } - else { - themeSource = new ResourceBundleThemeSource(); - } - if (logger.isDebugEnabled()) { - logger.debug("Unable to locate ThemeSource with name '" + THEME_SOURCE_BEAN_NAME + - "': using default [" + themeSource + "]"); - } - return themeSource; - } - } - -} diff --git a/grails-spring/src/main/java/org/springframework/web/servlet/ThemeResolver.java b/grails-spring/src/main/java/org/springframework/web/servlet/ThemeResolver.java deleted file mode 100644 index bb116d2f4e..0000000000 --- a/grails-spring/src/main/java/org/springframework/web/servlet/ThemeResolver.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2002-2017 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.web.servlet; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -import org.springframework.lang.Nullable; - -/** - * Interface for web-based theme resolution strategies that allows for - * both theme resolution via the request and theme modification via - * request and response. - * - * <p>This interface allows for implementations based on session, - * cookies, etc. The default implementation is - * {@link org.springframework.web.servlet.theme.FixedThemeResolver}, - * simply using a configured default theme. - * - * <p>Note that this resolver is only responsible for determining the - * current theme name. The Theme instance for the resolved theme name - * gets looked up by DispatcherServlet via the respective ThemeSource, - * i.e. the current WebApplicationContext. - * - * <p>Use {@link org.springframework.web.servlet.support.RequestContext#getTheme()} - * to retrieve the current theme in controllers or views, independent - * of the actual resolution strategy. - * - * @author Jean-Pierre Pawlak - * @author Juergen Hoeller - * @since 17.06.2003 - * @see org.springframework.ui.context.Theme - * @see org.springframework.ui.context.ThemeSource - * @deprecated as of 6.0 in favor of using CSS, without direct replacement - */ -@Deprecated(since = "6.0") -public interface ThemeResolver { - - /** - * Resolve the current theme name via the given request. - * Should return a default theme as fallback in any case. - * @param request the request to be used for resolution - * @return the current theme name - */ - String resolveThemeName(HttpServletRequest request); - - /** - * Set the current theme name to the given one. - * @param request the request to be used for theme name modification - * @param response the response to be used for theme name modification - * @param themeName the new theme name ({@code null} or empty to reset it) - * @throws UnsupportedOperationException if the ThemeResolver implementation - * does not support dynamic changing of the theme - */ - void setThemeName(HttpServletRequest request, @Nullable HttpServletResponse response, @Nullable String themeName); - -} diff --git a/grails-spring/src/main/java/org/springframework/web/servlet/theme/AbstractThemeResolver.java b/grails-spring/src/main/java/org/springframework/web/servlet/theme/AbstractThemeResolver.java deleted file mode 100644 index 4155455b18..0000000000 --- a/grails-spring/src/main/java/org/springframework/web/servlet/theme/AbstractThemeResolver.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2002-2007 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.web.servlet.theme; - -import org.springframework.web.servlet.ThemeResolver; - -/** - * Abstract base class for {@link ThemeResolver} implementations. - * Provides support for a default theme name. - * - * @author Juergen Hoeller - * @author Jean-Pierre Pawlak - * @since 17.06.2003 - * @deprecated as of 6.0 in favor of using CSS, without direct replacement - */ -@Deprecated(since = "6.0") -public abstract class AbstractThemeResolver implements ThemeResolver { - - /** - * Out-of-the-box value for the default theme name: "theme". - */ - public static final String ORIGINAL_DEFAULT_THEME_NAME = "theme"; - - private String defaultThemeName = ORIGINAL_DEFAULT_THEME_NAME; - - - /** - * Set the name of the default theme. - * Out-of-the-box value is "theme". - */ - public void setDefaultThemeName(String defaultThemeName) { - this.defaultThemeName = defaultThemeName; - } - - /** - * Return the name of the default theme. - */ - public String getDefaultThemeName() { - return this.defaultThemeName; - } - -} diff --git a/grails-spring/src/main/java/org/springframework/web/servlet/theme/SessionThemeResolver.java b/grails-spring/src/main/java/org/springframework/web/servlet/theme/SessionThemeResolver.java deleted file mode 100644 index e31204d926..0000000000 --- a/grails-spring/src/main/java/org/springframework/web/servlet/theme/SessionThemeResolver.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2002-2017 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. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.web.servlet.theme; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -import org.springframework.lang.Nullable; -import org.springframework.util.StringUtils; -import org.springframework.web.util.WebUtils; - -/** - * {@link org.springframework.web.servlet.ThemeResolver} implementation that - * uses a theme attribute in the user's session in case of a custom setting, - * with a fallback to the default theme. This is most appropriate if the - * application needs user sessions anyway. - * - * <p>Custom controllers can override the user's theme by calling - * {@code setThemeName}, e.g. responding to a theme change request. - * - * @author Jean-Pierre Pawlak - * @author Juergen Hoeller - * @since 17.06.2003 - * @see #setThemeName - * @deprecated as of 6.0 in favor of using CSS, without direct replacement - */ -@Deprecated(since = "6.0") -public class SessionThemeResolver extends AbstractThemeResolver { - - /** - * Name of the session attribute that holds the theme name. - * Only used internally by this implementation. - * Use {@code RequestContext(Utils).getTheme()} - * to retrieve the current theme in controllers or views. - * @see org.springframework.web.servlet.support.RequestContext#getTheme - * @see org.springframework.web.servlet.support.RequestContextUtils#getTheme - */ - public static final String THEME_SESSION_ATTRIBUTE_NAME = SessionThemeResolver.class.getName() + ".THEME"; - - - @Override - public String resolveThemeName(HttpServletRequest request) { - String themeName = (String) WebUtils.getSessionAttribute(request, THEME_SESSION_ATTRIBUTE_NAME); - // A specific theme indicated, or do we need to fall back to the default? - return (themeName != null ? themeName : getDefaultThemeName()); - } - - @Override - public void setThemeName( - HttpServletRequest request, @Nullable HttpServletResponse response, @Nullable String themeName) { - - WebUtils.setSessionAttribute(request, THEME_SESSION_ATTRIBUTE_NAME, - (StringUtils.hasText(themeName) ? themeName : null)); - } - -}
