public interface ConfigSource
Implement this interfaces to provide a ConfigSource. A ConfigSource provides properties from a specific place, like JNDI configuration, a properties file, etc
The custom implementation can be 'registered' using a
ConfigSourceProvider
or via the
ServiceLoader
mechanism. In the later case
it must get registered via creating a
META-INF/services/org.apache.deltaspike.core.spi.config.ConfigSource
file and adding the fully qualified class name of your ConfigSource
implementation into it.
If a ConfigSource implements the AutoCloseable
interface it will automatically
be released when the Config is shut down.
Modifier and Type | Field and Description |
---|---|
static String |
DELTASPIKE_ORDINAL
The default name for the ordinal field.
|
Modifier and Type | Method and Description |
---|---|
String |
getConfigName() |
int |
getOrdinal()
Lookup order:
System properties (ordinal 400)
Environment properties (ordinal 300)
JNDI values (ordinal 200)
Properties file values (/META-INF/apache-deltaspike.properties) (ordinal 100)
Important Hints for custom implementations:
If a custom implementation should be invoked before the default implementations, use a value > 400
If a custom implementation should be invoked after the default implementations, use a value < 100
IMPORTANT: Have a look at the abstract base-implementation DeltaSpike is using internally,
if a custom implementation should load the ordinal value from the config-source like the default
implementations provided by DeltaSpike do.
|
Map<String,String> |
getProperties()
Return properties contained in this config source.
|
String |
getPropertyValue(String key) |
boolean |
isScannable()
Determines if this config source should be scanned for its list of properties.
|
default void |
setOnAttributeChange(Consumer<Set<String>> reportAttributeChange)
This callback should get invoked if an attribute change got detected inside the ConfigSource.
|
static final String DELTASPIKE_ORDINAL
getOrdinal()
.int getOrdinal()
Important Hints for custom implementations:
If a custom implementation should be invoked before the default implementations, use a value > 400
If a custom implementation should be invoked after the default implementations, use a value < 100
IMPORTANT: Have a look at the abstract base-implementation DeltaSpike is using internally, if a custom implementation should load the ordinal value from the config-source like the default implementations provided by DeltaSpike do.
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 > 400. That means, you have to add e.g. deltaspike_ordinal=401 to /META-INF/apache-deltaspike.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.
Map<String,String> getProperties()
String getPropertyValue(String key)
key
- for the propertynull
if this ConfigSource doesn't provide any value for the given key.String getConfigName()
boolean isScannable()
default void setOnAttributeChange(Consumer<Set<String>> reportAttributeChange)
reportAttributeChange.accept(changedKeys);
reportAttributeChange
- will be set by the Config
after this
ConfigSource
got created and before any configured values
get served.Copyright © 2020 The Apache Software Foundation. All rights reserved.