-
Notifications
You must be signed in to change notification settings - Fork 6
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:
- DefaultConfigLoader: This loader can take static map or vararg of pairs to create a loader from it.
- JsonConfigLoader: Load the properties from a Json file.
- PropertyConfigLoader: Load the properties from a Java properties file.
- 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 propertyglobal.url
-
_
will become.
-
-
will become.
- The property name will become lowercase
-
- 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
- YamlConfigLoader: Load the properties from a Yaml file.
- GitConfigLoader: Load the properties from a Git repository, possible giving the branch name or folder to denote different environments.