Class DirConfigSource

  • All Implemented Interfaces:
    org.eclipse.microprofile.config.spi.ConfigSource

    public class DirConfigSource
    extends PayaraConfigSource
    implements org.eclipse.microprofile.config.spi.ConfigSource
    Config Source that reads properties from files from a directory where filename is the property name and file contents is the property value.
    Since:
    5.2020.7
    • Constructor Detail

      • DirConfigSource

        public DirConfigSource()
    • Method Detail

      • getProperties

        public Map<String,​String> getProperties()
        Specified by:
        getProperties in interface org.eclipse.microprofile.config.spi.ConfigSource
      • getOrdinal

        public int getOrdinal()
        Specified by:
        getOrdinal in interface org.eclipse.microprofile.config.spi.ConfigSource
      • getValue

        public String getValue​(String property)
        Specified by:
        getValue in interface org.eclipse.microprofile.config.spi.ConfigSource
      • getName

        public String getName()
        Specified by:
        getName in interface org.eclipse.microprofile.config.spi.ConfigSource
      • isAptDir

        public static final boolean isAptDir​(Path path)
                                      throws IOException
        Check path to be a directory, readable by us, but ignore if starting with a "." (as done for K8s secrets mounts).
        Parameters:
        path -
        Returns:
        true if suitable, false if not.
        Throws:
        IOException - when path cannot be resolved, maybe because of a broken symlink.
      • isAptFile

        public static final boolean isAptFile​(Path path,
                                              BasicFileAttributes atts)
                                       throws IOException
        Check if the file exists (follows symlinks), is a regular file (following symlinks), is readable (following symlinks), the filename does not start with a "." (not following the symlink!) and the file is less than 512 KB.
        Parameters:
        path -
        Returns:
        true if suitable file, false if not.
        Throws:
        IOException - when path cannot be accessed or resolved etc.
      • parsePropertyNameFromPath

        public static final String parsePropertyNameFromPath​(Path path,
                                                             Path rootDir)
        Parsing the relative path into a configuration property name. Using dots to mark scopes based on directories plus keeping dots used in the files name.
        Parameters:
        path - The path to the property file
        Returns:
        The property name