Module io.avaje.config
Package io.avaje.config
Application configuration based on loading properties and yaml files.
Examples
int port = Config.getInt("app.port", 8090);
String topicName = Config.get("app.topic.name");
List<Integer> codes = Config.getList().ofInt("my.codes", 42, 54);
Loading into System properties
If config.load.systemProperties
is set to true
then all the properties are loaded into System properties.
File watching and reloading
We can enable watching configuration files by setting
config.watch.enabled=true
. With this enabled
config will watch for modifications to the configuration files
and reload the configuration.
By default the files are checked every 60 seconds. We can
change this by setting the config.watch.period
(which is in seconds). For example setting
config.watch.period=10
means the files are
checked every every 10 seconds.
By default there is an initial delay of 60 seconds. We can
change this by setting config.watch.delay
.
This can provide us a simple "feature toggle" mechanism.
// we can toggle this on/off by editing the
// appropriate property in the configuration file
if (Config.enabled("feature.cleanup", false)) {
...
}
-
Interface Summary Interface Description Configuration Configuration API for accessing property values and registering onChange listeners.Configuration.ExpressionEval Expression evaluation.Configuration.ListValue Return a List of values for a configuration key.Configuration.SetValue Return a Set of values configured.ConfigurationLog Configuration events are sent to this event log.ConfigurationSource Additional source to load and update configuration.ModificationEvent The event that occurs on configuration changes.ModificationEvent.Builder Build and publish modifications to the configuration.ModificationEventRunner Run the event listener notifications. -
Class Summary Class Description Config Provides application Configuration based on loading properties and yaml files as well as plugins that supply properties (like dynamic configuration loaded from a db).