Skip to content

Commit c74bad6

Browse files
committed
Remove outdated references to ContextLoaderServlet
Issue: SPR-7725 (cherry picked from commit 69998e3)
1 parent f41e0bc commit c74bad6

File tree

7 files changed

+72
-87
lines changed

7 files changed

+72
-87
lines changed

spring-orm-hibernate4/src/main/java/org/springframework/orm/hibernate4/support/OpenSessionInViewFilter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@
6363
*
6464
* <p>Looks up the SessionFactory in Spring's root web application context.
6565
* Supports a "sessionFactoryBeanName" filter init-param in {@code web.xml};
66-
* the default bean name is "sessionFactory". Looks up the SessionFactory on each
67-
* request, to avoid initialization order issues (when using ContextLoaderServlet,
68-
* the root application context will get initialized <i>after</i> this filter).
66+
* the default bean name is "sessionFactory".
6967
*
7068
* @author Juergen Hoeller
7169
* @since 3.1

spring-orm/src/main/java/org/springframework/orm/hibernate3/support/OpenSessionInViewFilter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@
7878
*
7979
* <p>Looks up the SessionFactory in Spring's root web application context.
8080
* Supports a "sessionFactoryBeanName" filter init-param in {@code web.xml};
81-
* the default bean name is "sessionFactory". Looks up the SessionFactory on each
82-
* request, to avoid initialization order issues (when using ContextLoaderServlet,
83-
* the root application context will get initialized <i>after</i> this filter).
81+
* the default bean name is "sessionFactory".
8482
*
8583
* @author Juergen Hoeller
8684
* @since 1.2

spring-orm/src/main/java/org/springframework/orm/jdo/support/OpenPersistenceManagerInViewFilter.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 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.
@@ -45,9 +45,7 @@
4545
*
4646
* <p>Looks up the PersistenceManagerFactory in Spring's root web application context.
4747
* Supports a "persistenceManagerFactoryBeanName" filter init-param in {@code web.xml};
48-
* the default bean name is "persistenceManagerFactory". Looks up the PersistenceManagerFactory
49-
* on each request, to avoid initialization order issues (when using ContextLoaderServlet,
50-
* the root application context will get initialized <i>after</i> this filter).
48+
* the default bean name is "persistenceManagerFactory".
5149
*
5250
* @author Juergen Hoeller
5351
* @since 1.1

