Class DirConfigSource
- java.lang.Object
-
- fish.payara.nucleus.microprofile.config.source.PayaraConfigSource
-
- fish.payara.nucleus.microprofile.config.source.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
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_DIR
-
Fields inherited from class fish.payara.nucleus.microprofile.config.source.PayaraConfigSource
configService, domainConfiguration, PROPERTY_PREFIX
-
-
Constructor Summary
Constructors Constructor Description DirConfigSource()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getName()
int
getOrdinal()
Map<String,String>
getProperties()
Set<String>
getPropertyNames()
String
getValue(String property)
static boolean
isAptDir(Path path)
Check path to be a directory, readable by us, but ignore if starting with a "." (as done for K8s secrets mounts).static boolean
isAptFile(Path path, BasicFileAttributes atts)
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.static String
parsePropertyNameFromPath(Path path, Path rootDir)
Parsing the relative path into a configuration property name.
-
-
-
Field Detail
-
DEFAULT_DIR
public static final String DEFAULT_DIR
- See Also:
- Constant Field Values
-
-
Method Detail
-
getProperties
public Map<String,String> getProperties()
- Specified by:
getProperties
in interfaceorg.eclipse.microprofile.config.spi.ConfigSource
-
getPropertyNames
public Set<String> getPropertyNames()
- Specified by:
getPropertyNames
in interfaceorg.eclipse.microprofile.config.spi.ConfigSource
- Overrides:
getPropertyNames
in classPayaraConfigSource
-
getOrdinal
public int getOrdinal()
- Specified by:
getOrdinal
in interfaceorg.eclipse.microprofile.config.spi.ConfigSource
-
getValue
public String getValue(String property)
- Specified by:
getValue
in interfaceorg.eclipse.microprofile.config.spi.ConfigSource
-
getName
public String getName()
- Specified by:
getName
in interfaceorg.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
-
-