-
Notifications
You must be signed in to change notification settings - Fork 6
Providers
Javier Diaz edited this page Aug 19, 2018
·
2 revisions
A provider is just the presentation layer. It will convert the String that comes from the Loader and give you the object type that you are asking for. It will make the conversion every time you ask as you can ask for a different type (String/Int/Long/BigInteger for a number, for example), if you want to avoid this, take a look at CachedConfigProvider
You can create your own Provider
by implementing ConfigProvider
or extending DefaultConfigProvider
, keep in mind that the default provider already has the parsing so it is always a good practice to extend it.
Examples and core implementations here
Built in providers:
- DefaultConfigProvider: Base class for all the other providers. It has the basic functionality for a Provider. (You can obviously ignore it if implementing a new provider)
- CachedConfigProvider: This provider will cache the calls into a map and use the cached one once the same call is done again. When the method
reload
is called this cache will be cleared. - OverrideConfigProvider: With this provider you can input a list of Loaders in order of precedence and it will return the first one that is not null/empty. So you can override properties for example:
EnvironmentConfigLoader -> JsonConfigLoader
it would pick first from Environment and then from Json.