public interface PropertySource
This interface models a provider that serves configuration properties. The contained properties may be read from a Map of single or several sources (composite). PropertySources are the building blocks of the final configuration.
Implementations of this interface must be
A PropertySourceProvider will current picked up via the
ServiceLoader mechanism and can be registered via
META-INF/services/org.apache.tamaya.spi.PropertySource
If you like to register multiple PropertySources at the same time
you can use the PropertySourceProvider
interface.
| Modifier and Type | Field | Description |
|---|---|---|
static PropertySource |
EMPTY |
A resusable instance of an empty PropertySource.
|
static String |
TAMAYA_ORDINAL |
property name to override default tamaya ordinals
|
| Modifier and Type | Method | Description |
|---|---|---|
default void |
addChangeListener(BiConsumer<Set<String>,PropertySource> l) |
Add a change listener for this properrty source.
|
PropertyValue |
get(String key) |
Access a property.
|
default ChangeSupport |
getChangeSupport() |
Get the support for reporting changes to property sources provided by this instance.
|
String |
getName() |
Get the name of the property source.
|
default int |
getOrdinal() |
The ordinal value is the default ordering parameter which definines the default order of
auto-discovered property sources.
|
Map<String,PropertyValue> |
getProperties() |
Access the current properties as Set.
|
default String |
getVersion() |
Get the current version.
|
default boolean |
isScannable() |
Deprecated.
will be removed.
|
default void |
removeAllChangeListeners() |
Removes all registered change listeners, if any.
|
default void |
removeChangeListener(BiConsumer<Set<String>,PropertySource> l) |
Removes a change listener for this properrty source.
|
static final String TAMAYA_ORDINAL
static final PropertySource EMPTY
default int getOrdinal()
tamaya-jndi extension module)Important Hints for custom implementations:
If a custom implementation should be invoked before the default implementations, use a value > 1000
If a custom implementation should be invoked after the default implementations, use a value < 100
Reordering of the default order of the config-sources:
Example: If the properties file/s should be used before the other implementations, you have to configure an ordinal > 1000. That means, you have to addPropertyValue e.g. tamaya.ordinal=401 to /META-INF/javaconfiguration.properties . Hint: In case of property files every file is handled as independent config-source, but all of them have ordinal 400 by default (and can be reordered in a fine-grained manner.
In cases where it is not possible to change a config sources ordinal value, you may have several options:ConfigurationBuilder to redefine the source order and finally use
ConfigurationProvider.setConfiguration(Configuration) to
change the current default Configuration.String getName()
null.PropertyValue get(String key)
key - the property's key, not null.mapProperties.current(key) == value, including also any metadata. In case a
value is null, simply return null.Map<String,PropertyValue> getProperties()
null@Deprecated default boolean isScannable()
PropertySources which are not scannable might not be able to find all the
configured values to provide via getProperties(). This might happen
if the underlying storage doesn't support listing.
true if this PropertySource can be scanned for its createList of properties,
false if it cannot/should not be scanned.default ChangeSupport getChangeSupport()
default String getVersion()
getChangeSupport() is ChangeSupport.SUPPORTED.
The content and format of the version String is imeplemtation specific. We recommend to addPropertyValue information
such as the loading timestamp, the source systems read or whatever is appropriate. By default this
method returns "N/A".default void addChangeListener(BiConsumer<Set<String>,PropertySource> l)
l - the listner, not null.default void removeChangeListener(BiConsumer<Set<String>,PropertySource> l)
l - the listner, not null.default void removeAllChangeListeners()
Copyright © 2014–2019 Apache Software Foundation. All rights reserved.