Skip to content

Commit b8c51a2

Browse files
committed
Additional theme removal updates
See gh-33809
1 parent 9cfece0 commit b8c51a2

File tree

21 files changed

+20
-133
lines changed

21 files changed

+20
-133
lines changed

framework-docs/modules/ROOT/pages/core/beans/basics.adoc

+3-4
Original file line numberDiff line numberDiff line change
@@ -206,18 +206,17 @@ another file or files. The following example shows how to do so:
206206
<beans>
207207
<import resource="services.xml"/>
208208
<import resource="resources/messageSource.xml"/>
209-
<import resource="/resources/themeSource.xml"/>
210209
211210
<bean id="bean1" class="..."/>
212211
<bean id="bean2" class="..."/>
213212
</beans>
214213
----
215214

216-
In the preceding example, external bean definitions are loaded from three files:
217-
`services.xml`, `messageSource.xml`, and `themeSource.xml`. All location paths are
215+
In the preceding example, external bean definitions are loaded from the files
216+
`services.xml` and `messageSource.xml`. All location paths are
218217
relative to the definition file doing the importing, so `services.xml` must be in the
219218
same directory or classpath location as the file doing the importing, while
220-
`messageSource.xml` and `themeSource.xml` must be in a `resources` location below the
219+
`messageSource.xml` must be in a `resources` location below the
221220
location of the importing file. As you can see, a leading slash is ignored. However, given
222221
that these paths are relative, it is better form not to use the slash at all. The
223222
contents of the files being imported, including the top level `<beans/>` element, must

framework-docs/modules/ROOT/pages/testing/testcontext-framework/web-scoped-beans.adoc

+1-3
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ Kotlin::
9696
The following code snippet is similar to the one we saw earlier for a request-scoped
9797
bean. However, this time, the `userService` bean has a dependency on a session-scoped
9898
`userPreferences` bean. Note that the `UserPreferences` bean is instantiated by using a
99-
SpEL expression that retrieves the theme from the current HTTP session. In our test, we
100-
need to configure a theme in the mock session managed by the TestContext framework. The
101-
following example shows how to do so:
99+
SpEL expression that retrieves an attribute from the current HTTP session.
102100

103101
.Session-scoped bean configuration
104102
[source,xml,indent=0,subs="verbatim,quotes"]

framework-docs/modules/ROOT/pages/web/webmvc/mvc-servlet/sequence.adoc

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ The `DispatcherServlet` processes requests as follows:
1111
* The locale resolver is bound to the request to let elements in the process
1212
resolve the locale to use when processing the request (rendering the view, preparing
1313
data, and so on). If you do not need locale resolving, you do not need the locale resolver.
14-
* The theme resolver is bound to the request to let elements such as views determine
15-
which theme to use. If you do not use themes, you can ignore it.
1614
* If you specify a multipart file resolver, the request is inspected for multiparts. If
1715
multiparts are found, the request is wrapped in a `MultipartHttpServletRequest` for
1816
further processing by other elements in the process. See xref:web/webmvc/mvc-servlet/multipart.adoc[Multipart Resolver] for further

framework-docs/src/main/kotlin/org/springframework/docs/web/webmvc/mvcconfig/mvcconfiginterceptors/WebConfiguration.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,21 @@
1414
* limitations under the License.
1515
*/
1616

17-
@file:Suppress("DEPRECATION")
1817
package org.springframework.docs.web.webmvc.mvcconfig.mvcconfiginterceptors
1918

2019
import org.springframework.context.annotation.Configuration
2120
import org.springframework.web.servlet.config.annotation.InterceptorRegistry
2221
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
22+
import org.springframework.web.servlet.handler.UserRoleAuthorizationInterceptor
2323
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor
24-
import org.springframework.web.servlet.theme.ThemeChangeInterceptor
2524

