-
Notifications
You must be signed in to change notification settings - Fork 3
Usage
Include this dependency
<dependency>
<groupId>org.irenical.jindy</groupId>
<artifactId>jindy-api</artifactId>
<version>1.0</version>
</dependency>
From anywhere in your code, call
Config config = ConfigFactory.getConfig();With the returned Config object you can do the following
Fetch a value
config.getString("my.property");Fetch a value or a default if none is defined
config.getString("my.property","my default string");Force error handling if a value is not defined
try{
config.getMandatoryString("my.property");
} catch(ConfigNotFoundException noConfig){
...
}Caution: Do not include an actual implementation of a binding in your library, as that will force all projects downstream to contain it.
Same as in a library but you have to include an actual implementation (a binding). No library in your upstream should include a Jindy binding, as it would force that upon your application. Multiple bindings are not allowed, you should get a runtime error if more than one (or none) are detected.
jindy-api only provides the API, not any implementation of actual configuration retrieval. For the Config API to work in runtime, you must add a valid binding to your final application. You can build one from scratch, or extend one of the following: