Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dk131072
spring-framework
提交
c06752ef
S
spring-framework
项目概览
dk131072
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c06752ef
编写于
5月 20, 2011
作者:
C
Chris Beams
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename {Default=>Standard}Environment
Issue: SPR-8348
上级
615fcff7
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
114 addition
and
113 deletion
+114
-113
org.springframework.beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinitionReader.java
...k/beans/factory/support/AbstractBeanDefinitionReader.java
+4
-4
org.springframework.beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
...gframework/beans/factory/support/AbstractBeanFactory.java
+1
-1
org.springframework.beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java
...ework/beans/factory/xml/BeanDefinitionParserDelegate.java
+3
-3
org.springframework.beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java
...pringframework/beans/support/ResourceEditorRegistrar.java
+3
-3
org.springframework.beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementTests.java
...gframework/beans/factory/xml/NestedBeansElementTests.java
+2
-2
org.springframework.beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java
...work/beans/factory/xml/ProfileXmlBeanDefinitionTests.java
+7
-7
org.springframework.context/src/main/java/org/springframework/context/annotation/AnnotatedBeanDefinitionReader.java
...ork/context/annotation/AnnotatedBeanDefinitionReader.java
+3
-3
org.springframework.context/src/main/java/org/springframework/context/annotation/ClassPathBeanDefinitionScanner.java
...rk/context/annotation/ClassPathBeanDefinitionScanner.java
+3
-2
org.springframework.context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java
...notation/ClassPathScanningCandidateComponentProvider.java
+3
-3
org.springframework.context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java
...framework/context/support/AbstractApplicationContext.java
+3
-3
org.springframework.context/src/test/java/org/springframework/context/annotation/AsmCircularImportDetectionTests.java
...k/context/annotation/AsmCircularImportDetectionTests.java
+2
-2
org.springframework.context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java
...ion/ClassPathScanningCandidateComponentProviderTests.java
+3
-3
org.springframework.context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java
...xt/support/PropertySourcesPlaceholderConfigurerTests.java
+2
-2
org.springframework.core/src/main/java/org/springframework/core/env/AbstractEnvironment.java
...ava/org/springframework/core/env/AbstractEnvironment.java
+1
-1
org.springframework.core/src/main/java/org/springframework/core/env/ConfigurableEnvironment.java
...org/springframework/core/env/ConfigurableEnvironment.java
+2
-2
org.springframework.core/src/main/java/org/springframework/core/env/Environment.java
...c/main/java/org/springframework/core/env/Environment.java
+2
-2
org.springframework.core/src/main/java/org/springframework/core/env/StandardEnvironment.java
...ava/org/springframework/core/env/StandardEnvironment.java
+4
-4
org.springframework.core/src/main/java/org/springframework/core/io/ResourceEditor.java
...main/java/org/springframework/core/io/ResourceEditor.java
+6
-6
org.springframework.core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java
...ramework/core/io/support/ResourceArrayPropertyEditor.java
+7
-7
org.springframework.core/src/test/java/org/springframework/core/env/EnvironmentTests.java
...t/java/org/springframework/core/env/EnvironmentTests.java
+6
-6
org.springframework.core/src/test/java/org/springframework/core/io/ResourceEditorTests.java
...java/org/springframework/core/io/ResourceEditorTests.java
+2
-2
org.springframework.integration-tests/src/test/java/org/springframework/core/env/EnvironmentIntegrationTests.java
...springframework/core/env/EnvironmentIntegrationTests.java
+25
-25
org.springframework.transaction/src/main/java/org/springframework/jca/context/SpringContextResourceAdapter.java
...ngframework/jca/context/SpringContextResourceAdapter.java
+3
-3
org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/context/DefaultPortletEnvironment.java
...mework/web/portlet/context/DefaultPortletEnvironment.java
+5
-5
org.springframework.web/src/main/java/org/springframework/web/context/support/DefaultWebEnvironment.java
...gframework/web/context/support/DefaultWebEnvironment.java
+5
-5
org.springframework.web/src/test/java/org/springframework/web/context/support/DefaultWebEnvironmentTests.java
...ework/web/context/support/DefaultWebEnvironmentTests.java
+7
-7
未找到文件。
org.springframework.beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinitionReader.java
浏览文件 @
c06752ef
...
...
@@ -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.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
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
Default
Environment
();
private
Environment
environment
=
new
Standard
Environment
();
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
Default
Environment}. All ApplicationContext implementations are
* use a {@link
Standard
Environment}. 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
Default
Environment
();
this
.
environment
=
new
Standard
Environment
();
}
}
...
...
org.springframework.beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java
浏览文件 @
c06752ef
...
...
@@ -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.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ObjectUtils
;
...
...
org.springframework.beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java
浏览文件 @
c06752ef
...
...
@@ -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.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
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
Default
Environment}.
* supplied {@link XmlReaderContext} and a new {@link
Standard
Environment}.
* @deprecated since Spring 3.1 in favor of
* {@link #BeanDefinitionParserDelegate(XmlReaderContext, Environment)}
*/
@Deprecated
public
BeanDefinitionParserDelegate
(
XmlReaderContext
readerContext
)
{
this
(
readerContext
,
new
Default
Environment
());
this
(
readerContext
,
new
Standard
Environment
());
}
/**
...
...
org.springframework.beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java
浏览文件 @
c06752ef
...
...
@@ -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.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
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
Default
Environment}.
* using a {@link
Standard
Environment}.
* @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
Default
Environment
());
this
(
resourceLoader
,
new
Standard
Environment
());
}
/**
...
...
org.springframework.beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementTests.java
浏览文件 @
c06752ef
...
...
@@ -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.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
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
Default
Environment
();
ConfigurableEnvironment
env
=
new
Standard
Environment
();
env
.
setActiveProfiles
(
"dev"
);
DefaultListableBeanFactory
bf
=
new
DefaultListableBeanFactory
();
...
...
org.springframework.beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java
浏览文件 @
c06752ef
...
...
@@ -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.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
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
Default
Environment
();
ConfigurableEnvironment
env
=
new
Standard
Environment
();
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
Default
Environment
();
ConfigurableEnvironment
env
=
new
Standard
Environment
();
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
Default
Environment
();
ConfigurableEnvironment
env
=
new
Standard
Environment
();
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
Default
Environment
();
ConfigurableEnvironment
env
=
new
Standard
Environment
();
// 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
Default
Environment
();
ConfigurableEnvironment
env
=
new
Standard
Environment
();
// 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
Default
Environment
();
StandardEnvironment
env
=
new
Standard
Environment
();
env
.
setActiveProfiles
(
activeProfiles
);
reader
.
setEnvironment
(
env
);
reader
.
loadBeanDefinitions
(
new
ClassPathResource
(
xmlName
,
getClass
()));
...
...
org.springframework.context/src/main/java/org/springframework/context/annotation/AnnotatedBeanDefinitionReader.java
浏览文件 @
c06752ef
...
...
@@ -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.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
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
Default
Environment
();
private
Environment
environment
=
new
Standard
Environment
();
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
Default
Environment}.
* <p>The default is a {@link
Standard
Environment}.
* @see #registerBean(Class, String, Class...)
*/
public
void
setEnvironment
(
Environment
environment
)
{
...
...
org.springframework.context/src/main/java/org/springframework/context/annotation/ClassPathBeanDefinitionScanner.java
浏览文件 @
c06752ef
...
...
@@ -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
...
...
org.springframework.context/src/main/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProvider.java
浏览文件 @
c06752ef
...
...
@@ -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.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
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
Default
Environment
();
private
Environment
environment
=
new
Standard
Environment
();
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
Default
Environment}
* <p>The default is a {@link
Standard
Environment}
* @param environment the Environment to use
*/
public
void
setEnvironment
(
Environment
environment
)
{
...
...
org.springframework.context/src/main/java/org/springframework/context/support/AbstractApplicationContext.java
浏览文件 @
c06752ef
...
...
@@ -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.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
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
Default
Environment}.
* Create and return a new {@link
Standard
Environment}.
* <p>Subclasses may override this method in order to supply
* a custom {@link ConfigurableEnvironment} implementation.
*/
protected
ConfigurableEnvironment
createEnvironment
()
{
return
new
Default
Environment
();
return
new
Standard
Environment
();
}
public
void
refresh
()
throws
BeansException
,
IllegalStateException
{
...
...
org.springframework.context/src/test/java/org/springframework/context/annotation/AsmCircularImportDetectionTests.java
浏览文件 @
c06752ef
...
...
@@ -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.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
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
Default
Environment
(),
new
Standard
Environment
(),
new
DefaultResourceLoader
(),
new
DefaultListableBeanFactory
());
}
...
...
org.springframework.context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java
浏览文件 @
c06752ef
...
...
@@ -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.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
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
Default
Environment
();
ConfigurableEnvironment
env
=
new
Standard
Environment
();
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
Default
Environment
();
ConfigurableEnvironment
env
=
new
Standard
Environment
();
env
.
setActiveProfiles
(
ProfileAnnotatedComponent
.
PROFILE_NAME
);
provider
.
setEnvironment
(
env
);
Set
<
BeanDefinition
>
candidates
=
provider
.
findCandidateComponents
(
TEST_PROFILE_PACKAGE
);
...
...
org.springframework.context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java
浏览文件 @
c06752ef
...
...
@@ -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.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
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
Default
Environment
());
ppc
.
setEnvironment
(
new
Standard
Environment
());
ppc
.
postProcessBeanFactory
(
bf
);
System
.
clearProperty
(
"key1"
);
System
.
clearProperty
(
"key2"
);
...
...
org.springframework.core/src/main/java/org/springframework/core/env/AbstractEnvironment.java
浏览文件 @
c06752ef
...
...
@@ -41,7 +41,7 @@ import org.springframework.util.StringUtils;
*
* @author Chris Beams
* @since 3.1
* @see
Default
Environment
* @see
Standard
Environment
*/
public
abstract
class
AbstractEnvironment
implements
ConfigurableEnvironment
{
...
...
org.springframework.core/src/main/java/org/springframework/core/env/ConfigurableEnvironment.java
浏览文件 @
c06752ef
...
...
@@ -25,7 +25,7 @@ import java.util.Map;
*
* @author Chris Beams
* @since 3.1
* @see
Default
Environment
* @see
Standard
Environment
* @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
();
...
...
org.springframework.core/src/main/java/org/springframework/core/env/Environment.java
浏览文件 @
c06752ef
...
...
@@ -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
Default
Environment} for several examples of using the ConfigurableEnvironment
* {@link
Standard
Environment} 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
Default
Environment
* @see
Standard
Environment
* @see org.springframework.context.EnvironmentAware
* @see org.springframework.context.ConfigurableApplicationContext#getEnvironment
* @see org.springframework.context.ConfigurableApplicationContext#setEnvironment
...
...
org.springframework.core/src/main/java/org/springframework/core/env/
Default
Environment.java
→
org.springframework.core/src/main/java/org/springframework/core/env/
Standard
Environment.java
浏览文件 @
c06752ef
...
...
@@ -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
Default
Environment();
* ConfigurableEnvironment environment = new
Standard
Environment();
* 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(
Default
Environment.SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)
* propertySources.remove(
Standard
Environment.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(
Default
Environment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, mockEnvVars);
* propertySources.replace(
Standard
Environment.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
Default
Environment
extends
AbstractEnvironment
{
public
class
Standard
Environment
extends
AbstractEnvironment
{
/** System environment property source name: {@value} */
public
static
final
String
SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME
=
"systemEnvironment"
;
...
...
org.springframework.core/src/main/java/org/springframework/core/io/ResourceEditor.java
浏览文件 @
c06752ef
...
...
@@ -19,7 +19,7 @@ package org.springframework.core.io;
import
java.beans.PropertyEditorSupport
;
import
java.io.IOException
;
import
org.springframework.core.env.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
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
Default
Environment}.
* using a {@link DefaultResourceLoader} and {@link
Standard
Environment}.
*/
public
ResourceEditor
()
{
this
(
new
DefaultResourceLoader
(),
new
Default
Environment
());
this
(
new
DefaultResourceLoader
(),
new
Standard
Environment
());
}
/**
* Create a new instance of the {@link ResourceEditor} class
* using the given {@link ResourceLoader} and a {@link
Default
Environment}.
* using the given {@link ResourceLoader} and a {@link
Standard
Environment}.
* @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
Default
Environment
(),
true
);
this
(
resourceLoader
,
new
Standard
Environment
(),
true
);
}
/**
...
...
@@ -97,7 +97,7 @@ public class ResourceEditor extends PropertyEditorSupport {
*/
@Deprecated
public
ResourceEditor
(
ResourceLoader
resourceLoader
,
boolean
ignoreUnresolvablePlaceholders
)
{
this
(
resourceLoader
,
new
Default
Environment
(),
ignoreUnresolvablePlaceholders
);
this
(
resourceLoader
,
new
Standard
Environment
(),
ignoreUnresolvablePlaceholders
);
}
/**
...
...
org.springframework.core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java
浏览文件 @
c06752ef
...
...
@@ -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.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
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
Default
Environment}.
* {@link PathMatchingResourcePatternResolver} and {@link
Standard
Environment}.
* @see PathMatchingResourcePatternResolver
* @see Environment
*/
public
ResourceArrayPropertyEditor
()
{
this
(
new
PathMatchingResourcePatternResolver
(),
new
Default
Environment
(),
true
);
this
(
new
PathMatchingResourcePatternResolver
(),
new
Standard
Environment
(),
true
);
}
/**
* Create a new ResourceArrayPropertyEditor with the given {@link ResourcePatternResolver}
* and a {@link
Default
Environment}.
* and a {@link
Standard
Environment}.
* @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
Default
Environment
(),
true
);
this
(
resourcePatternResolver
,
new
Standard
Environment
(),
true
);
}
/**
...
...
@@ -95,7 +95,7 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport {
/**
* Create a new ResourceArrayPropertyEditor with the given {@link ResourcePatternResolver}
* and a {@link
Default
Environment}.
* and a {@link
Standard
Environment}.
* @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
Default
Environment
(),
ignoreUnresolvablePlaceholders
);
this
(
resourcePatternResolver
,
new
Standard
Environment
(),
ignoreUnresolvablePlaceholders
);
}
/**
...
...
org.springframework.core/src/test/java/org/springframework/core/env/EnvironmentTests.java
浏览文件 @
c06752ef
/*
* Copyright 2002-201
0
the original author or authors.
* Copyright 2002-201
1
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
Default
Environment}.
* Unit tests for {@link
Standard
Environment}.
*
* @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
Default
Environment
();
private
ConfigurableEnvironment
environment
=
new
Standard
Environment
();
@Test
public
void
propertySourceOrder
()
{
ConfigurableEnvironment
env
=
new
Default
Environment
();
ConfigurableEnvironment
env
=
new
Standard
Environment
();
MutablePropertySources
sources
=
env
.
getPropertySources
();
assertThat
(
sources
.
precedenceOf
(
PropertySource
.
named
(
Default
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
)),
equalTo
(
0
));
assertThat
(
sources
.
precedenceOf
(
PropertySource
.
named
(
Default
Environment
.
SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME
)),
equalTo
(
1
));
assertThat
(
sources
.
precedenceOf
(
PropertySource
.
named
(
Standard
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
)),
equalTo
(
0
));
assertThat
(
sources
.
precedenceOf
(
PropertySource
.
named
(
Standard
Environment
.
SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME
)),
equalTo
(
1
));
assertThat
(
sources
.
size
(),
is
(
2
));
}
...
...
org.springframework.core/src/test/java/org/springframework/core/io/ResourceEditorTests.java
浏览文件 @
c06752ef
...
...
@@ -20,7 +20,7 @@ import java.beans.PropertyEditor;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Test
;
import
org.springframework.core.env.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
/**
* 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
Default
Environment
(),
false
);
PropertyEditor
editor
=
new
ResourceEditor
(
new
DefaultResourceLoader
(),
new
Standard
Environment
(),
false
);
System
.
setProperty
(
"test.prop"
,
"foo"
);
try
{
editor
.
setAsText
(
"${test.prop}-${bar}"
);
...
...
org.springframework.integration-tests/src/test/java/org/springframework/core/env/EnvironmentIntegrationTests.java
浏览文件 @
c06752ef
...
...
@@ -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
Default
Environment
();
prodEnv
=
new
Standard
Environment
();
prodEnv
.
setActiveProfiles
(
PROD_ENV_NAME
);
devEnv
=
new
Default
Environment
();
devEnv
=
new
Standard
Environment
();
devEnv
.
setActiveProfiles
(
DEV_ENV_NAME
);
}
@Test
public
void
genericApplicationContext_
default
Env
()
{
public
void
genericApplicationContext_
standard
Env
()
{
ConfigurableApplicationContext
ctx
=
new
GenericApplicationContext
(
newBeanFactoryWithEnvironmentAwareBean
());
ctx
.
refresh
();
assertHas
Default
Environment
(
ctx
);
assertHas
Standard
Environment
(
ctx
);
assertEnvironmentBeanRegistered
(
ctx
);
assertEnvironmentAwareInvoked
(
ctx
,
ctx
.
getEnvironment
());
}
...
...
@@ -199,7 +199,7 @@ public class EnvironmentIntegrationTests {
public
void
genericXmlApplicationContext
()
{
GenericXmlApplicationContext
ctx
=
new
GenericXmlApplicationContext
();
assertHas
Default
Environment
(
ctx
);
assertHas
Standard
Environment
(
ctx
);
ctx
.
setEnvironment
(
prodEnv
);
...
...
@@ -249,7 +249,7 @@ public class EnvironmentIntegrationTests {
public
void
annotationConfigApplicationContext_withPojos
()
{
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
assertHas
Default
Environment
(
ctx
);
assertHas
Standard
Environment
(
ctx
);
ctx
.
setEnvironment
(
prodEnv
);
ctx
.
register
(
EnvironmentAwareBean
.
class
);
...
...
@@ -262,7 +262,7 @@ public class EnvironmentIntegrationTests {
public
void
annotationConfigApplicationContext_withProdEnvAndProdConfigClass
()
{
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
assertHas
Default
Environment
(
ctx
);
assertHas
Standard
Environment
(
ctx
);
ctx
.
setEnvironment
(
prodEnv
);
ctx
.
register
(
ProdConfig
.
class
);
...
...
@@ -275,7 +275,7 @@ public class EnvironmentIntegrationTests {
public
void
annotationConfigApplicationContext_withProdEnvAndDevConfigClass
()
{
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
assertHas
Default
Environment
(
ctx
);
assertHas
Standard
Environment
(
ctx
);
ctx
.
setEnvironment
(
prodEnv
);
ctx
.
register
(
DevConfig
.
class
);
...
...
@@ -289,7 +289,7 @@ public class EnvironmentIntegrationTests {
public
void
annotationConfigApplicationContext_withDevEnvAndDevConfigClass
()
{
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
assertHas
Default
Environment
(
ctx
);
assertHas
Standard
Environment
(
ctx
);
ctx
.
setEnvironment
(
devEnv
);
ctx
.
register
(
DevConfig
.
class
);
...
...
@@ -303,7 +303,7 @@ public class EnvironmentIntegrationTests {
public
void
annotationConfigApplicationContext_withImportedConfigClasses
()
{
AnnotationConfigApplicationContext
ctx
=
new
AnnotationConfigApplicationContext
();
assertHas
Default
Environment
(
ctx
);
assertHas
Standard
Environment
(
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
Default
Environment
();
StandardEnvironment
derivedDevEnv
=
new
Standard
Environment
();
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
();
assertHas
Default
Environment
(
ctx
);
assertHas
Standard
Environment
(
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
(
Default
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
))));
lessThan
(
propertySources
.
precedenceOf
(
PropertySource
.
named
(
Standard
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
))));
// Replace system properties with a mock property source for convenience
MockPropertySource
mockSystemProperties
=
new
MockPropertySource
(
Default
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
);
MockPropertySource
mockSystemProperties
=
new
MockPropertySource
(
Standard
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
);
mockSystemProperties
.
setProperty
(
"pCommon"
,
"pCommonSysPropsValue"
);
mockSystemProperties
.
setProperty
(
"pSysProps1"
,
"pSysProps1Value"
);
propertySources
.
replace
(
Default
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
,
mockSystemProperties
);
propertySources
.
replace
(
Standard
Environment
.
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
(
Default
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
))));
lessThan
(
propertySources
.
precedenceOf
(
PropertySource
.
named
(
Standard
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
))));
// Replace system properties with a mock property source for convenience
MockPropertySource
mockSystemProperties
=
new
MockPropertySource
(
Default
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
);
MockPropertySource
mockSystemProperties
=
new
MockPropertySource
(
Standard
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
);
mockSystemProperties
.
setProperty
(
"pCommon"
,
"pCommonSysPropsValue"
);
mockSystemProperties
.
setProperty
(
"pSysProps1"
,
"pSysProps1Value"
);
propertySources
.
replace
(
Default
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
,
mockSystemProperties
);
propertySources
.
replace
(
Standard
Environment
.
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
(
Default
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
))));
lessThan
(
propertySources
.
precedenceOf
(
PropertySource
.
named
(
Standard
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
))));
// Replace system properties with a mock property source for convenience
MockPropertySource
mockSystemProperties
=
new
MockPropertySource
(
Default
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
);
MockPropertySource
mockSystemProperties
=
new
MockPropertySource
(
Standard
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
);
mockSystemProperties
.
setProperty
(
"pCommon"
,
"pCommonSysPropsValue"
);
mockSystemProperties
.
setProperty
(
"pSysProps1"
,
"pSysProps1Value"
);
propertySources
.
replace
(
Default
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
,
mockSystemProperties
);
propertySources
.
replace
(
Standard
Environment
.
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
()));
assertHas
Default
Environment
(
ctx
);
assertHas
Standard
Environment
(
ctx
);
registerEnvironmentBeanDefinition
(
ctx
);
...
...
@@ -626,10 +626,10 @@ public class EnvironmentIntegrationTests {
assertThat
(
ctx
.
containsBean
(
ENVIRONMENT_BEAN_NAME
),
is
(
true
));
}
private
void
assertHas
Default
Environment
(
ApplicationContext
ctx
)
{
private
void
assertHas
Standard
Environment
(
ApplicationContext
ctx
)
{
Environment
defaultEnv
=
ctx
.
getEnvironment
();
assertThat
(
defaultEnv
,
notNullValue
());
assertThat
(
defaultEnv
,
instanceOf
(
Default
Environment
.
class
));
assertThat
(
defaultEnv
,
instanceOf
(
Standard
Environment
.
class
));
}
private
void
assertHasDefaultWebEnvironment
(
WebApplicationContext
ctx
)
{
...
...
org.springframework.transaction/src/main/java/org/springframework/jca/context/SpringContextResourceAdapter.java
浏览文件 @
c06752ef
...
...
@@ -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.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
import
org.springframework.util.StringUtils
;
/**
...
...
@@ -144,12 +144,12 @@ public class SpringContextResourceAdapter implements ResourceAdapter {
}
/**
* Return a new {@link
Default
Environment}.
* Return a new {@link
Standard
Environment}.
* <p>Subclasses may override this method in order to supply
* a custom {@link ConfigurableEnvironment} implementation.
*/
protected
ConfigurableEnvironment
createEnvironment
()
{
return
new
Default
Environment
();
return
new
Standard
Environment
();
}
/**
...
...
org.springframework.web.portlet/src/main/java/org/springframework/web/portlet/context/DefaultPortletEnvironment.java
浏览文件 @
c06752ef
...
...
@@ -20,7 +20,7 @@ import javax.portlet.PortletConfig;
import
javax.portlet.PortletContext
;
import
javax.servlet.ServletContext
;
import
org.springframework.core.env.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
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
Default
Environment
* @see
Standard
Environment
* @see DefaultWebEnvironment
*/
public
class
DefaultPortletEnvironment
extends
Default
Environment
{
public
class
DefaultPortletEnvironment
extends
Standard
Environment
{
/** 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
Default
Environment} superclass.
* variables contributed by the {@link
Standard
Environment} 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
Default
Environment#customizePropertySources
* @see
Standard
Environment#customizePropertySources
* @see PortletConfigPropertySource
* @see PortletContextPropertySource
* @see AbstractRefreshablePortletApplicationContext#initPropertySources
...
...
org.springframework.web/src/main/java/org/springframework/web/context/support/DefaultWebEnvironment.java
浏览文件 @
c06752ef
...
...
@@ -19,7 +19,7 @@ package org.springframework.web.context.support;
import
javax.servlet.ServletConfig
;
import
javax.servlet.ServletContext
;
import
org.springframework.core.env.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
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
Default
Environment
* @see
Standard
Environment
* @see DefaultPortletEnvironment
*/
public
class
DefaultWebEnvironment
extends
Default
Environment
{
public
class
DefaultWebEnvironment
extends
Standard
Environment
{
/** 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
Default
Environment} superclass.
* variables contributed by the {@link
Standard
Environment} 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
Default
Environment#customizePropertySources
* @see
Standard
Environment#customizePropertySources
* @see ServletConfigPropertySource
* @see ServletContextPropertySource
* @see org.springframework.jndi.JndiPropertySource
...
...
org.springframework.web/src/test/java/org/springframework/web/context/support/DefaultWebEnvironmentTests.java
浏览文件 @
c06752ef
...
...
@@ -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.
Default
Environment
;
import
org.springframework.core.env.
Standard
Environment
;
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
(
Default
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
)),
equalTo
(
2
));
assertThat
(
sources
.
precedenceOf
(
PropertySource
.
named
(
Default
Environment
.
SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME
)),
equalTo
(
3
));
assertThat
(
sources
.
precedenceOf
(
PropertySource
.
named
(
Standard
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
)),
equalTo
(
2
));
assertThat
(
sources
.
precedenceOf
(
PropertySource
.
named
(
Standard
Environment
.
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
(
Default
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
)),
equalTo
(
3
));
assertThat
(
sources
.
precedenceOf
(
PropertySource
.
named
(
Default
Environment
.
SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME
)),
equalTo
(
4
));
assertThat
(
sources
.
precedenceOf
(
PropertySource
.
named
(
Standard
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
)),
equalTo
(
3
));
assertThat
(
sources
.
precedenceOf
(
PropertySource
.
named
(
Standard
Environment
.
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
(
Default
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
)),
equalTo
(
2
));
assertThat
(
sources
.
precedenceOf
(
PropertySource
.
named
(
Default
Environment
.
SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME
)),
equalTo
(
3
));
assertThat
(
sources
.
precedenceOf
(
PropertySource
.
named
(
Standard
Environment
.
SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME
)),
equalTo
(
2
));
assertThat
(
sources
.
precedenceOf
(
PropertySource
.
named
(
Standard
Environment
.
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录