public class DefaultOsConfigurationService extends 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 FileFilter |
DIRECTORY_FILTER
FileFilter accepting directories only. |
| Constructor and Description |
|---|
DefaultOsConfigurationService() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
doRetrieveOsConfigurationKey(String prefix)
Does the actual property key resolution (without the cache).
|
protected File |
doRetrieveOsDirectory(File root)
Resolves the os specific directory (without the caching).
|
ConfigurationService |
getConfigurationService()
Accesses the
ConfigurationService to use for property (key) resolution. |
String |
getOsArch()
Accesses this systems operation system architecture.
|
String |
getOsName()
Accesses this systems operation system name.
|
String |
retrieveOsConfigurationKey(String prefix)
Retrieves the best available configuration/property key for the given prefix.
|
File |
retrieveOsDirectory(File rootDirectory)
Evaluates the directory structure of the given
rootDirectory and return the best matching
os specific folder. |
String |
retrieveOsSpecificProperty(String prefix,
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(String osArch)
Sets this systems operation system architecture name.
|
void |
setOsName(String osName)
Sets this systems operation system name.
|
public static final FileFilter DIRECTORY_FILTER
FileFilter accepting directories only. Also directories which name start with a dot (.) are skipped.public String retrieveOsSpecificProperty(String prefix, 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 String retrieveOsConfigurationKey(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 String doRetrieveOsConfigurationKey(String prefix) throws NoSuchConfigurationKeyException
prefix - the prefix of the configuration key in questionNoSuchConfigurationKeyException - if no such configuration key existsOsConfigurationService.retrieveOsConfigurationKey(String)public File retrieveOsDirectory(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 File doRetrieveOsDirectory(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 String getOsName()
System.getProperty("os.name")
, but can be overwritten through spring configuration.System.getProperties()public void setOsName(String osName)
System.getProperty("os.name"),
but can be overwritten through spring configuration.osName - the name of this systems operation system.System.getProperties()public String getOsArch()
System.getProperty("os.arch"), but can be overwritten through spring configuration.System.getProperties()public void setOsArch(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 © 2017 SAP SE. All Rights Reserved.