java.lang.Object
org.gcube.informationsystem.resourceregistry.configuration.ServiceConfiguration

public class ServiceConfiguration extends Object
The configuration of the service, read from "service.yaml" in WEB-INF/classes.

The file is a YAML mapping of sections (database, redis), each a mapping of keys to scalar values. Every value is read as its string form, so a quoted and an unquoted scalar give the same value. A missing file is an error.

Author:
Luca Frosini (ISTI - CNR)
  • Field Details

    • FILENAME

      public static final String FILENAME
      Name of the configuration file of the service, on the classpath.
      See Also:
  • Constructor Details

    • ServiceConfiguration

      public ServiceConfiguration()
      Reads "service.yaml" from the classpath.
      Throws:
      IllegalStateException - if the file is missing or is not a mapping of sections
  • Method Details

    • getWebappRoot

      public File getWebappRoot()
      Returns the root of the deployed webapp, found from where "service.yaml" is read (<webapp>/WEB-INF/classes/"service.yaml").
      Returns:
      the root, or null when "service.yaml" is not read from a directory of the file system (e.g. from a jar)
    • section

      public Map<String,String> section(String name)
      Returns a section of the configuration.
      Parameters:
      name - the name of the section
      Returns:
      its keys and values, or null when the file has no such section