spring-web/src/main/java/org/springframework/web/context/support/WebApplicationContextUtils.java

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 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.
@@ -67,18 +67,16 @@ public abstract class WebApplicationContextUtils {
6767

6868

6969
/**
70-
* Find the root WebApplicationContext for this web application, which is
71-
* typically loaded via {@link org.springframework.web.context.ContextLoaderListener}.
70+
* Find the root {@link WebApplicationContext} for this web app, typically
71+
* loaded via {@link org.springframework.web.context.ContextLoaderListener}.
7272
* <p>Will rethrow an exception that happened on root context startup,
7373
* to differentiate between a failed context startup and no context at all.
7474
* @param sc ServletContext to find the web application context for
7575
* @return the root WebApplicationContext for this web app
7676
* @throws IllegalStateException if the root WebApplicationContext could not be found
7777
* @see org.springframework.web.context.WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
7878
*/
79-
public static WebApplicationContext getRequiredWebApplicationContext(ServletContext sc)
80-
throws IllegalStateException {
81-
79+
public static WebApplicationContext getRequiredWebApplicationContext(ServletContext sc) throws IllegalStateException {
8280
WebApplicationContext wac = getWebApplicationContext(sc);
8381
if (wac == null) {
8482
throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");
@@ -87,8 +85,8 @@ public static WebApplicationContext getRequiredWebApplicationContext(ServletCont
8785
}
8886

8987
/**
90-
* Find the root WebApplicationContext for this web application, which is
91-
* typically loaded via {@link org.springframework.web.context.ContextLoaderListener}.
88+
* Find the root {@link WebApplicationContext} for this web app, typically
89+
* loaded via {@link org.springframework.web.context.ContextLoaderListener}.
9290
* <p>Will rethrow an exception that happened on root context startup,
9391
* to differentiate between a failed context startup and no context at all.
9492
* @param sc ServletContext to find the web application context for
@@ -100,7 +98,7 @@ public static WebApplicationContext getWebApplicationContext(ServletContext sc)
10098
}
10199

102100
/**
103-
* Find a custom WebApplicationContext for this web application.
101+
* Find a custom {@link WebApplicationContext} for this web app.
104102
* @param sc ServletContext to find the web application context for
105103
* @param attrName the name of the ServletContext attribute to look for
106104
* @return the desired WebApplicationContext for this web app, or {@code null} if none
@@ -175,34 +173,34 @@ public static void registerEnvironmentBeans(ConfigurableListableBeanFactory bf,
175173
* Register web-specific environment beans ("contextParameters", "contextAttributes")
176174
* with the given BeanFactory, as used by the WebApplicationContext.
177175
* @param bf the BeanFactory to configure
178-
* @param sc the ServletContext that we're running within
179-
* @param config the ServletConfig of the containing Portlet
176+
* @param servletContext the ServletContext that we're running within
177+
* @param servletConfig the ServletConfig of the containing Portlet
180178
*/
181179
public static void registerEnvironmentBeans(
182-
ConfigurableListableBeanFactory bf, ServletContext sc, ServletConfig config) {
180+
ConfigurableListableBeanFactory bf, ServletContext servletContext, ServletConfig servletConfig) {
183181

184-
if (sc != null && !bf.containsBean(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME)) {
185-
bf.registerSingleton(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME, sc);
182+
if (servletContext != null && !bf.containsBean(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME)) {
183+
bf.registerSingleton(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME, servletContext);
186184
}
187185

188-
if (config != null && !bf.containsBean(ConfigurableWebApplicationContext.SERVLET_CONFIG_BEAN_NAME)) {
189-
bf.registerSingleton(ConfigurableWebApplicationContext.SERVLET_CONFIG_BEAN_NAME, config);
186+
if (servletConfig != null && !bf.containsBean(ConfigurableWebApplicationContext.SERVLET_CONFIG_BEAN_NAME)) {
187+
bf.registerSingleton(ConfigurableWebApplicationContext.SERVLET_CONFIG_BEAN_NAME, servletConfig);
190188
}
191189

192190
if (!bf.containsBean(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME)) {
193191
Map<String, String> parameterMap = new HashMap<String, String>();
194-
if (sc != null) {
195-
Enumeration<?> paramNameEnum = sc.getInitParameterNames();
192+
if (servletContext != null) {
193+
Enumeration<?> paramNameEnum = servletContext.getInitParameterNames();
196194
while (paramNameEnum.hasMoreElements()) {
197195
String paramName = (String) paramNameEnum.nextElement();
198-
parameterMap.put(paramName, sc.getInitParameter(paramName));
196+
parameterMap.put(paramName, servletContext.getInitParameter(paramName));
199197
}
200198
}
201-
if (config != null) {
202-
Enumeration<?> paramNameEnum = config.getInitParameterNames();
199+
if (servletConfig != null) {
200+
Enumeration<?> paramNameEnum = servletConfig.getInitParameterNames();
203201
while (paramNameEnum.hasMoreElements()) {
204202
String paramName = (String) paramNameEnum.nextElement();
205-
parameterMap.put(paramName, config.getInitParameter(paramName));
203+
parameterMap.put(paramName, servletConfig.getInitParameter(paramName));
206204
}
207205
}
208206
bf.registerSingleton(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME,
@@ -211,11 +209,11 @@ public static void registerEnvironmentBeans(
211209

212210
if (!bf.containsBean(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME)) {
213211
Map<String, Object> attributeMap = new HashMap<String, Object>();
214-
if (sc != null) {
215-
Enumeration<?> attrNameEnum = sc.getAttributeNames();
212+
if (servletContext != null) {
213+
Enumeration<?> attrNameEnum = servletContext.getAttributeNames();
216214
while (attrNameEnum.hasMoreElements()) {
217215
String attrName = (String) attrNameEnum.nextElement();
218-
attributeMap.put(attrName, sc.getAttribute(attrName));
216+
attributeMap.put(attrName, servletContext.getAttribute(attrName));
219217
}
220218
}
221219
bf.registerSingleton(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME,
@@ -229,9 +227,7 @@ public static void registerEnvironmentBeans(
229227
* {@link ServletConfig} parameter.
230228
* @see #initServletPropertySources(MutablePropertySources, ServletContext, ServletConfig)
231229
*/
232-
public static void initServletPropertySources(
233-
MutablePropertySources propertySources, ServletContext servletContext) {
234-
230+
public static void initServletPropertySources(MutablePropertySources propertySources, ServletContext servletContext) {
235231
initServletPropertySources(propertySources, servletContext, null);
236232
}
237233

spring-web/src/main/java/org/springframework/web/jsf/FacesContextUtils.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 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,8 +38,8 @@
3838
public abstract class FacesContextUtils {
3939

4040
/**
41-
* Find the root {@link WebApplicationContext} for this web app,
42-
* typically loaded via ContextLoaderListener.
41+
* Find the root {@link WebApplicationContext} for this web app, typically
42+
* loaded via {@link org.springframework.web.context.ContextLoaderListener}.
4343
* <p>Will rethrow an exception that happened on root context startup,
4444
* to differentiate between a failed context startup and no context at all.
4545
* @param fc the FacesContext to find the web application context for
@@ -66,18 +66,16 @@ public static WebApplicationContext getWebApplicationContext(FacesContext fc) {
6666
}
6767

6868
/**
69-
* Find the root {@link WebApplicationContext} for this web app,
70-
* typically loaded via ContextLoaderListener.
69+
* Find the root {@link WebApplicationContext} for this web app, typically
70+
* loaded via {@link org.springframework.web.context.ContextLoaderListener}.
7171
* <p>Will rethrow an exception that happened on root context startup,
7272
* to differentiate between a failed context startup and no context at all.
7373
* @param fc the FacesContext to find the web application context for
7474
* @return the root WebApplicationContext for this web app
7575
* @throws IllegalStateException if the root WebApplicationContext could not be found
7676
* @see org.springframework.web.context.WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
7777
*/
78-
public static WebApplicationContext getRequiredWebApplicationContext(FacesContext fc)
79-
throws IllegalStateException {
80-
78+
public static WebApplicationContext getRequiredWebApplicationContext(FacesContext fc) throws IllegalStateException {
8179
WebApplicationContext wac = getWebApplicationContext(fc);
8280
if (wac == null) {
8381
throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");

spring-web/src/main/java/org/springframework/web/multipart/support/MultipartFilter.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 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,9 +34,7 @@
3434
*
3535
* <p>Looks up the MultipartResolver in Spring's root web application context.
3636
* Supports a "multipartResolverBeanName" filter init-param in {@code web.xml};
37-
* the default bean name is "filterMultipartResolver". Looks up the MultipartResolver
38-
* on each request, to avoid initialization order issues (when using ContextLoaderServlet,
39-
* the root application context will get initialized <i>after</i> this filter).
37+
* the default bean name is "filterMultipartResolver".
4038
*
4139
* <p>If no MultipartResolver bean is found, this filter falls back to a default
4240
* MultipartResolver: {@link StandardServletMultipartResolver} for Servlet 3.0,
@@ -110,6 +108,7 @@ protected void doFilterInternal(
110108
processedRequest = multipartResolver.resolveMultipart(processedRequest);
111109
}
112110
else {
111+
// A regular request...
113112
if (logger.isDebugEnabled()) {
114113
logger.debug("Request [" + processedRequest.getRequestURI() + "] is not a multipart request");
115114
}

spring-webmvc-portlet/src/main/java/org/springframework/web/portlet/context/PortletApplicationContextUtils.java

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 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.
@@ -56,8 +56,8 @@
5656
public abstract class PortletApplicationContextUtils {
5757

5858
/**
59-
* Find the root WebApplicationContext for this portlet application, which is
60-
* typically loaded via ContextLoaderListener or ContextLoaderServlet.
59+
* Find the root {@link WebApplicationContext} for this web app, typically
60+
* loaded via {@link org.springframework.web.context.ContextLoaderListener}.
6161
* <p>Will rethrow an exception that happened on root context startup,
6262
* to differentiate between a failed context startup and no context at all.
6363
* @param pc PortletContext to find the web application context for
@@ -85,8 +85,8 @@ public static ApplicationContext getWebApplicationContext(PortletContext pc) {
8585
}
8686

8787
/**
88-
* Find the root WebApplicationContext for this portlet application, which is
89-
* typically loaded via ContextLoaderListener or ContextLoaderServlet.
88+
* Find the root {@link WebApplicationContext} for this web app, typically
89+
* loaded via {@link org.springframework.web.context.ContextLoaderListener}.
9090
* <p>Will rethrow an exception that happened on root context startup,
9191
* to differentiate between a failed context startup and no context at all.
9292
* @param pc PortletContext to find the web application context for
@@ -96,9 +96,7 @@ public static ApplicationContext getWebApplicationContext(PortletContext pc) {
9696
* @throws IllegalStateException if the root WebApplicationContext could not be found
9797
* @see org.springframework.web.context.WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
9898
*/
99-
public static ApplicationContext getRequiredWebApplicationContext(PortletContext pc)
100-
throws IllegalStateException {
101-
99+
public static ApplicationContext getRequiredWebApplicationContext(PortletContext pc) throws IllegalStateException {
102100
ApplicationContext wac = getWebApplicationContext(pc);
103101
if (wac == null) {
104102
throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");
@@ -110,62 +108,62 @@ public static ApplicationContext getRequiredWebApplicationContext(PortletContext
110108
/**
111109
* Register web-specific scopes ("request", "session", "globalSession")
112110
* with the given BeanFactory, as used by the Portlet ApplicationContext.
113-
* @param beanFactory the BeanFactory to configure
111+
* @param bf the BeanFactory to configure
114112
* @param pc the PortletContext that we're running within
115113
*/
116-
static void registerPortletApplicationScopes(ConfigurableListableBeanFactory beanFactory, PortletContext pc) {
117-
beanFactory.registerScope(WebApplicationContext.SCOPE_REQUEST, new RequestScope());
118-
beanFactory.registerScope(WebApplicationContext.SCOPE_SESSION, new SessionScope(false));
119-
beanFactory.registerScope(WebApplicationContext.SCOPE_GLOBAL_SESSION, new SessionScope(true));
114+
static void registerPortletApplicationScopes(ConfigurableListableBeanFactory bf, PortletContext pc) {
115+
bf.registerScope(WebApplicationContext.SCOPE_REQUEST, new RequestScope());
116+
bf.registerScope(WebApplicationContext.SCOPE_SESSION, new SessionScope(false));
117+
bf.registerScope(WebApplicationContext.SCOPE_GLOBAL_SESSION, new SessionScope(true));
120118
if (pc != null) {
121119
PortletContextScope appScope = new PortletContextScope(pc);
122-
beanFactory.registerScope(WebApplicationContext.SCOPE_APPLICATION, appScope);
120+
bf.registerScope(WebApplicationContext.SCOPE_APPLICATION, appScope);
123121
// Register as PortletContext attribute, for ContextCleanupListener to detect it.
124122
pc.setAttribute(PortletContextScope.class.getName(), appScope);
125123
}
126124

127-
beanFactory.registerResolvableDependency(PortletRequest.class, new RequestObjectFactory());
128-
beanFactory.registerResolvableDependency(PortletSession.class, new SessionObjectFactory());
129-
beanFactory.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory());
125+
bf.registerResolvableDependency(PortletRequest.class, new RequestObjectFactory());
126+
bf.registerResolvableDependency(PortletSession.class, new SessionObjectFactory());
127+
bf.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory());
130128
}
131129

132130
/**
133131
* Register web-specific environment beans ("contextParameters", "contextAttributes")
134132
* with the given BeanFactory, as used by the Portlet ApplicationContext.
135133
* @param bf the BeanFactory to configure
136-
* @param sc the ServletContext that we're running within
137-
* @param pc the PortletContext that we're running within
138-
* @param config the PortletConfig of the containing Portlet
134+
* @param servletContext the ServletContext that we're running within
135+
* @param portletContext the PortletContext that we're running within
136+
* @param portletConfig the PortletConfig of the containing Portlet
139137
*/
140-
static void registerEnvironmentBeans(
141-
ConfigurableListableBeanFactory bf, ServletContext sc, PortletContext pc, PortletConfig config) {
138+
static void registerEnvironmentBeans(ConfigurableListableBeanFactory bf, ServletContext servletContext,
139+
PortletContext portletContext, PortletConfig portletConfig) {
142140

143-
if (sc != null && !bf.containsBean(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME)) {
144-
bf.registerSingleton(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME, sc);
141+
if (servletContext != null && !bf.containsBean(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME)) {
142+
bf.registerSingleton(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME, servletContext);
145143
}
146144

147-
if (pc != null && !bf.containsBean(ConfigurablePortletApplicationContext.PORTLET_CONTEXT_BEAN_NAME)) {
148-
bf.registerSingleton(ConfigurablePortletApplicationContext.PORTLET_CONTEXT_BEAN_NAME, pc);
145+
if (portletContext != null && !bf.containsBean(ConfigurablePortletApplicationContext.PORTLET_CONTEXT_BEAN_NAME)) {
146+
bf.registerSingleton(ConfigurablePortletApplicationContext.PORTLET_CONTEXT_BEAN_NAME, portletContext);
149147
}
150148

151-
if (config != null && !bf.containsBean(ConfigurablePortletApplicationContext.PORTLET_CONFIG_BEAN_NAME)) {
152-
bf.registerSingleton(ConfigurablePortletApplicationContext.PORTLET_CONFIG_BEAN_NAME, config);
149+
if (portletConfig != null && !bf.containsBean(ConfigurablePortletApplicationContext.PORTLET_CONFIG_BEAN_NAME)) {
150+
bf.registerSingleton(ConfigurablePortletApplicationContext.PORTLET_CONFIG_BEAN_NAME, portletConfig);
153151
}
154152

155153
if (!bf.containsBean(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME)) {
156154
Map<String, String> parameterMap = new HashMap<String, String>();
157-
if (pc != null) {
158-
Enumeration<String> paramNameEnum = pc.getInitParameterNames();
155+
if (portletContext != null) {
156+
Enumeration<String> paramNameEnum = portletContext.getInitParameterNames();
159157
while (paramNameEnum.hasMoreElements()) {
160158
String paramName = paramNameEnum.nextElement();
161-
parameterMap.put(paramName, pc.getInitParameter(paramName));
159+
parameterMap.put(paramName, portletContext.getInitParameter(paramName));
162160
}
163161
}
164-
if (config != null) {
165-
Enumeration<String> paramNameEnum = config.getInitParameterNames();
162+
if (portletConfig != null) {
163+
Enumeration<String> paramNameEnum = portletConfig.getInitParameterNames();
166164
while (paramNameEnum.hasMoreElements()) {
167165
String paramName = paramNameEnum.nextElement();
168-
parameterMap.put(paramName, config.getInitParameter(paramName));
166+
parameterMap.put(paramName, portletConfig.getInitParameter(paramName));
169167
}
170168
}
171169
bf.registerSingleton(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME,
@@ -174,11 +172,11 @@ static void registerEnvironmentBeans(
174172

175173
if (!bf.containsBean(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME)) {
176174
Map<String, Object> attributeMap = new HashMap<String, Object>();
177-
if (pc != null) {
178-
Enumeration<String> attrNameEnum = pc.getAttributeNames();
175+
if (portletContext != null) {
176+
Enumeration<String> attrNameEnum = portletContext.getAttributeNames();
179177
while (attrNameEnum.hasMoreElements()) {
180178
String attrName = attrNameEnum.nextElement();
181-
attributeMap.put(attrName, pc.getAttribute(attrName));
179+
attributeMap.put(attrName, portletContext.getAttribute(attrName));
182180
}
183181
}
184182
bf.registerSingleton(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME,

0 commit comments

Comments
 (0)