Skip to content

Commit 69998e3

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

File tree

7 files changed

+71
-86
lines changed

7 files changed

+71
-86
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: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,16 @@ public abstract class WebApplicationContextUtils {
6868

6969

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

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

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

186-
if (sc != null && !bf.containsBean(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME)) {
187-
bf.registerSingleton(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME, sc);
184+
if (servletContext != null && !bf.containsBean(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME)) {
185+
bf.registerSingleton(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME, servletContext);
188186
}
189187

190-
if (config != null && !bf.containsBean(ConfigurableWebApplicationContext.SERVLET_CONFIG_BEAN_NAME)) {
191-
bf.registerSingleton(ConfigurableWebApplicationContext.SERVLET_CONFIG_BEAN_NAME, config);
188+
if (servletConfig != null && !bf.containsBean(ConfigurableWebApplicationContext.SERVLET_CONFIG_BEAN_NAME)) {
189+
bf.registerSingleton(ConfigurableWebApplicationContext.SERVLET_CONFIG_BEAN_NAME, servletConfig);
192190
}
193191

194192
if (!bf.containsBean(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME)) {
195193
Map<String, String> parameterMap = new HashMap<String, String>();
196-
if (sc != null) {
197-
Enumeration<?> paramNameEnum = sc.getInitParameterNames();
194+
if (servletContext != null) {
195+
Enumeration<?> paramNameEnum = servletContext.getInitParameterNames();
198196
while (paramNameEnum.hasMoreElements()) {
199197
String paramName = (String) paramNameEnum.nextElement();
200-
parameterMap.put(paramName, sc.getInitParameter(paramName));
198+
parameterMap.put(paramName, servletContext.getInitParameter(paramName));
201199
}
202200
}
203-
if (config != null) {
204-
Enumeration<?> paramNameEnum = config.getInitParameterNames();
201+
if (servletConfig != null) {
202+
Enumeration<?> paramNameEnum = servletConfig.getInitParameterNames();
205203
while (paramNameEnum.hasMoreElements()) {
206204
String paramName = (String) paramNameEnum.nextElement();
207-
parameterMap.put(paramName, config.getInitParameter(paramName));
205+
parameterMap.put(paramName, servletConfig.getInitParameter(paramName));
208206
}
209207
}
210208
bf.registerSingleton(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME,
@@ -213,11 +211,11 @@ public static void registerEnvironmentBeans(
213211

214212
if (!bf.containsBean(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME)) {
215213
Map<String, Object> attributeMap = new HashMap<String, Object>();
216-
if (sc != null) {
217-
Enumeration<?> attrNameEnum = sc.getAttributeNames();
214+
if (servletContext != null) {
215+
Enumeration<?> attrNameEnum = servletContext.getAttributeNames();
218216
while (attrNameEnum.hasMoreElements()) {
219217
String attrName = (String) attrNameEnum.nextElement();
220-
attributeMap.put(attrName, sc.getAttribute(attrName));
218+
attributeMap.put(attrName, servletContext.getAttribute(attrName));
221219
}
222220
}
223221
bf.registerSingleton(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME,
@@ -231,9 +229,7 @@ public static void registerEnvironmentBeans(
231229
* {@link ServletConfig} parameter.
232230
* @see #initServletPropertySources(MutablePropertySources, ServletContext, ServletConfig)
233231
*/
234-
public static void initServletPropertySources(
235-
MutablePropertySources propertySources, ServletContext servletContext) {
236-
232+
public static void initServletPropertySources(MutablePropertySources propertySources, ServletContext servletContext) {
237233
initServletPropertySources(propertySources, servletContext, null);
238234
}
239235

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
@@ -57,8 +57,8 @@
5757
public abstract class PortletApplicationContextUtils {
5858

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

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

128-
beanFactory.registerResolvableDependency(PortletRequest.class, new RequestObjectFactory());
129-
beanFactory.registerResolvableDependency(PortletResponse.class, new ResponseObjectFactory());
130-
beanFactory.registerResolvableDependency(PortletSession.class, new SessionObjectFactory());
131-
beanFactory.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory());
126+
bf.registerResolvableDependency(PortletRequest.class, new RequestObjectFactory());
127+
bf.registerResolvableDependency(PortletResponse.class, new ResponseObjectFactory());
128+
bf.registerResolvableDependency(PortletSession.class, new SessionObjectFactory());
129+
bf.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory());
132130
}
133131

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

145-
if (sc != null && !bf.containsBean(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME)) {
146-
bf.registerSingleton(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME, sc);
143+
if (servletContext != null && !bf.containsBean(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME)) {
144+
bf.registerSingleton(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME, servletContext);
147145
}
148146

149-
if (pc != null && !bf.containsBean(ConfigurablePortletApplicationContext.PORTLET_CONTEXT_BEAN_NAME)) {
150-
bf.registerSingleton(ConfigurablePortletApplicationContext.PORTLET_CONTEXT_BEAN_NAME, pc);
147+
if (portletContext != null && !bf.containsBean(ConfigurablePortletApplicationContext.PORTLET_CONTEXT_BEAN_NAME)) {
148+
bf.registerSingleton(ConfigurablePortletApplicationContext.PORTLET_CONTEXT_BEAN_NAME, portletContext);
151149
}
152150

153-
if (config != null && !bf.containsBean(ConfigurablePortletApplicationContext.PORTLET_CONFIG_BEAN_NAME)) {
154-
bf.registerSingleton(ConfigurablePortletApplicationContext.PORTLET_CONFIG_BEAN_NAME, config);
151+
if (portletConfig != null && !bf.containsBean(ConfigurablePortletApplicationContext.PORTLET_CONFIG_BEAN_NAME)) {
152+
bf.registerSingleton(ConfigurablePortletApplicationContext.PORTLET_CONFIG_BEAN_NAME, portletConfig);
155153
}
156154

157155
if (!bf.containsBean(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME)) {
158156
Map<String, String> parameterMap = new HashMap<String, String>();
159-
if (pc != null) {
160-
Enumeration<String> paramNameEnum = pc.getInitParameterNames();
157+
if (portletContext != null) {
158+
Enumeration<String> paramNameEnum = portletContext.getInitParameterNames();
161159
while (paramNameEnum.hasMoreElements()) {
162160
String paramName = paramNameEnum.nextElement();
163-
parameterMap.put(paramName, pc.getInitParameter(paramName));
161+
parameterMap.put(paramName, portletContext.getInitParameter(paramName));
164162
}
165163
}
166-
if (config != null) {
167-
Enumeration<String> paramNameEnum = config.getInitParameterNames();
164+
if (portletConfig != null) {
165+
Enumeration<String> paramNameEnum = portletConfig.getInitParameterNames();
168166
while (paramNameEnum.hasMoreElements()) {
169167
String paramName = paramNameEnum.nextElement();
170-
parameterMap.put(paramName, config.getInitParameter(paramName));
168+
parameterMap.put(paramName, portletConfig.getInitParameter(paramName));
171169
}
172170
}
173171
bf.registerSingleton(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME,
@@ -176,11 +174,11 @@ static void registerEnvironmentBeans(
176174

177175
if (!bf.containsBean(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME)) {
178176
Map<String, Object> attributeMap = new HashMap<String, Object>();
179-
if (pc != null) {
180-
Enumeration<String> attrNameEnum = pc.getAttributeNames();
177+
if (portletContext != null) {
178+
Enumeration<String> attrNameEnum = portletContext.getAttributeNames();
181179
while (attrNameEnum.hasMoreElements()) {
182180
String attrName = attrNameEnum.nextElement();
183-
attributeMap.put(attrName, pc.getAttribute(attrName));
181+
attributeMap.put(attrName, portletContext.getAttribute(attrName));
184182
}
185183
}
186184
bf.registerSingleton(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME,

0 commit comments

Comments
 (0)