Rename {Default=>Standard}Environment
Issue: SPR-8348
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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}");
|
||||
|
||||
Reference in New Issue
Block a user