提交 c06752ef 编写于 作者: C Chris Beams

Rename {Default=>Standard}Environment

Issue: SPR-8348
上级 615fcff7
......@@ -22,7 +22,7 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.EnvironmentCapable;
import org.springframework.core.io.Resource;
......@@ -54,7 +54,7 @@ public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable
private ClassLoader beanClassLoader;
private Environment environment = new DefaultEnvironment();
private Environment environment = new StandardEnvironment();
private BeanNameGenerator beanNameGenerator = new DefaultBeanNameGenerator();
......@@ -69,7 +69,7 @@ public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable
* {@link org.springframework.core.io.support.PathMatchingResourcePatternResolver}.
* <p>If the the passed-in bean factory also implements {@link EnvironmentCapable} its
* environment will be used by this reader. Otherwise, the reader will initialize and
* use a {@link DefaultEnvironment}. All ApplicationContext implementations are
* use a {@link StandardEnvironment}. All ApplicationContext implementations are
* EnvironmentCapable, while normal BeanFactory implementations are not.
* @param registry the BeanFactory to load bean definitions into,
* in the form of a BeanDefinitionRegistry
......@@ -93,7 +93,7 @@ public abstract class AbstractBeanDefinitionReader implements EnvironmentCapable
this.environment = ((EnvironmentCapable)this.registry).getEnvironment();
}
else {
this.environment = new DefaultEnvironment();
this.environment = new StandardEnvironment();
}
}
......
......@@ -69,7 +69,7 @@ import org.springframework.core.DecoratingClassLoader;
import org.springframework.core.NamedThreadLocal;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.ObjectUtils;
......
......@@ -59,7 +59,7 @@ import org.springframework.beans.factory.support.ManagedProperties;
import org.springframework.beans.factory.support.ManagedSet;
import org.springframework.beans.factory.support.MethodOverrides;
import org.springframework.beans.factory.support.ReplaceOverride;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
......@@ -272,13 +272,13 @@ public class BeanDefinitionParserDelegate {
/**
* Create a new BeanDefinitionParserDelegate associated with the
* supplied {@link XmlReaderContext} and a new {@link DefaultEnvironment}.
* supplied {@link XmlReaderContext} and a new {@link StandardEnvironment}.
* @deprecated since Spring 3.1 in favor of
* {@link #BeanDefinitionParserDelegate(XmlReaderContext, Environment)}
*/
@Deprecated
public BeanDefinitionParserDelegate(XmlReaderContext readerContext) {
this(readerContext, new DefaultEnvironment());
this(readerContext, new StandardEnvironment());
}
/**
......
......@@ -34,7 +34,7 @@ import org.springframework.beans.propertyeditors.InputSourceEditor;
import org.springframework.beans.propertyeditors.InputStreamEditor;
import org.springframework.beans.propertyeditors.URIEditor;
import org.springframework.beans.propertyeditors.URLEditor;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertyResolver;
import org.springframework.core.io.Resource;
......@@ -64,7 +64,7 @@ public class ResourceEditorRegistrar implements PropertyEditorRegistrar {
/**
* Create a new ResourceEditorRegistrar for the given {@link ResourceLoader}
* using a {@link DefaultEnvironment}.
* using a {@link StandardEnvironment}.
* @param resourceLoader the ResourceLoader (or ResourcePatternResolver)
* to create editors for (usually an ApplicationContext)
* @see org.springframework.core.io.support.ResourcePatternResolver
......@@ -74,7 +74,7 @@ public class ResourceEditorRegistrar implements PropertyEditorRegistrar {
*/
@Deprecated
public ResourceEditorRegistrar(ResourceLoader resourceLoader) {
this(resourceLoader, new DefaultEnvironment());
this(resourceLoader, new StandardEnvironment());
}
/**
......
......@@ -6,7 +6,7 @@ import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
......@@ -30,7 +30,7 @@ public class NestedBeansElementTests {
@Test
public void getBean_withActiveProfile() {
ConfigurableEnvironment env = new DefaultEnvironment();
ConfigurableEnvironment env = new StandardEnvironment();
env.setActiveProfiles("dev");
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
......
......@@ -26,7 +26,7 @@ import org.junit.internal.matchers.TypeSafeMatcher;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.ClassPathResource;
/**
......@@ -99,7 +99,7 @@ public class ProfileXmlBeanDefinitionTests {
{
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
ConfigurableEnvironment env = new DefaultEnvironment();
ConfigurableEnvironment env = new StandardEnvironment();
env.setDefaultProfiles("custom-default");
reader.setEnvironment(env);
reader.loadBeanDefinitions(new ClassPathResource(DEFAULT_ELIGIBLE_XML, getClass()));
......@@ -109,7 +109,7 @@ public class ProfileXmlBeanDefinitionTests {
{
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
ConfigurableEnvironment env = new DefaultEnvironment();
ConfigurableEnvironment env = new StandardEnvironment();
env.setDefaultProfiles("custom-default");
reader.setEnvironment(env);
reader.loadBeanDefinitions(new ClassPathResource(CUSTOM_DEFAULT_ELIGIBLE_XML, getClass()));
......@@ -126,7 +126,7 @@ public class ProfileXmlBeanDefinitionTests {
{
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
ConfigurableEnvironment env = new DefaultEnvironment();
ConfigurableEnvironment env = new StandardEnvironment();
env.setActiveProfiles(DEV_ACTIVE);
env.setDefaultProfiles("default");
reader.setEnvironment(env);
......@@ -136,7 +136,7 @@ public class ProfileXmlBeanDefinitionTests {
{
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
ConfigurableEnvironment env = new DefaultEnvironment();
ConfigurableEnvironment env = new StandardEnvironment();
// env.setActiveProfiles(DEV_ACTIVE);
env.setDefaultProfiles("default");
reader.setEnvironment(env);
......@@ -146,7 +146,7 @@ public class ProfileXmlBeanDefinitionTests {
{
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
ConfigurableEnvironment env = new DefaultEnvironment();
ConfigurableEnvironment env = new StandardEnvironment();
// env.setActiveProfiles(DEV_ACTIVE);
//env.setDefaultProfiles("default");
reader.setEnvironment(env);
......@@ -159,7 +159,7 @@ public class ProfileXmlBeanDefinitionTests {
private BeanDefinitionRegistry beanFactoryFor(String xmlName, String... activeProfiles) {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
DefaultEnvironment env = new DefaultEnvironment();
StandardEnvironment env = new StandardEnvironment();
env.setActiveProfiles(activeProfiles);
reader.setEnvironment(env);
reader.loadBeanDefinitions(new ClassPathResource(xmlName, getClass()));
......
......@@ -24,7 +24,7 @@ import org.springframework.beans.factory.support.AutowireCandidateQualifier;
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotationMetadata;
......@@ -42,7 +42,7 @@ public class AnnotatedBeanDefinitionReader {
private final BeanDefinitionRegistry registry;
private Environment environment = new DefaultEnvironment();
private Environment environment = new StandardEnvironment();
private BeanNameGenerator beanNameGenerator = new AnnotationBeanNameGenerator();
......@@ -70,7 +70,7 @@ public class AnnotatedBeanDefinitionReader {
/**
* Set the Environment to use when evaluating whether
* {@link Profile @Profile}-annotated component classes should be registered.
* <p>The default is a {@link DefaultEnvironment}.
* <p>The default is a {@link StandardEnvironment}.
* @see #registerBean(Class, String, Class...)
*/
public void setEnvironment(Environment environment) {
......
......@@ -91,8 +91,9 @@ public class ClassPathBeanDefinitionScanner extends ClassPathScanningCandidateCo
* {@link org.springframework.core.io.support.PathMatchingResourcePatternResolver}.
* <p>If the the passed-in bean factory also implements {@link EnvironmentCapable} its
* environment will be used by this reader. Otherwise, the reader will initialize and
* use a {@link DefaultEnvironment}. All ApplicationContext implementations are
* EnvironmentCapable, while normal BeanFactory implementations are not.
* use a {@link org.springframework.core.env.StandardEnvironment}. All
* ApplicationContext implementations are EnvironmentCapable, while normal BeanFactory
* implementations are not.
* @param registry the BeanFactory to load bean definitions into,
* in the form of a BeanDefinitionRegistry
* @param useDefaultFilters whether to include the default filters for the
......
......@@ -29,7 +29,7 @@ import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.EnvironmentCapable;
import org.springframework.core.io.Resource;
......@@ -73,7 +73,7 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC
protected final Log logger = LogFactory.getLog(getClass());
private Environment environment = new DefaultEnvironment();
private Environment environment = new StandardEnvironment();
private ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
......@@ -117,7 +117,7 @@ public class ClassPathScanningCandidateComponentProvider implements EnvironmentC
/**
* Set the Environment to use when resolving placeholders and evaluating
* {@link Profile @Profile}-annotated component classes.
* <p>The default is a {@link DefaultEnvironment}
* <p>The default is a {@link StandardEnvironment}
* @param environment the Environment to use
*/
public void setEnvironment(Environment environment) {
......
......@@ -73,7 +73,7 @@ import org.springframework.core.Ordered;
import org.springframework.core.PriorityOrdered;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
......@@ -410,12 +410,12 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
}
/**
* Create and return a new {@link DefaultEnvironment}.
* Create and return a new {@link StandardEnvironment}.
* <p>Subclasses may override this method in order to supply
* a custom {@link ConfigurableEnvironment} implementation.
*/
protected ConfigurableEnvironment createEnvironment() {
return new DefaultEnvironment();
return new StandardEnvironment();
}
public void refresh() throws BeansException, IllegalStateException {
......
......@@ -17,7 +17,7 @@ package org.springframework.context.annotation;
import org.springframework.beans.factory.parsing.FailFastProblemReporter;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
......@@ -38,7 +38,7 @@ public class AsmCircularImportDetectionTests extends AbstractCircularImportDetec
return new ConfigurationClassParser(
new CachingMetadataReaderFactory(),
new FailFastProblemReporter(),
new DefaultEnvironment(),
new StandardEnvironment(),
new DefaultResourceLoader(),
new DefaultListableBeanFactory());
}
......
......@@ -30,7 +30,7 @@ import org.aspectj.lang.annotation.Aspect;
import org.junit.Test;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.type.filter.AnnotationTypeFilter;
import org.springframework.core.type.filter.AssignableTypeFilter;
import org.springframework.core.type.filter.RegexPatternTypeFilter;
......@@ -175,7 +175,7 @@ public class ClassPathScanningCandidateComponentProviderTests {
@Test
public void testWithInactiveProfile() {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
ConfigurableEnvironment env = new DefaultEnvironment();
ConfigurableEnvironment env = new StandardEnvironment();
env.setActiveProfiles("other");
provider.setEnvironment(env);
Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_PROFILE_PACKAGE);
......@@ -185,7 +185,7 @@ public class ClassPathScanningCandidateComponentProviderTests {
@Test
public void testWithActiveProfile() {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
ConfigurableEnvironment env = new DefaultEnvironment();
ConfigurableEnvironment env = new StandardEnvironment();
env.setActiveProfiles(ProfileAnnotatedComponent.PROFILE_NAME);
provider.setEnvironment(env);
Set<BeanDefinition> candidates = provider.findCandidateComponents(TEST_PROFILE_PACKAGE);
......
......@@ -28,7 +28,7 @@ import java.util.Properties;
import org.junit.Test;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.ClassPathResource;
......@@ -233,7 +233,7 @@ public class PropertySourcesPlaceholderConfigurerTests {
System.setProperty("key1", "systemKey1Value");
System.setProperty("key2", "systemKey2Value");
ppc.setEnvironment(new DefaultEnvironment());
ppc.setEnvironment(new StandardEnvironment());
ppc.postProcessBeanFactory(bf);
System.clearProperty("key1");
System.clearProperty("key2");
......
......@@ -41,7 +41,7 @@ import org.springframework.util.StringUtils;
*
* @author Chris Beams
* @since 3.1
* @see DefaultEnvironment
* @see StandardEnvironment
*/
public abstract class AbstractEnvironment implements ConfigurableEnvironment {
......
......@@ -25,7 +25,7 @@ import java.util.Map;
*
* @author Chris Beams
* @since 3.1
* @see DefaultEnvironment
* @see StandardEnvironment
* @see org.springframework.context.ConfigurableApplicationContext#getEnvironment
*/
public interface ConfigurableEnvironment extends Environment, ConfigurablePropertyResolver {
......@@ -61,7 +61,7 @@ public interface ConfigurableEnvironment extends Environment, ConfigurableProper
* certain user-defined property sources have search precedence over default property
* sources such as the set of system properties or the set of system environment
* variables.
* @see DefaultEnvironment#DefaultEnvironment()
* @see AbstractEnvironment#customizePropertySources
*/
MutablePropertySources getPropertySources();
......
......@@ -52,7 +52,7 @@ package org.springframework.core.env;
* <p>Configuration of the environment object must be done through the
* {@link ConfigurableEnvironment} interface, returned from all
* {@code AbstractApplicationContext} subclass {@code getEnvironment()} methods. See
* {@link DefaultEnvironment} for several examples of using the ConfigurableEnvironment
* {@link StandardEnvironment} for several examples of using the ConfigurableEnvironment
* interface to manipulate property sources prior to application context refresh().
*
* @author Chris Beams
......@@ -61,7 +61,7 @@ package org.springframework.core.env;
* @see EnvironmentCapable
* @see ConfigurableEnvironment
* @see AbstractEnvironment
* @see DefaultEnvironment
* @see StandardEnvironment
* @see org.springframework.context.EnvironmentAware
* @see org.springframework.context.ConfigurableApplicationContext#getEnvironment
* @see org.springframework.context.ConfigurableApplicationContext#setEnvironment
......
......@@ -41,7 +41,7 @@ package org.springframework.core.env;
*
* <h4>Example: adding a new property source with highest search priority</h4>
* <pre class="code">
* ConfigurableEnvironment environment = new DefaultEnvironment();
* ConfigurableEnvironment environment = new StandardEnvironment();
* MutablePropertySources propertySources = environment.getPropertySources();
* Map<String, String> myMap = new HashMap<String, String>();
* myMap.put("xyz", "myValue");
......@@ -51,14 +51,14 @@ package org.springframework.core.env;
* <h4>Example: removing the default system properties property source</h4>
* <pre class="code">
* MutablePropertySources propertySources = environment.getPropertySources();
* propertySources.remove(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)
* propertySources.remove(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)
* </pre>
*
* <h4>Example: mocking the system environment for testing purposes</h4>
* <pre class="code">
* MutablePropertySources propertySources = environment.getPropertySources();
* MockPropertySource mockEnvVars = new MockPropertySource().withProperty("xyz", "myValue");
* propertySources.replace(DefaultEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, mockEnvVars);
* propertySources.replace(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, mockEnvVars);
* </pre>
*
* When an {@link Environment} is being used by an ApplicationContext, it is important
......@@ -73,7 +73,7 @@ package org.springframework.core.env;
* @see ConfigurableEnvironment
* @see org.springframework.web.context.support.DefaultWebEnvironment
*/
public class DefaultEnvironment extends AbstractEnvironment {
public class StandardEnvironment extends AbstractEnvironment {
/** System environment property source name: {@value} */
public static final String SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME = "systemEnvironment";
......
......@@ -19,7 +19,7 @@ package org.springframework.core.io;
import java.beans.PropertyEditorSupport;
import java.io.IOException;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.env.PropertyResolver;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
......@@ -58,22 +58,22 @@ public class ResourceEditor extends PropertyEditorSupport {
/**
* Create a new instance of the {@link ResourceEditor} class
* using a {@link DefaultResourceLoader} and {@link DefaultEnvironment}.
* using a {@link DefaultResourceLoader} and {@link StandardEnvironment}.
*/
public ResourceEditor() {
this(new DefaultResourceLoader(), new DefaultEnvironment());
this(new DefaultResourceLoader(), new StandardEnvironment());
}
/**
* Create a new instance of the {@link ResourceEditor} class
* using the given {@link ResourceLoader} and a {@link DefaultEnvironment}.
* using the given {@link ResourceLoader} and a {@link StandardEnvironment}.
* @param resourceLoader the <code>ResourceLoader</code> to use
* @deprecated as of Spring 3.1 in favor of
* {@link #ResourceEditor(ResourceLoader, PropertyResolver)}
*/
@Deprecated
public ResourceEditor(ResourceLoader resourceLoader) {
this(resourceLoader, new DefaultEnvironment(), true);
this(resourceLoader, new StandardEnvironment(), true);
}
/**
......@@ -97,7 +97,7 @@ public class ResourceEditor extends PropertyEditorSupport {
*/
@Deprecated
public ResourceEditor(ResourceLoader resourceLoader, boolean ignoreUnresolvablePlaceholders) {
this(resourceLoader, new DefaultEnvironment(), ignoreUnresolvablePlaceholders);
this(resourceLoader, new StandardEnvironment(), ignoreUnresolvablePlaceholders);
}
/**
......
......@@ -25,7 +25,7 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertyResolver;
import org.springframework.core.io.Resource;
......@@ -64,23 +64,23 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport {
/**
* Create a new ResourceArrayPropertyEditor with a default
* {@link PathMatchingResourcePatternResolver} and {@link DefaultEnvironment}.
* {@link PathMatchingResourcePatternResolver} and {@link StandardEnvironment}.
* @see PathMatchingResourcePatternResolver
* @see Environment
*/
public ResourceArrayPropertyEditor() {
this(new PathMatchingResourcePatternResolver(), new DefaultEnvironment(), true);
this(new PathMatchingResourcePatternResolver(), new StandardEnvironment(), true);
}
/**
* Create a new ResourceArrayPropertyEditor with the given {@link ResourcePatternResolver}
* and a {@link DefaultEnvironment}.
* and a {@link StandardEnvironment}.
* @param resourcePatternResolver the ResourcePatternResolver to use
* @deprecated as of 3.1 in favor of {@link #ResourceArrayPropertyEditor(ResourcePatternResolver, Environment)}
*/
@Deprecated
public ResourceArrayPropertyEditor(ResourcePatternResolver resourcePatternResolver) {
this(resourcePatternResolver, new DefaultEnvironment(), true);
this(resourcePatternResolver, new StandardEnvironment(), true);
}
/**
......@@ -95,7 +95,7 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport {
/**
* Create a new ResourceArrayPropertyEditor with the given {@link ResourcePatternResolver}
* and a {@link DefaultEnvironment}.
* and a {@link StandardEnvironment}.
* @param resourcePatternResolver the ResourcePatternResolver to use
* @param ignoreUnresolvablePlaceholders whether to ignore unresolvable placeholders
* if no corresponding system property could be found
......@@ -103,7 +103,7 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport {
*/
@Deprecated
public ResourceArrayPropertyEditor(ResourcePatternResolver resourcePatternResolver, boolean ignoreUnresolvablePlaceholders) {
this(resourcePatternResolver, new DefaultEnvironment(), ignoreUnresolvablePlaceholders);
this(resourcePatternResolver, new StandardEnvironment(), ignoreUnresolvablePlaceholders);
}
/**
......
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2011 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.
......@@ -43,7 +43,7 @@ import org.junit.Test;
import org.springframework.mock.env.MockPropertySource;
/**
* Unit tests for {@link DefaultEnvironment}.
* Unit tests for {@link StandardEnvironment}.
*
* @author Chris Beams
*/
......@@ -60,14 +60,14 @@ public class EnvironmentTests {
private static final Object NON_STRING_PROPERTY_NAME = new Object();
private static final Object NON_STRING_PROPERTY_VALUE = new Object();
private ConfigurableEnvironment environment = new DefaultEnvironment();
private ConfigurableEnvironment environment = new StandardEnvironment();
@Test
public void propertySourceOrder() {
ConfigurableEnvironment env = new DefaultEnvironment();
ConfigurableEnvironment env = new StandardEnvironment();
MutablePropertySources sources = env.getPropertySources();
assertThat(sources.precedenceOf(PropertySource.named(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)), equalTo(0));
assertThat(sources.precedenceOf(PropertySource.named(DefaultEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)), equalTo(1));
assertThat(sources.precedenceOf(PropertySource.named(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)), equalTo(0));
assertThat(sources.precedenceOf(PropertySource.named(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)), equalTo(1));
assertThat(sources.size(), is(2));
}
......
......@@ -20,7 +20,7 @@ import java.beans.PropertyEditor;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
/**
* Unit tests for the {@link ResourceEditor} class.
......@@ -75,7 +75,7 @@ public final class ResourceEditorTests {
@Test(expected=IllegalArgumentException.class)
public void testStrictSystemPropertyReplacement() {
PropertyEditor editor = new ResourceEditor(new DefaultResourceLoader(), new DefaultEnvironment(), false);
PropertyEditor editor = new ResourceEditor(new DefaultResourceLoader(), new StandardEnvironment(), false);
System.setProperty("test.prop", "foo");
try {
editor.setAsText("${test.prop}-${bar}");
......
......@@ -85,7 +85,7 @@ import org.springframework.web.portlet.context.XmlPortletApplicationContext;
*
* Tests all existing BeanFactory and ApplicationContext implementations to
* ensure that:
* - a default environment object is always present
* - a standard environment object is always present
* - a custom environment object can be set and retrieved against the factory/context
* - the {@link EnvironmentAware} interface is respected
* - the environment object is registered with the container as a singleton
......@@ -120,21 +120,21 @@ public class EnvironmentIntegrationTests {
@Before
public void setUp() {
prodEnv = new DefaultEnvironment();
prodEnv = new StandardEnvironment();
prodEnv.setActiveProfiles(PROD_ENV_NAME);
devEnv = new DefaultEnvironment();
devEnv = new StandardEnvironment();
devEnv.setActiveProfiles(DEV_ENV_NAME);
}
@Test
public void genericApplicationContext_defaultEnv() {
public void genericApplicationContext_standardEnv() {
ConfigurableApplicationContext ctx =
new GenericApplicationContext(newBeanFactoryWithEnvironmentAwareBean());
ctx.refresh();
assertHasDefaultEnvironment(ctx);
assertHasStandardEnvironment(ctx);
assertEnvironmentBeanRegistered(ctx);
assertEnvironmentAwareInvoked(ctx, ctx.getEnvironment());
}
......@@ -199,7 +199,7 @@ public class EnvironmentIntegrationTests {
public void genericXmlApplicationContext() {
GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
assertHasDefaultEnvironment(ctx);
assertHasStandardEnvironment(ctx);
ctx.setEnvironment(prodEnv);
......@@ -249,7 +249,7 @@ public class EnvironmentIntegrationTests {
public void annotationConfigApplicationContext_withPojos() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
assertHasDefaultEnvironment(ctx);
assertHasStandardEnvironment(ctx);
ctx.setEnvironment(prodEnv);
ctx.register(EnvironmentAwareBean.class);
......@@ -262,7 +262,7 @@ public class EnvironmentIntegrationTests {
public void annotationConfigApplicationContext_withProdEnvAndProdConfigClass() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
assertHasDefaultEnvironment(ctx);
assertHasStandardEnvironment(ctx);
ctx.setEnvironment(prodEnv);
ctx.register(ProdConfig.class);
......@@ -275,7 +275,7 @@ public class EnvironmentIntegrationTests {
public void annotationConfigApplicationContext_withProdEnvAndDevConfigClass() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
assertHasDefaultEnvironment(ctx);
assertHasStandardEnvironment(ctx);
ctx.setEnvironment(prodEnv);
ctx.register(DevConfig.class);
......@@ -289,7 +289,7 @@ public class EnvironmentIntegrationTests {
public void annotationConfigApplicationContext_withDevEnvAndDevConfigClass() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
assertHasDefaultEnvironment(ctx);
assertHasStandardEnvironment(ctx);
ctx.setEnvironment(devEnv);
ctx.register(DevConfig.class);
......@@ -303,7 +303,7 @@ public class EnvironmentIntegrationTests {
public void annotationConfigApplicationContext_withImportedConfigClasses() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
assertHasDefaultEnvironment(ctx);
assertHasStandardEnvironment(ctx);
ctx.setEnvironment(prodEnv);
ctx.register(Config.class);
......@@ -318,7 +318,7 @@ public class EnvironmentIntegrationTests {
@Test
public void mostSpecificDerivedClassDrivesEnvironment_withDerivedDevEnvAndDerivedDevConfigClass() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
DefaultEnvironment derivedDevEnv = new DefaultEnvironment();
StandardEnvironment derivedDevEnv = new StandardEnvironment();
derivedDevEnv.setActiveProfiles(DERIVED_DEV_ENV_NAME);
ctx.setEnvironment(derivedDevEnv);
ctx.register(DerivedDevConfig.class);
......@@ -374,7 +374,7 @@ public class EnvironmentIntegrationTests {
public void staticApplicationContext() {
StaticApplicationContext ctx = new StaticApplicationContext();
assertHasDefaultEnvironment(ctx);
assertHasStandardEnvironment(ctx);
registerEnvironmentBeanDefinition(ctx);
......@@ -446,13 +446,13 @@ public class EnvironmentIntegrationTests {
// Servlet* PropertySources have precedence over System* PropertySources
assertThat(propertySources.precedenceOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME)),
lessThan(propertySources.precedenceOf(PropertySource.named(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME))));
lessThan(propertySources.precedenceOf(PropertySource.named(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME))));
// Replace system properties with a mock property source for convenience
MockPropertySource mockSystemProperties = new MockPropertySource(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME);
MockPropertySource mockSystemProperties = new MockPropertySource(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME);
mockSystemProperties.setProperty("pCommon", "pCommonSysPropsValue");
mockSystemProperties.setProperty("pSysProps1", "pSysProps1Value");
propertySources.replace(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, mockSystemProperties);
propertySources.replace(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, mockSystemProperties);
// assert that servletconfig params resolve with higher precedence than sysprops
assertThat(environment.getProperty("pCommon"), is("pCommonConfigValue"));
......@@ -480,13 +480,13 @@ public class EnvironmentIntegrationTests {
// Servlet* PropertySources have precedence over System* PropertySources
assertThat(propertySources.precedenceOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME)),
lessThan(propertySources.precedenceOf(PropertySource.named(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME))));
lessThan(propertySources.precedenceOf(PropertySource.named(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME))));
// Replace system properties with a mock property source for convenience
MockPropertySource mockSystemProperties = new MockPropertySource(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME);
MockPropertySource mockSystemProperties = new MockPropertySource(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME);
mockSystemProperties.setProperty("pCommon", "pCommonSysPropsValue");
mockSystemProperties.setProperty("pSysProps1", "pSysProps1Value");
propertySources.replace(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, mockSystemProperties);
propertySources.replace(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, mockSystemProperties);
// assert that servletcontext init params resolve with higher precedence than sysprops
assertThat(environment.getProperty("pCommon"), is("pCommonContextValue"));
......@@ -523,13 +523,13 @@ public class EnvironmentIntegrationTests {
// Servlet* PropertySources have precedence over System* PropertySources
assertThat(propertySources.precedenceOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME)),
lessThan(propertySources.precedenceOf(PropertySource.named(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME))));
lessThan(propertySources.precedenceOf(PropertySource.named(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME))));
// Replace system properties with a mock property source for convenience
MockPropertySource mockSystemProperties = new MockPropertySource(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME);
MockPropertySource mockSystemProperties = new MockPropertySource(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME);
mockSystemProperties.setProperty("pCommon", "pCommonSysPropsValue");
mockSystemProperties.setProperty("pSysProps1", "pSysProps1Value");
propertySources.replace(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, mockSystemProperties);
propertySources.replace(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, mockSystemProperties);
// assert that servletconfig params resolve with higher precedence than sysprops
assertThat(environment.getProperty("pCommon"), is("pCommonConfigValue"));
......@@ -540,7 +540,7 @@ public class EnvironmentIntegrationTests {
public void resourceAdapterApplicationContext() {
ResourceAdapterApplicationContext ctx = new ResourceAdapterApplicationContext(new SimpleBootstrapContext(new SimpleTaskWorkManager()));
assertHasDefaultEnvironment(ctx);
assertHasStandardEnvironment(ctx);
registerEnvironmentBeanDefinition(ctx);
......@@ -626,10 +626,10 @@ public class EnvironmentIntegrationTests {
assertThat(ctx.containsBean(ENVIRONMENT_BEAN_NAME), is(true));
}
private void assertHasDefaultEnvironment(ApplicationContext ctx) {
private void assertHasStandardEnvironment(ApplicationContext ctx) {
Environment defaultEnv = ctx.getEnvironment();
assertThat(defaultEnv, notNullValue());
assertThat(defaultEnv, instanceOf(DefaultEnvironment.class));
assertThat(defaultEnv, instanceOf(StandardEnvironment.class));
}
private void assertHasDefaultWebEnvironment(WebApplicationContext ctx) {
......
......@@ -32,7 +32,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.util.StringUtils;
/**
......@@ -144,12 +144,12 @@ public class SpringContextResourceAdapter implements ResourceAdapter {
}
/**
* Return a new {@link DefaultEnvironment}.
* Return a new {@link StandardEnvironment}.
* <p>Subclasses may override this method in order to supply
* a custom {@link ConfigurableEnvironment} implementation.
*/
protected ConfigurableEnvironment createEnvironment() {
return new DefaultEnvironment();
return new StandardEnvironment();
}
/**
......
......@@ -20,7 +20,7 @@ import javax.portlet.PortletConfig;
import javax.portlet.PortletContext;
import javax.servlet.ServletContext;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySource;
......@@ -38,10 +38,10 @@ import org.springframework.web.context.support.DefaultWebEnvironment;
*
* @author Chris Beams
* @since 3.1
* @see DefaultEnvironment
* @see StandardEnvironment
* @see DefaultWebEnvironment
*/
public class DefaultPortletEnvironment extends DefaultEnvironment {
public class DefaultPortletEnvironment extends StandardEnvironment {
/** Portlet context init parameters property source name: {@value} */
public static final String PORTLET_CONTEXT_PROPERTY_SOURCE_NAME = "portletContextInitParams";
......@@ -62,12 +62,12 @@ public class DefaultPortletEnvironment extends DefaultEnvironment {
* which takes precedence over those in
* {@linkplain DefaultWebEnvironment#SERVLET_CONTEXT_PROPERTY_SOURCE_NAME "servletContextInitParams"}.
* <p>Properties in any of the above will take precedence over system properties and environment
* variables contributed by the {@link DefaultEnvironment} superclass.
* variables contributed by the {@link StandardEnvironment} superclass.
* <p>The property sources are added as stubs for now, and will be
* {@linkplain PortletApplicationContextUtils#initPortletPropertySources fully initialized}
* once the actual {@link PortletConfig}, {@link PortletContext}, and {@link ServletContext}
* objects are available.
* @see DefaultEnvironment#customizePropertySources
* @see StandardEnvironment#customizePropertySources
* @see PortletConfigPropertySource
* @see PortletContextPropertySource
* @see AbstractRefreshablePortletApplicationContext#initPropertySources
......
......@@ -19,7 +19,7 @@ package org.springframework.web.context.support;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySource;
......@@ -42,10 +42,10 @@ import org.springframework.jndi.JndiPropertySource;
*
* @author Chris Beams
* @since 3.1
* @see DefaultEnvironment
* @see StandardEnvironment
* @see DefaultPortletEnvironment
*/
public class DefaultWebEnvironment extends DefaultEnvironment {
public class DefaultWebEnvironment extends StandardEnvironment {
/** Servlet context init parameters property source name: {@value} */
public static final String SERVLET_CONTEXT_PROPERTY_SOURCE_NAME = "servletContextInitParams";
......@@ -64,7 +64,7 @@ public class DefaultWebEnvironment extends DefaultEnvironment {
* <p>Properties present in {@value #SERVLET_CONFIG_PROPERTY_SOURCE_NAME} will
* take precedence over those in {@value #SERVLET_CONTEXT_PROPERTY_SOURCE_NAME}.
* <p>Properties in any of the above will take precedence over system properties and environment
* variables contributed by the {@link DefaultEnvironment} superclass.
* variables contributed by the {@link StandardEnvironment} superclass.
* <p>The {@code Servlet}-related property sources are added as stubs for now, and will be
* {@linkplain WebApplicationContextUtils#initServletPropertySources fully initialized}
* once the actual {@link ServletConfig} and {@link ServletContext} objects are available.
......@@ -72,7 +72,7 @@ public class DefaultWebEnvironment extends DefaultEnvironment {
* property is present in any of the default property sources, a {@link JndiPropertySource} will
* be added as well, with precedence lower than servlet property sources, but higher than system
* properties and environment variables.
* @see DefaultEnvironment#customizePropertySources
* @see StandardEnvironment#customizePropertySources
* @see ServletConfigPropertySource
* @see ServletContextPropertySource
* @see org.springframework.jndi.JndiPropertySource
......
......@@ -22,7 +22,7 @@ import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.DefaultEnvironment;
import org.springframework.core.env.StandardEnvironment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySource;
import org.springframework.jndi.JndiPropertySource;
......@@ -35,8 +35,8 @@ public class DefaultWebEnvironmentTests {
MutablePropertySources sources = env.getPropertySources();
assertThat(sources.precedenceOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME)), equalTo(0));
assertThat(sources.precedenceOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME)), equalTo(1));
assertThat(sources.precedenceOf(PropertySource.named(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)), equalTo(2));
assertThat(sources.precedenceOf(PropertySource.named(DefaultEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)), equalTo(3));
assertThat(sources.precedenceOf(PropertySource.named(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)), equalTo(2));
assertThat(sources.precedenceOf(PropertySource.named(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)), equalTo(3));
assertThat(sources.size(), is(4));
}
......@@ -49,8 +49,8 @@ public class DefaultWebEnvironmentTests {
assertThat(sources.precedenceOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME)), equalTo(0));
assertThat(sources.precedenceOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME)), equalTo(1));
assertThat(sources.precedenceOf(PropertySource.named(JndiPropertySource.JNDI_PROPERTY_SOURCE_NAME)), equalTo(2));
assertThat(sources.precedenceOf(PropertySource.named(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)), equalTo(3));
assertThat(sources.precedenceOf(PropertySource.named(DefaultEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)), equalTo(4));
assertThat(sources.precedenceOf(PropertySource.named(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)), equalTo(3));
assertThat(sources.precedenceOf(PropertySource.named(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)), equalTo(4));
assertThat(sources.size(), is(5));
System.clearProperty(JndiPropertySource.JNDI_PROPERTY_SOURCE_ENABLED_FLAG);
......@@ -65,8 +65,8 @@ public class DefaultWebEnvironmentTests {
assertThat(sources.precedenceOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME)), equalTo(0));
assertThat(sources.precedenceOf(PropertySource.named(DefaultWebEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME)), equalTo(1));
//assertThat(sources.precedenceOf(PropertySource.named(JndiPropertySource.JNDI_PROPERTY_SOURCE_NAME)), equalTo(2));
assertThat(sources.precedenceOf(PropertySource.named(DefaultEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)), equalTo(2));
assertThat(sources.precedenceOf(PropertySource.named(DefaultEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)), equalTo(3));
assertThat(sources.precedenceOf(PropertySource.named(StandardEnvironment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)), equalTo(2));
assertThat(sources.precedenceOf(PropertySource.named(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)), equalTo(3));
assertThat(sources.size(), is(4));
System.clearProperty(JndiPropertySource.JNDI_PROPERTY_SOURCE_ENABLED_FLAG);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册