类 CompositePropertySource
- java.lang.Object
- org.springframework.core.env.PropertySource<T>
- org.springframework.core.env.EnumerablePropertySource<Object>
- org.springframework.core.env.CompositePropertySource
public class CompositePropertySource extends EnumerablePropertySource<Object>
CompositePropertySource
implementation that iterates over a set ofPropertySource
instances. Necessary in cases where multiple property sources share the same name, e.g. when multiple values are supplied to@PropertySource
.As of Spring 4.1.2, this class extends
EnumerablePropertySource
instead of plainPropertySource
, exposinggetPropertyNames()
based on the accumulated property names from all contained sources (as far as possible).- 从以下版本开始:
- 3.1.1
- 作者:
- Chris Beams, Juergen Hoeller, Phillip Webb
嵌套类概要
从类继承的嵌套类/接口 org.springframework.core.env.PropertySource
PropertySource.StubPropertySource
字段概要
从类继承的字段 org.springframework.core.env.PropertySource
logger, name, source
构造器概要
构造器 构造器 说明 CompositePropertySource(String name)
Create a newCompositePropertySource
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
addFirstPropertySource(PropertySource<?> propertySource)
Add the givenPropertySource
to the start of the chain.void
addPropertySource(PropertySource<?> propertySource)
Add the givenPropertySource
to the end of the chain.boolean
containsProperty(String name)
Return whether thisPropertySource
contains a property with the given name.Object
getProperty(String name)
Return the value associated with the given name, ornull
if not found.String[]
getPropertyNames()
Return the names of all properties contained by the source object (nevernull
).Collection<PropertySource<?>>
getPropertySources()
Return all property sources that this composite source holds.String
toString()
Produce concise output (type and name) if the current log level does not include debug.
构造器详细资料
CompositePropertySource
public CompositePropertySource(String name)
Create a newCompositePropertySource
.- 参数:
name
- the name of the property source
方法详细资料
getProperty
@Nullable public Object getProperty(String name)
从类复制的说明:PropertySource
Return the value associated with the given name, ornull
if not found.- 指定者:
getProperty
在类中PropertySource<Object>
- 参数:
name
- the property to find- 另请参阅:
PropertyResolver.getRequiredProperty(String)
containsProperty
public boolean containsProperty(String name)
从类复制的说明:EnumerablePropertySource
Return whether thisPropertySource
contains a property with the given name.This implementation checks for the presence of the given name within the
EnumerablePropertySource.getPropertyNames()
array.- 覆盖:
containsProperty
在类中EnumerablePropertySource<Object>
- 参数:
name
- the name of the property to find
getPropertyNames
public String[] getPropertyNames()
从类复制的说明:EnumerablePropertySource
Return the names of all properties contained by the source object (nevernull
).
addPropertySource
public void addPropertySource(PropertySource<?> propertySource)
Add the givenPropertySource
to the end of the chain.- 参数:
propertySource
- the PropertySource to add
addFirstPropertySource
public void addFirstPropertySource(PropertySource<?> propertySource)
Add the givenPropertySource
to the start of the chain.- 参数:
propertySource
- the PropertySource to add- 从以下版本开始:
- 4.1
getPropertySources
public Collection<PropertySource<?>> getPropertySources()
Return all property sources that this composite source holds.- 从以下版本开始:
- 4.1.1
toString
public String toString()
从类复制的说明:PropertySource
Produce concise output (type and name) if the current log level does not include debug. If debug is enabled, produce verbose output including the hash code of the PropertySource instance and every name/value property pair.This variable verbosity is useful as a property source such as system properties or environment variables may contain an arbitrary number of property pairs, potentially leading to difficult to read exception and log messages.
- 覆盖:
toString
在类中PropertySource<Object>
- 另请参阅:
Log.isDebugEnabled()