public class CompositePropertySource extends EnumerablePropertySource<Object>
PropertySource implementation that iterates over a set of
PropertySource 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 plain PropertySource, exposing getPropertyNames() based on the
accumulated property names from all contained sources (as far as possible).
PropertySource.StubPropertySourcelogger, name, source| 构造器和说明 |
|---|
CompositePropertySource(String name)
Create a new
CompositePropertySource. |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addFirstPropertySource(PropertySource<?> propertySource)
Add the given
PropertySource to the start of the chain. |
void |
addPropertySource(PropertySource<?> propertySource)
Add the given
PropertySource to the end of the chain. |
boolean |
containsProperty(String name)
Return whether this
PropertySource contains a property with the given name. |
Object |
getProperty(String name)
Return the value associated with the given name,
or
null if not found. |
String[] |
getPropertyNames()
Return the names of all properties contained by the
source object (never
null). |
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.
|
public CompositePropertySource(String name)
CompositePropertySource.name - the name of the property source@Nullable public Object getProperty(String name)
PropertySourcenull if not found.getProperty 在类中 PropertySource<Object>name - the property to findPropertyResolver.getRequiredProperty(String)public boolean containsProperty(String name)
EnumerablePropertySourcePropertySource 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 findpublic String[] getPropertyNames()
EnumerablePropertySourcenull).getPropertyNames 在类中 EnumerablePropertySource<Object>public void addPropertySource(PropertySource<?> propertySource)
PropertySource to the end of the chain.propertySource - the PropertySource to addpublic void addFirstPropertySource(PropertySource<?> propertySource)
PropertySource to the start of the chain.propertySource - the PropertySource to addpublic Collection<PropertySource<?>> getPropertySources()
public String toString()
PropertySourceThis 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()