public class ConfigTreePropertySource extends org.springframework.core.env.EnumerablePropertySource<java.nio.file.Path> implements OriginLookup<java.lang.String>
PropertySource backed by a directory tree that contains files for each value.
The PropertySource will recursively scan a given source directory and expose a
property for each file found. The property name will be the filename, and the property
value will be the contents of the file.
Directories are only scanned when the source is first created. The directory is not
monitored for updates, so files should not be added or removed. However, the contents
of a file can be updated as long as the property source was created with a
ConfigTreePropertySource.Option.ALWAYS_READ option. Nested directories are included in the source, but
with a '.' rather than '/' used as the path separator.
Property values are returned as ConfigTreePropertySource.Value instances which allows them to be treated
either as an InputStreamSource or as a CharSequence. In addition, if
used with an Environment configured with an
ApplicationConversionService, property values can be converted to a
String or byte[].
This property source is typically used to read Kubernetes configMap volume
mounts.
| Modifier and Type | Class and Description |
|---|---|
static class |
ConfigTreePropertySource.Option
Property source options.
|
static interface |
ConfigTreePropertySource.Value
A value returned from the property source which exposes the contents of the
property file.
|
| Constructor and Description |
|---|
ConfigTreePropertySource(java.lang.String name,
java.nio.file.Path sourceDirectory)
Create a new
ConfigTreePropertySource instance. |
ConfigTreePropertySource(java.lang.String name,
java.nio.file.Path sourceDirectory,
ConfigTreePropertySource.Option... options)
Create a new
ConfigTreePropertySource instance. |
| Modifier and Type | Method and Description |
|---|---|
Origin |
getOrigin(java.lang.String name)
Return the origin of the given key or
null if the origin cannot be
determined. |
ConfigTreePropertySource.Value |
getProperty(java.lang.String name) |
java.lang.String[] |
getPropertyNames() |
boolean |
isImmutable()
Return
true if this lookup is immutable and has contents that will never
change. |
equals, getName, getSource, hashCode, named, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetOrigin, getPrefixpublic ConfigTreePropertySource(java.lang.String name,
java.nio.file.Path sourceDirectory)
ConfigTreePropertySource instance.name - the name of the property sourcesourceDirectory - the underlying source directorypublic ConfigTreePropertySource(java.lang.String name,
java.nio.file.Path sourceDirectory,
ConfigTreePropertySource.Option... options)
ConfigTreePropertySource instance.name - the name of the property sourcesourceDirectory - the underlying source directoryoptions - the property source optionspublic java.lang.String[] getPropertyNames()
getPropertyNames in class org.springframework.core.env.EnumerablePropertySource<java.nio.file.Path>public ConfigTreePropertySource.Value getProperty(java.lang.String name)
getProperty in class org.springframework.core.env.PropertySource<java.nio.file.Path>public Origin getOrigin(java.lang.String name)
OriginLookupnull if the origin cannot be
determined.getOrigin in interface OriginLookup<java.lang.String>name - the key to lookupnullpublic boolean isImmutable()
OriginLookuptrue if this lookup is immutable and has contents that will never
change.isImmutable in interface OriginLookup<java.lang.String>