Package restx.config

Class ConfigLoader

java.lang.Object
restx.config.ConfigLoader

public class ConfigLoader extends Object
User: xavierhanin Date: 9/24/13 Time: 11:54 PM
  • Constructor Details

    • ConfigLoader

      public ConfigLoader(com.google.common.base.Optional<String> env)
  • Method Details

    • fromResource

      public ConfigSupplier fromResource(String resource)
      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

      public ConfigSupplier fromFile(String path)
      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

      public String 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. 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

      protected void loadAllFromResource(List<ConfigElement> elements, String resource)
    • loadAllFromFile

      protected void loadAllFromFile(List<ConfigElement> elements, String path)
    • loadFileInto

      protected void loadFileInto(Path path, List<ConfigElement> elements)
    • loadResourceInto

      protected void loadResourceInto(String name, List<ConfigElement> elements)