Package 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)) {
     ...
   }