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