2625
// tag::snippet[]
2726
@Configuration
2827
class WebConfiguration : WebMvcConfigurer {
2928

3029
override fun addInterceptors(registry: InterceptorRegistry) {
3130
registry.addInterceptor(LocaleChangeInterceptor())
32-
registry.addInterceptor(ThemeChangeInterceptor()).addPathPatterns("/**").excludePathPatterns("/admin/**")
31+
registry.addInterceptor(UserRoleAuthorizationInterceptor()).addPathPatterns("/**").excludePathPatterns("/admin/**")
3332
}
3433
}
3534
// end::snippet[]

framework-docs/src/main/resources/org/springframework/docs/web/webmvc/mvcconfig/mvcconfiginterceptors/WebConfiguration.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
<mvc:interceptor>
1515
<mvc:mapping path="/**"/>
1616
<mvc:exclude-mapping path="/admin/**"/>
17-
<bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor"/>
17+
<bean class="org.springframework.web.servlet.handler.UserRoleAuthorizationInterceptor">
18+
<property name="authorizedRoles" value="ROLE_USER"/>
19+
</bean>
1820
</mvc:interceptor>
1921
</mvc:interceptors>
2022
<!-- end::snippet[] -->

spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerInterceptor.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@
3131
* <p>A HandlerInterceptor gets called before the appropriate HandlerAdapter
3232
* triggers the execution of the handler itself. This mechanism can be used
3333
* for a large field of preprocessing aspects, or common handler behavior
34-
* like locale or theme changes. Its main purpose is to allow for factoring
34+
* like locale changes. Its main purpose is to allow for factoring
3535
* out repetitive handler code.
3636
*
3737
* <p>In an asynchronous processing scenario, the handler may be executed in a
@@ -75,7 +75,6 @@
7575
* @see org.springframework.web.servlet.handler.AbstractHandlerMapping#setInterceptors
7676
* @see org.springframework.web.servlet.handler.UserRoleAuthorizationInterceptor
7777
* @see org.springframework.web.servlet.i18n.LocaleChangeInterceptor
78-
* @see org.springframework.web.servlet.theme.ThemeChangeInterceptor
7978
* @see jakarta.servlet.Filter
8079
*/
8180
public interface HandlerInterceptor {

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/Controller.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@
3838
* <h3><a name="workflow">Workflow</a></h3>
3939
*
4040
* <p>After a {@code DispatcherServlet} has received a request and has
41-
* done its work to resolve locales, themes, and suchlike, it then tries
41+
* done its work to resolve locales, and suchlike, it then tries
4242
* to resolve a Controller, using a
4343
* {@link org.springframework.web.servlet.HandlerMapping HandlerMapping}.
4444
* When a Controller has been found to handle the request, the

spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContext.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
/**
5656
* Context holder for request-specific state, like current web application context, current locale,
57-
* current theme, and potential binding errors. Provides easy access to localized messages and
57+
* and potential binding errors. Provides easy access to localized messages and
5858
* Errors instances.
5959
*
6060
* <p>Suitable for exposition to views, and usage within JSP's "useBean" tag, JSP scriptlets, JSTL EL,

spring-webmvc/src/main/java/org/springframework/web/servlet/support/RequestContextUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
* set by the {@link org.springframework.web.servlet.DispatcherServlet}.
4747
*
4848
* <p>Supports lookup of current WebApplicationContext, LocaleResolver,
49-
* Locale, ThemeResolver, Theme, and MultipartResolver.
49+
* Locale, and MultipartResolver.
5050
*
5151
* @author Juergen Hoeller
5252
* @author Rossen Stoyanchev

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/ArgumentTag.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
/**
2424
* The {@code <argument>} tag is based on the JSTL {@code fmt:param} tag.
25-
* The purpose is to support arguments inside the message and theme tags.
25+
* The purpose is to support arguments inside the message tags.
2626
*
2727
* <p>This tag must be nested under an argument aware tag.
2828
*

spring-webmvc/src/main/java/org/springframework/web/servlet/tags/RequestContextAwareTag.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,8 +34,7 @@
3434
* <p>The {@code RequestContext} instance provides easy access
3535
* to current state like the
3636
* {@link org.springframework.web.context.WebApplicationContext},
37-
* the {@link java.util.Locale}, the
38-
* {@link org.springframework.ui.context.Theme}, etc.
37+
* the {@link java.util.Locale}, etc.
3938
*
4039
* <p>Mainly intended for
4140
* {@link org.springframework.web.servlet.DispatcherServlet} requests;

spring-webmvc/src/main/resources/META-INF/spring.tld

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130

131131
<tag>
132132
<description>Argument tag based on the JSTL fmt:param tag. The purpose is to
133-
support arguments inside the spring:message and spring:theme tags.</description>
133+
support arguments inside the spring:message tags.</description>
134134
<name>argument</name>
135135
<tag-class>org.springframework.web.servlet.tags.ArgumentTag</tag-class>
136136
<body-content>JSP</body-content>

spring-webmvc/src/main/resources/org/springframework/web/servlet/view/freemarker/spring.ftl

-30
Original file line numberDiff line numberDiff line change
@@ -50,36 +50,6 @@
5050
-->
5151
<#macro messageArgsText code, args, text>${springMacroRequestContext.getMessage(code, args, text)?no_esc}</#macro>
5252

53-
<#--
54-
* theme
55-
*
56-
* Macro to translate a theme message code into a message.
57-
-->
58-
<#macro theme code>${springMacroRequestContext.getThemeMessage(code)?no_esc}</#macro>
59-
60-
<#--
61-
* themeText
62-
*
63-
* Macro to translate a theme message code into a message,
64-
* using the given default text if no message found.
65-
-->
66-
<#macro themeText code, text>${springMacroRequestContext.getThemeMessage(code, text)?no_esc}</#macro>
67-
68-
<#--
69-
* themeArgs
70-
*
71-
* Macro to translate a theme message code with arguments into a message.
72-
-->
73-
<#macro themeArgs code, args>${springMacroRequestContext.getThemeMessage(code, args)?no_esc}</#macro>
74-
75-
<#--
76-
* themeArgsText
77-
*
78-
* Macro to translate a theme message code with arguments into a message,
79-
* using the given default text if no message found.
80-
-->
81-
<#macro themeArgsText code, args, text>${springMacroRequestContext.getThemeMessage(code, args, text)?no_esc}</#macro>
82-
8353
<#--
8454
* url
8555
*

spring-webmvc/src/test/java/org/springframework/web/servlet/view/DummyMacroRequestContext.java

+1-37
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -40,8 +40,6 @@ public class DummyMacroRequestContext {
4040

4141
private Map<String, String> messageMap;
4242

43-
private Map<String, String> themeMessageMap;
44-
4543
private String contextPath;
4644

4745

@@ -54,10 +52,6 @@ public void setMessageMap(Map<String, String> messageMap) {
5452
this.messageMap = messageMap;
5553
}
5654

57-
public void setThemeMessageMap(Map<String, String> themeMessageMap) {
58-
this.themeMessageMap = themeMessageMap;
59-
}
60-
6155

6256
/**
6357
* @see org.springframework.web.servlet.support.RequestContext#getMessage(String)
@@ -89,36 +83,6 @@ public String getMessage(String code, List<?> args, String defaultMsg) {
8983
return (msg != null ? msg + args : defaultMsg);
9084
}
9185

92-
/**
93-
* @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String)
94-
*/
95-
public String getThemeMessage(String code) {
96-
return this.themeMessageMap.get(code);
97-
}
98-
99-
/**
100-
* @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String, String)
101-
*/
102-
public String getThemeMessage(String code, String defaultMsg) {
103-
String msg = this.themeMessageMap.get(code);
104-
return (msg != null ? msg : defaultMsg);
105-
}
106-
107-
/**
108-
* @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String, List)
109-
*/
110-
public String getThemeMessage(String code, List<?> args) {
111-
return this.themeMessageMap.get(code) + args;
112-
}
113-
114-
/**
115-
* @see org.springframework.web.servlet.support.RequestContext#getThemeMessage(String, List, String)
116-
*/
117-
public String getThemeMessage(String code, List<?> args, String defaultMsg) {
118-
String msg = this.themeMessageMap.get(code);
119-
return (msg != null ? msg + args : defaultMsg);
120-
}
121-
12286
public void setContextPath(String contextPath) {
12387
this.contextPath = contextPath;
12488
}

spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java

-24
Original file line numberDiff line numberDiff line change
@@ -171,26 +171,6 @@ void testMessageArgsWithDefaultMessage() throws Exception {
171171
assertThat(getMacroOutput("MESSAGEARGSWITHDEFAULTMESSAGE")).isEqualTo("Hi");
172172
}
173173

174-
@Test
175-
void testTheme() throws Exception {
176-
assertThat(getMacroOutput("THEME")).isEqualTo("Howdy! Mundo!");
177-
}
178-
179-
@Test
180-
void testDefaultTheme() throws Exception {
181-
assertThat(getMacroOutput("DEFAULTTHEME")).isEqualTo("hi! planet!");
182-
}
183-
184-
@Test
185-
void testThemeArgs() throws Exception {
186-
assertThat(getMacroOutput("THEMEARGS")).isEqualTo("Howdy![World]");
187-
}
188-
189-
@Test
190-
void testThemeArgsWithDefaultMessage() throws Exception {
191-
assertThat(getMacroOutput("THEMEARGSWITHDEFAULTMESSAGE")).isEqualTo("Hi!");
192-
}
193-
194174
@Test
195175
void testUrl() throws Exception {
196176
assertThat(getMacroOutput("URL")).isEqualTo("/springtest/aftercontext.html");
@@ -291,10 +271,6 @@ private String getMacroOutput(String name) throws Exception {
291271
msgMap.put("hello", "Howdy");
292272
msgMap.put("world", "Mundo");
293273
rc.setMessageMap(msgMap);
294-
Map<String, String> themeMsgMap = new HashMap<>();
295-
themeMsgMap.put("hello", "Howdy!");
296-
themeMsgMap.put("world", "Mundo!");
297-
rc.setThemeMessageMap(themeMsgMap);
298274
rc.setContextPath("/springtest");
299275

300276
TestBean darren = new TestBean("Darren", 99);
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
useCodeAsDefaultMessage=false
22
message-file=context-messages
33
objectName=test:service=myservice
4-
theme-base=org/springframework/web/context/WEB-INF/

spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/test-theme.properties

-1
This file was deleted.

spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/theme.properties

-2
This file was deleted.

spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/theme_en_GB.properties

Whitespace-only changes.

spring-webmvc/src/test/resources/org/springframework/web/context/WEB-INF/theme_en_US.properties

-1
This file was deleted.

spring-webmvc/src/test/resources/org/springframework/web/servlet/view/freemarker/test.ftl

-12
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,6 @@ MESSAGEARGS
2121
MESSAGEARGSWITHDEFAULTMESSAGE
2222
<@spring.messageArgsText "no.such.code", msgArgs, "Hi"/>
2323

24-
THEME
25-
<@spring.theme "hello"/> <@spring.theme "world"/>
26-
27-
DEFAULTTHEME
28-
<@spring.themeText "no.such.code", "hi!"/> <@spring.themeText "no.such.code", "planet!"/>
29-
30-
THEMEARGS
31-
<@spring.themeArgs "hello", msgArgs/>
32-
33-
THEMEARGSWITHDEFAULTMESSAGE
34-
<@spring.themeArgsText "no.such.code", msgArgs, "Hi!"/>
35-
3624
URL
3725
<@spring.url "/aftercontext.html"/>
3826

0 commit comments

Comments
 (0)