Package org.springframework.core.env
Class CompositePropertySource
java.lang.Object
org.springframework.core.env.PropertySource<T>
org.springframework.core.env.EnumerablePropertySource<Object>
org.springframework.core.env.CompositePropertySource
Composite
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).
- Since:
- 3.1.1
- Author:
- Chris Beams, Juergen Hoeller, Phillip Webb
-
Nested Class Summary
Nested classes/interfaces inherited from class org.springframework.core.env.PropertySource
PropertySource.StubPropertySource -
Field Summary
Fields inherited from class org.springframework.core.env.PropertySource
logger, name, source -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFirstPropertySource(PropertySource<?> propertySource) Add the givenPropertySourceto the start of the chain.voidaddPropertySource(PropertySource<?> propertySource) Add the givenPropertySourceto the end of the chain.booleancontainsProperty(String name) Return whether thisPropertySourcecontains a property with the given name.getProperty(String name) Return the value associated with the given name, ornullif not found.String[]Return the names of all properties contained by the source object (nevernull).Return all property sources that this composite source holds.toString()Produce concise output (type and name) if the current log level does not include debug.
-
Constructor Details
-
CompositePropertySource
Create a newCompositePropertySource.- Parameters:
name- the name of the property source
-
-
Method Details
-
getProperty
Description copied from class:PropertySourceReturn the value associated with the given name, ornullif not found.- Specified by:
getPropertyin classPropertySource<Object>- Parameters:
name- the property to find- See Also:
-
containsProperty
Description copied from class:EnumerablePropertySourceReturn whether thisPropertySourcecontains a property with the given name.This implementation checks for the presence of the given name within the
EnumerablePropertySource.getPropertyNames()array.- Overrides:
containsPropertyin classEnumerablePropertySource<Object>- Parameters:
name- the name of the property to find
-
getPropertyNames
Description copied from class:EnumerablePropertySourceReturn the names of all properties contained by the source object (nevernull).- Specified by:
getPropertyNamesin classEnumerablePropertySource<Object>
-
addPropertySource
Add the givenPropertySourceto the end of the chain.- Parameters:
propertySource- the PropertySource to add
-
addFirstPropertySource
Add the givenPropertySourceto the start of the chain.- Parameters:
propertySource- the PropertySource to add- Since:
- 4.1
-
getPropertySources
Return all property sources that this composite source holds.- Since:
- 4.1.1
-
toString
Description copied from class:PropertySourceProduce 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 difficulties to read exception and log messages.
- Overrides:
toStringin classPropertySource<Object>- See Also:
-