Interface ConfigSource
public interface ConfigSource
Implement this interfaces to provide a ConfigSource. A ConfigSource provides configuration values from a specific place, like JNDI configuration, a properties file, etc. A ConfigSource is always read-only, any potential updates of the configured values must be handled directly inside each ConfigSource.
The default config sources always available by default are:
- System properties (ordinal=400)
- Environment properties (ordinal=300)
- /META-INF/microprofile-config.properties (ordinal=100)
Custom ConfigSource will get picked up via the ServiceLoader
mechanism and and can be registered by
providing a file
META-INF/services/org.eclipse.microprofile.config.spi.ConfigSourcewhich contains the fully qualified
ConfigSource
implementation class name as content.
Adding a dynamic amount of custom config sources can be done programmatically via
ConfigSourceProvider
.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetName()
The name of the config might be used for logging or analysis of configured values.default int
Return the ordinal for this config source.Return the properties in this config sourceGets all property names known to this config source, without evaluating the values.Return the value for the specified property in this config source.
-
Field Details
-
CONFIG_ORDINAL
- See Also:
-
-
Method Details
-
getProperties
Return the properties in this config source- Returns:
- the map containing the properties in this config source
-
getPropertyNames
Gets all property names known to this config source, without evaluating the values. For backwards compatibility, there is a default implementation that just returns the keys ofgetProperties()
slower ConfigSource implementations should replace this with a more performant implementation- Returns:
- the set of property keys that are known to this ConfigSource
-
getOrdinal
default int getOrdinal()Return the ordinal for this config source. If a property is specified in multiple config sources, the value in the config source with the highest ordinal takes precedence. For the config sources with the same ordinal value, the config source names will be used for sorting according to string sorting criteria. Note that this property only gets evaluated during ConfigSource discovery. The default ordinals for the default config sources:- System properties (default ordinal=400)
- Environment properties (default ordinal=300)
- /META-INF/microprofile-config.properties (default ordinal=100)
- Returns:
- the ordinal value
-
getValue
Return the value for the specified property in this config source.- Parameters:
propertyName
- the property name- Returns:
- the property value
-
getName
String getName()The name of the config might be used for logging or analysis of configured values.- Returns:
- the 'name' of the configuration source, e.g. 'property-file mylocation/myproperty.properties'
-