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:
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
.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CONFIG_ORDINAL |
static int |
DEFAULT_ORDINAL |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getName()
The name of the config might be used for logging or analysis of configured values.
|
default int |
getOrdinal()
Return the ordinal for this config source.
|
java.util.Map<java.lang.String,java.lang.String> |
getProperties()
Return the properties in this config source
|
default java.util.Set<java.lang.String> |
getPropertyNames()
Gets all property names known to this config source, without evaluating the values.
|
java.lang.String |
getValue(java.lang.String propertyName)
Return the value for the specified property in this config source.
|
static final java.lang.String CONFIG_ORDINAL
static final int DEFAULT_ORDINAL
java.util.Map<java.lang.String,java.lang.String> getProperties()
default java.util.Set<java.lang.String> getPropertyNames()
getProperties()
slower ConfigSource implementations should replace this with a more performant implementationdefault int getOrdinal()
Some operating systems allow only alphabetic characters or an underscore(_), in environment variables.
Other characters such as ., /, etc may be disallowed.
In order to set a value for a config property that has a name containing such disallowed characters from an environment variable,
the following rules are used.
This ConfigSource searches for potentially 3 environment variables with a given property name (e.g. "com.ACME.size"
):
"com.ACME.size"
)"com_ACME_size"
)"COM_ACME_SIZE"
)The first environment variable that is found is returned by this ConfigSource.
java.lang.String getValue(java.lang.String propertyName)
propertyName
- the property namejava.lang.String getName()