Polishing
This commit is contained in:
@@ -201,11 +201,9 @@ public abstract class AbstractRefreshableWebApplicationContext extends AbstractR
|
||||
*/
|
||||
@Override
|
||||
protected void initPropertySources() {
|
||||
super.initPropertySources();
|
||||
ConfigurableEnvironment env = this.getEnvironment();
|
||||
ConfigurableEnvironment env = getEnvironment();
|
||||
if (env instanceof ConfigurableWebEnvironment) {
|
||||
((ConfigurableWebEnvironment)env).initPropertySources(
|
||||
this.servletContext, this.servletConfig);
|
||||
((ConfigurableWebEnvironment) env).initPropertySources(this.servletContext, this.servletConfig);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.ui.context.Theme;
|
||||
import org.springframework.ui.context.ThemeSource;
|
||||
import org.springframework.ui.context.support.UiApplicationContextUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.context.ConfigurableWebApplicationContext;
|
||||
@@ -192,11 +191,9 @@ public class GenericWebApplicationContext extends GenericApplicationContext
|
||||
*/
|
||||
@Override
|
||||
protected void initPropertySources() {
|
||||
super.initPropertySources();
|
||||
ConfigurableEnvironment env = this.getEnvironment();
|
||||
ConfigurableEnvironment env = getEnvironment();
|
||||
if (env instanceof ConfigurableWebEnvironment) {
|
||||
((ConfigurableWebEnvironment)env).initPropertySources(
|
||||
this.servletContext, null);
|
||||
((ConfigurableWebEnvironment) env).initPropertySources(this.servletContext, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,8 +41,7 @@ import org.springframework.web.context.ConfigurableWebEnvironment;
|
||||
* @since 3.1
|
||||
* @see StandardEnvironment
|
||||
*/
|
||||
public class StandardServletEnvironment extends StandardEnvironment
|
||||
implements ConfigurableWebEnvironment {
|
||||
public class StandardServletEnvironment extends StandardEnvironment implements ConfigurableWebEnvironment {
|
||||
|
||||
/** Servlet context init parameters property source name: {@value} */
|
||||
public static final String SERVLET_CONTEXT_PROPERTY_SOURCE_NAME = "servletContextInitParams";
|
||||
@@ -91,8 +90,7 @@ public class StandardServletEnvironment extends StandardEnvironment
|
||||
}
|
||||
|
||||
public void initPropertySources(ServletContext servletContext, ServletConfig servletConfig) {
|
||||
WebApplicationContextUtils.initServletPropertySources(
|
||||
this.getPropertySources(), servletContext, servletConfig);
|
||||
WebApplicationContextUtils.initServletPropertySources(getPropertySources(), servletContext, servletConfig);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -177,9 +177,8 @@ public class StaticWebApplicationContext extends StaticApplicationContext
|
||||
|
||||
@Override
|
||||
protected void initPropertySources() {
|
||||
super.initPropertySources();
|
||||
WebApplicationContextUtils.initServletPropertySources(
|
||||
this.getEnvironment().getPropertySources(), this.servletContext, this.servletConfig);
|
||||
WebApplicationContextUtils.initServletPropertySources(getEnvironment().getPropertySources(),
|
||||
this.servletContext, this.servletConfig);
|
||||
}
|
||||
|
||||
public Theme getTheme(String themeName) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,15 +16,11 @@
|
||||
|
||||
package org.springframework.web.context.support;
|
||||
|
||||
import static org.springframework.web.context.support.StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME;
|
||||
import static org.springframework.web.context.support.StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.ServletConfig;
|
||||
@@ -51,11 +47,11 @@ import org.springframework.web.context.request.WebRequest;
|
||||
/**
|
||||
* Convenience methods for retrieving the root
|
||||
* {@link org.springframework.web.context.WebApplicationContext} for a given
|
||||
* {@code ServletContext}. This is e.g. useful for accessing a Spring
|
||||
* context from within custom web views or Struts actions.
|
||||
* {@code ServletContext}. This is useful for programmatically accessing a
|
||||
* Spring application context from within custom web views or MVC actions.
|
||||
*
|
||||
* <p>Note that there are more convenient ways of accessing the root context for
|
||||
* many web frameworks, either part of Spring or available as external library.
|
||||
* many web frameworks, either part of Spring or available as an external library.
|
||||
* This helper class is just the most generic way to access the root context.
|
||||
*
|
||||
* @author Juergen Hoeller
|
||||
@@ -63,7 +59,6 @@ import org.springframework.web.context.request.WebRequest;
|
||||
* @see org.springframework.web.servlet.FrameworkServlet
|
||||
* @see org.springframework.web.servlet.DispatcherServlet
|
||||
* @see org.springframework.web.jsf.FacesContextUtils
|
||||
* @see org.springframework.web.jsf.SpringBeanVariableResolver
|
||||
* @see org.springframework.web.jsf.el.SpringBeanFacesELResolver
|
||||
*/
|
||||
public abstract class WebApplicationContextUtils {
|
||||
@@ -260,16 +255,17 @@ public abstract class WebApplicationContextUtils {
|
||||
*/
|
||||
public static void initServletPropertySources(
|
||||
MutablePropertySources propertySources, ServletContext servletContext, ServletConfig servletConfig) {
|
||||
|
||||
Assert.notNull(propertySources, "propertySources must not be null");
|
||||
if(servletContext != null &&
|
||||
propertySources.contains(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME) &&
|
||||
propertySources.get(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME) instanceof StubPropertySource) {
|
||||
propertySources.replace(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, new ServletContextPropertySource(SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, servletContext));
|
||||
if (servletContext != null && propertySources.contains(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME) &&
|
||||
propertySources.get(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME) instanceof StubPropertySource) {
|
||||
propertySources.replace(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME,
|
||||
new ServletContextPropertySource(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME, servletContext));
|
||||
}
|
||||
if(servletConfig != null &&
|
||||
propertySources.contains(SERVLET_CONFIG_PROPERTY_SOURCE_NAME) &&
|
||||
propertySources.get(SERVLET_CONFIG_PROPERTY_SOURCE_NAME) instanceof StubPropertySource) {
|
||||
propertySources.replace(SERVLET_CONFIG_PROPERTY_SOURCE_NAME, new ServletConfigPropertySource(SERVLET_CONFIG_PROPERTY_SOURCE_NAME, servletConfig));
|
||||
if (servletConfig != null && propertySources.contains(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME) &&
|
||||
propertySources.get(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME) instanceof StubPropertySource) {
|
||||
propertySources.replace(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME,
|
||||
new ServletConfigPropertySource(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME, servletConfig));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user