Skip to content

Loaders

Javier Diaz edited this page Aug 19, 2018 · 3 revisions

Loaders basically is what knows how to load whatever comes from the source. For example, you can use a FileConfiSource and then load it with a JsonConfigLoader. It is just an interface that defines two methods, get and reload (for those that can be reloaded)

fun get(key: String): ConfigObject?
fun reload()

If you have a custom format that you need to load, you can implement this interface in order to extend the library.

Supported loaders:

  1. DefaultConfigLoader: This loader can take static map or vararg of pairs to create a loader from it.
  2. JsonConfigLoader: Load the properties from a Json file.
  3. PropertyConfigLoader: Load the properties from a Java properties file.
  4. EnvironmentConfigLoader: Load the properties from the Environment Variables. This will transform the environment variables so they can be used inside the project and stay consistent with the rest of the properties. For example having the variable GLOBAL_URL will result in the property global.url
    1. _ will become .
    2. - will become .
    3. The property name will become lowercase
  5. HoconConfigLoader: Load the properties from a Hocon file. This has many advantages over Json or Property (it is a superset of both) so I recommend this loader but not before taking a look at the project: https://github.com/typesafehub/config#using-hocon-the-json-superset
  6. YamlConfigLoader: Load the properties from a Yaml file.
  7. GitConfigLoader: Load the properties from a Git repository, possible giving the branch name or folder to denote different environments.
Clone this wiki locally