public class DefaultOsConfigurationService extends java.lang.Object implements OsConfigurationService
OsConfigurationService interface. This implementation works with String
distance comparison for computing the best matching subdirectory or property key.| Modifier and Type | Field and Description |
|---|---|
static java.io.FileFilter |
DIRECTORY_FILTER
FileFilter accepting directories only. |
| Constructor and Description |
|---|
DefaultOsConfigurationService() |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
doRetrieveOsConfigurationKey(java.lang.String prefix)
Does the actual property key resolution (without the cache).
|
protected java.io.File |
doRetrieveOsDirectory(java.io.File root)
Resolves the os specific directory (without the caching).
|
ConfigurationService |
getConfigurationService()
Accesses the
ConfigurationService to use for property (key) resolution. |
java.lang.String |
getOsArch()
Accesses this systems operation system architecture.
|
java.lang.String |
getOsName()
Accesses this systems operation system name.
|
java.lang.String |
retrieveOsConfigurationKey(java.lang.String prefix)
Retrieves the best available configuration/property key for the given prefix.
|
java.io.File |
retrieveOsDirectory(java.io.File rootDirectory)
Evaluates the directory structure of the given
rootDirectory and return the best matching
os specific folder. |
java.lang.String |
retrieveOsSpecificProperty(java.lang.String prefix,
java.lang.String defaultValue)
Retrieves the best available configuration/property value instead of just retrieving the best matching key.
|
void |
setConfigurationService(ConfigurationService configurationService)
Sets the
ConfigurationService to use for property (key) resolution. |
void |
setOsArch(java.lang.String osArch)
Sets this systems operation system architecture name.
|
void |
setOsName(java.lang.String osName)
Sets this systems operation system name.
|
public static final java.io.FileFilter DIRECTORY_FILTER
FileFilter accepting directories only. Also directories which name start with a dot (.) are skipped.public java.lang.String retrieveOsSpecificProperty(java.lang.String prefix,
java.lang.String defaultValue)
retrieveOsSpecificProperty in interface OsConfigurationServiceprefix - the common prefix of all property keys to obeydefaultValue - the default value to return is no such property existsdefaultValue if no such key exists.OsConfigurationService.retrieveOsSpecificProperty(String, String)public java.lang.String retrieveOsConfigurationKey(java.lang.String prefix)
throws NoSuchConfigurationKeyException
OsConfigurationService.retrieveOsDirectory(File), but operates on the
ConfigurationService properties instead of file
system directories.retrieveOsConfigurationKey in interface OsConfigurationServiceprefix - the common prefix of all property keys to obeyNoSuchConfigurationKeyException - if no configuration keys for the given prefix existOsConfigurationService.retrieveOsConfigurationKey(java.lang.String)protected java.lang.String doRetrieveOsConfigurationKey(java.lang.String prefix)
throws NoSuchConfigurationKeyException
prefix - the prefix of the configuration key in questionNoSuchConfigurationKeyException - if no such configuration key existsOsConfigurationService.retrieveOsConfigurationKey(String)public java.io.File retrieveOsDirectory(java.io.File rootDirectory)
rootDirectory and return the best matching
os specific folder.retrieveOsDirectory in interface OsConfigurationServicerootDirectory - the base directory containing the two level folder hierarchy of
os.name/os.archOsConfigurationService.retrieveOsDirectory(File)protected java.io.File doRetrieveOsDirectory(java.io.File root)
root - the root directory to analyse.root for the current operation system and
architecture.public ConfigurationService getConfigurationService()
ConfigurationService to use for property (key) resolution.ConfigurationService to usepublic void setConfigurationService(ConfigurationService configurationService)
ConfigurationService to use for property (key) resolution. This setter is for Spring IoC wiring.configurationService - the ConfigurationService to usepublic java.lang.String getOsName()
System.getProperty("os.name")
, but can be overwritten through spring configuration.System.getProperties()public void setOsName(java.lang.String osName)
System.getProperty("os.name"),
but can be overwritten through spring configuration.osName - the name of this systems operation system.System.getProperties()public java.lang.String getOsArch()
System.getProperty("os.arch"), but can be overwritten through spring configuration.System.getProperties()public void setOsArch(java.lang.String osArch)
System.getProperty("os.arch"), but can be overwritten through spring configuration.osArch - the name of this systems operation system architecture.System.getProperties()Copyright © 2018 SAP SE. All Rights Reserved.