Remove outdated references to ContextLoaderServlet

Issue: SPR-7725
This commit is contained in:
Juergen Hoeller 2014-09-26 21:40:28 +02:00
parent 65d47afc11
commit b45d08f192
8 changed files with 76 additions and 119 deletions

View File

@ -63,9 +63,7 @@ import org.springframework.web.filter.OncePerRequestFilter;
* *
* <p>Looks up the SessionFactory in Spring's root web application context. * <p>Looks up the SessionFactory in Spring's root web application context.
* Supports a "sessionFactoryBeanName" filter init-param in {@code web.xml}; * Supports a "sessionFactoryBeanName" filter init-param in {@code web.xml};
* the default bean name is "sessionFactory". Looks up the SessionFactory on each * the default bean name is "sessionFactory".
* request, to avoid initialization order issues (when using ContextLoaderServlet,
* the root application context will get initialized <i>after</i> this filter).
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 3.1 * @since 3.1

View File

@ -78,9 +78,7 @@ import org.springframework.web.filter.OncePerRequestFilter;
* *
* <p>Looks up the SessionFactory in Spring's root web application context. * <p>Looks up the SessionFactory in Spring's root web application context.
* Supports a "sessionFactoryBeanName" filter init-param in {@code web.xml}; * Supports a "sessionFactoryBeanName" filter init-param in {@code web.xml};
* the default bean name is "sessionFactory". Looks up the SessionFactory on each * the default bean name is "sessionFactory".
* request, to avoid initialization order issues (when using ContextLoaderServlet,
* the root application context will get initialized <i>after</i> this filter).
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 1.2 * @since 1.2

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@
package org.springframework.orm.jdo.support; package org.springframework.orm.jdo.support;
import java.io.IOException; import java.io.IOException;
import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory; import javax.jdo.PersistenceManagerFactory;
import javax.servlet.FilterChain; import javax.servlet.FilterChain;
@ -46,9 +45,7 @@ import org.springframework.web.filter.OncePerRequestFilter;
* *
* <p>Looks up the PersistenceManagerFactory in Spring's root web application context. * <p>Looks up the PersistenceManagerFactory in Spring's root web application context.
* Supports a "persistenceManagerFactoryBeanName" filter init-param in {@code web.xml}; * Supports a "persistenceManagerFactoryBeanName" filter init-param in {@code web.xml};
* the default bean name is "persistenceManagerFactory". Looks up the PersistenceManagerFactory * the default bean name is "persistenceManagerFactory".
* on each request, to avoid initialization order issues (when using ContextLoaderServlet,
* the root application context will get initialized <i>after</i> this filter).
* *
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 1.1 * @since 1.1

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -67,8 +67,8 @@ public abstract class WebApplicationContextUtils {
/** /**
* Find the root WebApplicationContext for this web application, which is * Find the root {@link WebApplicationContext} for this web app, typically
* typically loaded via {@link org.springframework.web.context.ContextLoaderListener}. * loaded via {@link org.springframework.web.context.ContextLoaderListener}.
* <p>Will rethrow an exception that happened on root context startup, * <p>Will rethrow an exception that happened on root context startup,
* to differentiate between a failed context startup and no context at all. * to differentiate between a failed context startup and no context at all.
* @param sc ServletContext to find the web application context for * @param sc ServletContext to find the web application context for
@ -76,9 +76,7 @@ public abstract class WebApplicationContextUtils {
* @throws IllegalStateException if the root WebApplicationContext could not be found * @throws IllegalStateException if the root WebApplicationContext could not be found
* @see org.springframework.web.context.WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE * @see org.springframework.web.context.WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
*/ */
public static WebApplicationContext getRequiredWebApplicationContext(ServletContext sc) public static WebApplicationContext getRequiredWebApplicationContext(ServletContext sc) throws IllegalStateException {
throws IllegalStateException {
WebApplicationContext wac = getWebApplicationContext(sc); WebApplicationContext wac = getWebApplicationContext(sc);
if (wac == null) { if (wac == null) {
throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?"); throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");
@ -87,8 +85,8 @@ public abstract class WebApplicationContextUtils {
} }
/** /**
* Find the root WebApplicationContext for this web application, which is * Find the root {@link WebApplicationContext} for this web app, typically
* typically loaded via {@link org.springframework.web.context.ContextLoaderListener}. * loaded via {@link org.springframework.web.context.ContextLoaderListener}.
* <p>Will rethrow an exception that happened on root context startup, * <p>Will rethrow an exception that happened on root context startup,
* to differentiate between a failed context startup and no context at all. * to differentiate between a failed context startup and no context at all.
* @param sc ServletContext to find the web application context for * @param sc ServletContext to find the web application context for
@ -100,7 +98,7 @@ public abstract class WebApplicationContextUtils {
} }
/** /**
* Find a custom WebApplicationContext for this web application. * Find a custom {@link WebApplicationContext} for this web app.
* @param sc ServletContext to find the web application context for * @param sc ServletContext to find the web application context for
* @param attrName the name of the ServletContext attribute to look for * @param attrName the name of the ServletContext attribute to look for
* @return the desired WebApplicationContext for this web app, or {@code null} if none * @return the desired WebApplicationContext for this web app, or {@code null} if none
@ -175,34 +173,34 @@ public abstract class WebApplicationContextUtils {
* Register web-specific environment beans ("contextParameters", "contextAttributes") * Register web-specific environment beans ("contextParameters", "contextAttributes")
* with the given BeanFactory, as used by the WebApplicationContext. * with the given BeanFactory, as used by the WebApplicationContext.
* @param bf the BeanFactory to configure * @param bf the BeanFactory to configure
* @param sc the ServletContext that we're running within * @param servletContext the ServletContext that we're running within
* @param config the ServletConfig of the containing Portlet * @param servletConfig the ServletConfig of the containing Portlet
*/ */
public static void registerEnvironmentBeans( public static void registerEnvironmentBeans(
ConfigurableListableBeanFactory bf, ServletContext sc, ServletConfig config) { ConfigurableListableBeanFactory bf, ServletContext servletContext, ServletConfig servletConfig) {
if (sc != null && !bf.containsBean(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME)) { if (servletContext != null && !bf.containsBean(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME)) {
bf.registerSingleton(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME, sc); bf.registerSingleton(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME, servletContext);
} }
if (config != null && !bf.containsBean(ConfigurableWebApplicationContext.SERVLET_CONFIG_BEAN_NAME)) { if (servletConfig != null && !bf.containsBean(ConfigurableWebApplicationContext.SERVLET_CONFIG_BEAN_NAME)) {
bf.registerSingleton(ConfigurableWebApplicationContext.SERVLET_CONFIG_BEAN_NAME, config); bf.registerSingleton(ConfigurableWebApplicationContext.SERVLET_CONFIG_BEAN_NAME, servletConfig);
} }
if (!bf.containsBean(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME)) { if (!bf.containsBean(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME)) {
Map<String, String> parameterMap = new HashMap<String, String>(); Map<String, String> parameterMap = new HashMap<String, String>();
if (sc != null) { if (servletContext != null) {
Enumeration<?> paramNameEnum = sc.getInitParameterNames(); Enumeration<?> paramNameEnum = servletContext.getInitParameterNames();
while (paramNameEnum.hasMoreElements()) { while (paramNameEnum.hasMoreElements()) {
String paramName = (String) paramNameEnum.nextElement(); String paramName = (String) paramNameEnum.nextElement();
parameterMap.put(paramName, sc.getInitParameter(paramName)); parameterMap.put(paramName, servletContext.getInitParameter(paramName));
} }
} }
if (config != null) { if (servletConfig != null) {
Enumeration<?> paramNameEnum = config.getInitParameterNames(); Enumeration<?> paramNameEnum = servletConfig.getInitParameterNames();
while (paramNameEnum.hasMoreElements()) { while (paramNameEnum.hasMoreElements()) {
String paramName = (String) paramNameEnum.nextElement(); String paramName = (String) paramNameEnum.nextElement();
parameterMap.put(paramName, config.getInitParameter(paramName)); parameterMap.put(paramName, servletConfig.getInitParameter(paramName));
} }
} }
bf.registerSingleton(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME, bf.registerSingleton(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME,
@ -211,11 +209,11 @@ public abstract class WebApplicationContextUtils {
if (!bf.containsBean(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME)) { if (!bf.containsBean(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME)) {
Map<String, Object> attributeMap = new HashMap<String, Object>(); Map<String, Object> attributeMap = new HashMap<String, Object>();
if (sc != null) { if (servletContext != null) {
Enumeration<?> attrNameEnum = sc.getAttributeNames(); Enumeration<?> attrNameEnum = servletContext.getAttributeNames();
while (attrNameEnum.hasMoreElements()) { while (attrNameEnum.hasMoreElements()) {
String attrName = (String) attrNameEnum.nextElement(); String attrName = (String) attrNameEnum.nextElement();
attributeMap.put(attrName, sc.getAttribute(attrName)); attributeMap.put(attrName, servletContext.getAttribute(attrName));
} }
} }
bf.registerSingleton(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME, bf.registerSingleton(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME,
@ -229,9 +227,7 @@ public abstract class WebApplicationContextUtils {
* {@link ServletConfig} parameter. * {@link ServletConfig} parameter.
* @see #initServletPropertySources(MutablePropertySources, ServletContext, ServletConfig) * @see #initServletPropertySources(MutablePropertySources, ServletContext, ServletConfig)
*/ */
public static void initServletPropertySources( public static void initServletPropertySources(MutablePropertySources propertySources, ServletContext servletContext) {
MutablePropertySources propertySources, ServletContext servletContext) {
initServletPropertySources(propertySources, servletContext, null); initServletPropertySources(propertySources, servletContext, null);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,9 +24,9 @@ import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.util.WebUtils; import org.springframework.web.util.WebUtils;
/** /**
* Convenience methods to retrieve the root WebApplicationContext for a given * Convenience methods to retrieve Spring's root {@link WebApplicationContext}
* FacesContext. This is e.g. useful for accessing a Spring context from * for a given JSF {@link FacesContext}. This is useful for accessing a
* custom JSF code. * Spring application context from custom JSF-based code.
* *
* <p>Analogous to Spring's WebApplicationContextUtils for the ServletContext. * <p>Analogous to Spring's WebApplicationContextUtils for the ServletContext.
* *
@ -38,8 +38,8 @@ import org.springframework.web.util.WebUtils;
public abstract class FacesContextUtils { public abstract class FacesContextUtils {
/** /**
* Find the root WebApplicationContext for this web app, which is * Find the root {@link WebApplicationContext} for this web app, typically
* typically loaded via ContextLoaderListener or ContextLoaderServlet. * loaded via {@link org.springframework.web.context.ContextLoaderListener}.
* <p>Will rethrow an exception that happened on root context startup, * <p>Will rethrow an exception that happened on root context startup,
* to differentiate between a failed context startup and no context at all. * to differentiate between a failed context startup and no context at all.
* @param fc the FacesContext to find the web application context for * @param fc the FacesContext to find the web application context for
@ -66,8 +66,8 @@ public abstract class FacesContextUtils {
} }
/** /**
* Find the root WebApplicationContext for this web app, which is * Find the root {@link WebApplicationContext} for this web app, typically
* typically loaded via ContextLoaderListener or ContextLoaderServlet. * loaded via {@link org.springframework.web.context.ContextLoaderListener}.
* <p>Will rethrow an exception that happened on root context startup, * <p>Will rethrow an exception that happened on root context startup,
* to differentiate between a failed context startup and no context at all. * to differentiate between a failed context startup and no context at all.
* @param fc the FacesContext to find the web application context for * @param fc the FacesContext to find the web application context for
@ -75,9 +75,7 @@ public abstract class FacesContextUtils {
* @throws IllegalStateException if the root WebApplicationContext could not be found * @throws IllegalStateException if the root WebApplicationContext could not be found
* @see org.springframework.web.context.WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE * @see org.springframework.web.context.WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
*/ */
public static WebApplicationContext getRequiredWebApplicationContext(FacesContext fc) public static WebApplicationContext getRequiredWebApplicationContext(FacesContext fc) throws IllegalStateException {
throws IllegalStateException {
WebApplicationContext wac = getWebApplicationContext(fc); WebApplicationContext wac = getWebApplicationContext(fc);
if (wac == null) { if (wac == null) {
throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?"); throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -34,9 +34,7 @@ import org.springframework.web.multipart.MultipartResolver;
* *
* <p>Looks up the MultipartResolver in Spring's root web application context. * <p>Looks up the MultipartResolver in Spring's root web application context.
* Supports a "multipartResolverBeanName" filter init-param in {@code web.xml}; * Supports a "multipartResolverBeanName" filter init-param in {@code web.xml};
* the default bean name is "filterMultipartResolver". Looks up the MultipartResolver * the default bean name is "filterMultipartResolver".
* on each request, to avoid initialization order issues (when using ContextLoaderServlet,
* the root application context will get initialized <i>after</i> this filter).
* *
* <p>If no MultipartResolver bean is found, this filter falls back to a default * <p>If no MultipartResolver bean is found, this filter falls back to a default
* MultipartResolver: {@link StandardServletMultipartResolver} for Servlet 3.0, * MultipartResolver: {@link StandardServletMultipartResolver} for Servlet 3.0,
@ -110,6 +108,7 @@ public class MultipartFilter extends OncePerRequestFilter {
processedRequest = multipartResolver.resolveMultipart(processedRequest); processedRequest = multipartResolver.resolveMultipart(processedRequest);
} }
else { else {
// A regular request...
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Request [" + processedRequest.getRequestURI() + "] is not a multipart request"); logger.debug("Request [" + processedRequest.getRequestURI() + "] is not a multipart request");
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2014 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -56,8 +56,8 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
public abstract class PortletApplicationContextUtils { public abstract class PortletApplicationContextUtils {
/** /**
* Find the root WebApplicationContext for this portlet application, which is * Find the root {@link WebApplicationContext} for this web app, typically
* typically loaded via ContextLoaderListener or ContextLoaderServlet. * loaded via {@link org.springframework.web.context.ContextLoaderListener}.
* <p>Will rethrow an exception that happened on root context startup, * <p>Will rethrow an exception that happened on root context startup,
* to differentiate between a failed context startup and no context at all. * to differentiate between a failed context startup and no context at all.
* @param pc PortletContext to find the web application context for * @param pc PortletContext to find the web application context for
@ -85,8 +85,8 @@ public abstract class PortletApplicationContextUtils {
} }
/** /**
* Find the root WebApplicationContext for this portlet application, which is * Find the root {@link WebApplicationContext} for this web app, typically
* typically loaded via ContextLoaderListener or ContextLoaderServlet. * loaded via {@link org.springframework.web.context.ContextLoaderListener}.
* <p>Will rethrow an exception that happened on root context startup, * <p>Will rethrow an exception that happened on root context startup,
* to differentiate between a failed context startup and no context at all. * to differentiate between a failed context startup and no context at all.
* @param pc PortletContext to find the web application context for * @param pc PortletContext to find the web application context for
@ -96,9 +96,7 @@ public abstract class PortletApplicationContextUtils {
* @throws IllegalStateException if the root WebApplicationContext could not be found * @throws IllegalStateException if the root WebApplicationContext could not be found
* @see org.springframework.web.context.WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE * @see org.springframework.web.context.WebApplicationContext#ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE
*/ */
public static ApplicationContext getRequiredWebApplicationContext(PortletContext pc) public static ApplicationContext getRequiredWebApplicationContext(PortletContext pc) throws IllegalStateException {
throws IllegalStateException {
ApplicationContext wac = getWebApplicationContext(pc); ApplicationContext wac = getWebApplicationContext(pc);
if (wac == null) { if (wac == null) {
throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?"); throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");
@ -110,62 +108,62 @@ public abstract class PortletApplicationContextUtils {
/** /**
* Register web-specific scopes ("request", "session", "globalSession") * Register web-specific scopes ("request", "session", "globalSession")
* with the given BeanFactory, as used by the Portlet ApplicationContext. * with the given BeanFactory, as used by the Portlet ApplicationContext.
* @param beanFactory the BeanFactory to configure * @param bf the BeanFactory to configure
* @param pc the PortletContext that we're running within * @param pc the PortletContext that we're running within
*/ */
static void registerPortletApplicationScopes(ConfigurableListableBeanFactory beanFactory, PortletContext pc) { static void registerPortletApplicationScopes(ConfigurableListableBeanFactory bf, PortletContext pc) {
beanFactory.registerScope(WebApplicationContext.SCOPE_REQUEST, new RequestScope()); bf.registerScope(WebApplicationContext.SCOPE_REQUEST, new RequestScope());
beanFactory.registerScope(WebApplicationContext.SCOPE_SESSION, new SessionScope(false)); bf.registerScope(WebApplicationContext.SCOPE_SESSION, new SessionScope(false));
beanFactory.registerScope(WebApplicationContext.SCOPE_GLOBAL_SESSION, new SessionScope(true)); bf.registerScope(WebApplicationContext.SCOPE_GLOBAL_SESSION, new SessionScope(true));
if (pc != null) { if (pc != null) {
PortletContextScope appScope = new PortletContextScope(pc); PortletContextScope appScope = new PortletContextScope(pc);
beanFactory.registerScope(WebApplicationContext.SCOPE_APPLICATION, appScope); bf.registerScope(WebApplicationContext.SCOPE_APPLICATION, appScope);
// Register as PortletContext attribute, for ContextCleanupListener to detect it. // Register as PortletContext attribute, for ContextCleanupListener to detect it.
pc.setAttribute(PortletContextScope.class.getName(), appScope); pc.setAttribute(PortletContextScope.class.getName(), appScope);
} }
beanFactory.registerResolvableDependency(PortletRequest.class, new RequestObjectFactory()); bf.registerResolvableDependency(PortletRequest.class, new RequestObjectFactory());
beanFactory.registerResolvableDependency(PortletSession.class, new SessionObjectFactory()); bf.registerResolvableDependency(PortletSession.class, new SessionObjectFactory());
beanFactory.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory()); bf.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory());
} }
/** /**
* Register web-specific environment beans ("contextParameters", "contextAttributes") * Register web-specific environment beans ("contextParameters", "contextAttributes")
* with the given BeanFactory, as used by the Portlet ApplicationContext. * with the given BeanFactory, as used by the Portlet ApplicationContext.
* @param bf the BeanFactory to configure * @param bf the BeanFactory to configure
* @param sc the ServletContext that we're running within * @param servletContext the ServletContext that we're running within
* @param pc the PortletContext that we're running within * @param portletContext the PortletContext that we're running within
* @param config the PortletConfig of the containing Portlet * @param portletConfig the PortletConfig of the containing Portlet
*/ */
static void registerEnvironmentBeans( static void registerEnvironmentBeans(ConfigurableListableBeanFactory bf, ServletContext servletContext,
ConfigurableListableBeanFactory bf, ServletContext sc, PortletContext pc, PortletConfig config) { PortletContext portletContext, PortletConfig portletConfig) {
if (sc != null && !bf.containsBean(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME)) { if (servletContext != null && !bf.containsBean(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME)) {
bf.registerSingleton(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME, sc); bf.registerSingleton(WebApplicationContext.SERVLET_CONTEXT_BEAN_NAME, servletContext);
} }
if (pc != null && !bf.containsBean(ConfigurablePortletApplicationContext.PORTLET_CONTEXT_BEAN_NAME)) { if (portletContext != null && !bf.containsBean(ConfigurablePortletApplicationContext.PORTLET_CONTEXT_BEAN_NAME)) {
bf.registerSingleton(ConfigurablePortletApplicationContext.PORTLET_CONTEXT_BEAN_NAME, pc); bf.registerSingleton(ConfigurablePortletApplicationContext.PORTLET_CONTEXT_BEAN_NAME, portletContext);
} }
if (config != null && !bf.containsBean(ConfigurablePortletApplicationContext.PORTLET_CONFIG_BEAN_NAME)) { if (portletConfig != null && !bf.containsBean(ConfigurablePortletApplicationContext.PORTLET_CONFIG_BEAN_NAME)) {
bf.registerSingleton(ConfigurablePortletApplicationContext.PORTLET_CONFIG_BEAN_NAME, config); bf.registerSingleton(ConfigurablePortletApplicationContext.PORTLET_CONFIG_BEAN_NAME, portletConfig);
} }
if (!bf.containsBean(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME)) { if (!bf.containsBean(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME)) {
Map<String, String> parameterMap = new HashMap<String, String>(); Map<String, String> parameterMap = new HashMap<String, String>();
if (pc != null) { if (portletContext != null) {
Enumeration<String> paramNameEnum = pc.getInitParameterNames(); Enumeration<String> paramNameEnum = portletContext.getInitParameterNames();
while (paramNameEnum.hasMoreElements()) { while (paramNameEnum.hasMoreElements()) {
String paramName = paramNameEnum.nextElement(); String paramName = paramNameEnum.nextElement();
parameterMap.put(paramName, pc.getInitParameter(paramName)); parameterMap.put(paramName, portletContext.getInitParameter(paramName));
} }
} }
if (config != null) { if (portletConfig != null) {
Enumeration<String> paramNameEnum = config.getInitParameterNames(); Enumeration<String> paramNameEnum = portletConfig.getInitParameterNames();
while (paramNameEnum.hasMoreElements()) { while (paramNameEnum.hasMoreElements()) {
String paramName = paramNameEnum.nextElement(); String paramName = paramNameEnum.nextElement();
parameterMap.put(paramName, config.getInitParameter(paramName)); parameterMap.put(paramName, portletConfig.getInitParameter(paramName));
} }
} }
bf.registerSingleton(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME, bf.registerSingleton(WebApplicationContext.CONTEXT_PARAMETERS_BEAN_NAME,
@ -174,11 +172,11 @@ public abstract class PortletApplicationContextUtils {
if (!bf.containsBean(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME)) { if (!bf.containsBean(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME)) {
Map<String, Object> attributeMap = new HashMap<String, Object>(); Map<String, Object> attributeMap = new HashMap<String, Object>();
if (pc != null) { if (portletContext != null) {
Enumeration<String> attrNameEnum = pc.getAttributeNames(); Enumeration<String> attrNameEnum = portletContext.getAttributeNames();
while (attrNameEnum.hasMoreElements()) { while (attrNameEnum.hasMoreElements()) {
String attrName = attrNameEnum.nextElement(); String attrName = attrNameEnum.nextElement();
attributeMap.put(attrName, pc.getAttribute(attrName)); attributeMap.put(attrName, portletContext.getAttribute(attrName));
} }
} }
bf.registerSingleton(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME, bf.registerSingleton(WebApplicationContext.CONTEXT_ATTRIBUTES_BEAN_NAME,

View File

@ -563,20 +563,6 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required.</
programmatically by using one of the programmatically by using one of the
<interfacename>ApplicationContext</interfacename> implementations.</para> <interfacename>ApplicationContext</interfacename> implementations.</para>
<para>The <classname>ContextLoader</classname> mechanism comes in two
flavors: the <classname>ContextLoaderListener</classname> and the
<classname>ContextLoaderServlet</classname>. They have the same
functionality but differ in that the listener version is not reliable in
Servlet 2.3 containers. In the Servlet 2.4 specification, Servlet context
listeners must execute immediately after the Servlet context for the web
application is created and is available to service the first request (and
also when the Servlet context is about to be shut down). As such a Servlet
context listener is an ideal place to initialize the Spring
<interfacename>ApplicationContext</interfacename>. All things being equal,
you should probably prefer <classname>ContextLoaderListener</classname>;
for more information on compatibility, have a look at the Javadoc for the
<classname>ContextLoaderServlet</classname>.</para>
<para>You can register an <interfacename>ApplicationContext</interfacename> <para>You can register an <interfacename>ApplicationContext</interfacename>
using the <classname>ContextLoaderListener</classname> as follows:</para> using the <classname>ContextLoaderListener</classname> as follows:</para>
@ -587,15 +573,7 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required.</
&lt;listener&gt; &lt;listener&gt;
&lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt; &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
&lt;/listener&gt; &lt;/listener&gt;</programlisting>
<lineannotation>&lt;!-- or use the ContextLoaderServlet instead of the above listener</lineannotation><emphasis>
&lt;servlet&gt;
&lt;servlet-name&gt;context&lt;/servlet-name&gt;
&lt;servlet-class&gt;org.springframework.web.context.ContextLoaderServlet&lt;/servlet-class&gt;
&lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
&lt;/servlet&gt;
--</emphasis>&gt;</programlisting>
<para>The listener inspects the <literal>contextConfigLocation</literal> <para>The listener inspects the <literal>contextConfigLocation</literal>
parameter. If the parameter does not exist, the listener uses parameter. If the parameter does not exist, the listener uses
@ -608,11 +586,6 @@ argument.required=Ebagum lad, the '{0}' argument is required, I say, required.</
with "Context.xml", residing in the "WEB-INF" directory, and with "Context.xml", residing in the "WEB-INF" directory, and
<literal>/WEB-INF/**/*Context.xml</literal>, for all such files in any <literal>/WEB-INF/**/*Context.xml</literal>, for all such files in any
subdirectory of "WEB-INF".</para> subdirectory of "WEB-INF".</para>
<para>You can use <classname>ContextLoaderServlet</classname> instead of
<classname>ContextLoaderListener</classname>. The Servlet uses the
<literal>contextConfigLocation</literal> parameter just as the listener
does.</para>
</section> </section>
<section xml:id="context-deploy-rar"> <section xml:id="context-deploy-rar">