Package restx.config
Class ConfigLoader
java.lang.Object
restx.config.ConfigLoader
User: xavierhanin
Date: 9/24/13
Time: 11:54 PM
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionProvides a ConfigSupplier loading config from a file.fromResource(String resource) Provides a ConfigSupplier loading config from a classpath resource.protected voidloadAllFromFile(List<ConfigElement> elements, String path) protected voidloadAllFromResource(List<ConfigElement> elements, String resource) protected voidloadFileInto(Path path, List<ConfigElement> elements) protected voidloadResourceInto(String name, List<ConfigElement> elements) locationKeyForResource(String resource) Gives the name of the system property that can be used to provide a file location to load to override settings for a particular resource.
-
Constructor Details
-
ConfigLoader
-
-
Method Details
-
fromResource
Provides a ConfigSupplier loading config from a classpath resource. The name of the resource provided must not contain the extension, which must be .properties The loader will first try to load config from a file which location is provided by a system property, the name of the property being the name returned by #locationKeyForResource. Then it will try to load an env specific resource named [resource].[env].properties. Then it will load a resource named [resource].properties.- Parameters:
resource- the path of the resource to load, without extension.- Returns:
- a ConfigSupplier ready to load corresponding resource.
-
fromFile
Provides a ConfigSupplier loading config from a file. The loader will first try to load an env specific file named [path].[env].properties. Then it will try to load a file named [path].properties. Then it will try to load a file named [path] (without extension).- Parameters:
path- the path of the file to load config from.- Returns:
- a ConfigSupplier ready to load corresponding file.
-
locationKeyForResource
Gives the name of the system property that can be used to provide a file location to load to override settings for a particular resource. By defaut the name is equal to the resource name where slashes `/` are replaced by dots `.`, with `.location` suffix. Eg. `myapp/settings` becomes `myapp.settings.location`- Parameters:
resource- the resource for which the system property name should be provided.- Returns:
- the system property name.
-
loadAllFromResource
-
loadAllFromFile
-
loadFileInto
-
loadResourceInto
-