Polishing
This commit is contained in:
@@ -197,11 +197,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -183,11 +183,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";
|
||||
@@ -92,8 +91,7 @@ public class StandardServletEnvironment extends StandardEnvironment
|
||||
|
||||
@Override
|
||||
public void initPropertySources(ServletContext servletContext, ServletConfig servletConfig) {
|
||||
WebApplicationContextUtils.initServletPropertySources(
|
||||
this.getPropertySources(), servletContext, servletConfig);
|
||||
WebApplicationContextUtils.initServletPropertySources(getPropertySources(), servletContext, servletConfig);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -186,9 +186,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);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -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;
|
||||
@@ -259,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