Interface OsConfigurationService
-
- All Known Implementing Classes:
DefaultOsConfigurationService
public interface OsConfigurationServiceService to retrieve operation system specific configurations.This service can be used to provide different system specific implementations (of e.g. an executable) and pick the correct location to use.
The directory structure within the specified
rootFolderrespectively the structure of property keys must be as follows:- The first directory within the root denotes the os.name
- The folders within the latter directory match the os.arch
So for example:
root | |-- windows | | | |-- i386 | | | |-- amd64 | |-- linux | | | |-- i386 | | | |-- x86_64 | |-- mac_os | |-- amd64Note, that the matching to the directories are done by a string distance algorithm or other fuzzy stuff to increase fault tolerance on various system/JVM combinations.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringretrieveOsConfigurationKey(java.lang.String prefix)Retrieves the best available configuration/property key for the given prefix.java.io.FileretrieveOsDirectory(java.io.File rootDirectory)Evaluates the directory structure of the givenrootDirectoryand return the best matching os specific folder.java.lang.StringretrieveOsSpecificProperty(java.lang.String prefix, java.lang.String defaultValue)Retrieves the best available configuration/property value instead of just retrieving the best matching key.
-
-
-
Method Detail
-
retrieveOsDirectory
java.io.File retrieveOsDirectory(java.io.File rootDirectory)
Evaluates the directory structure of the givenrootDirectoryand return the best matching os specific folder.- Parameters:
rootDirectory- the base directory containing the two level folder hierarchy of os.name/os.arch- Returns:
- the directory matching best to the system.
- See Also:
System.getProperties()
-
retrieveOsConfigurationKey
java.lang.String retrieveOsConfigurationKey(java.lang.String prefix) throws NoSuchConfigurationKeyExceptionRetrieves the best available configuration/property key for the given prefix. This method behaves exactly the same asretrieveOsDirectory(File), but operates on theConfigurationServiceproperties instead of file system directories.- Parameters:
prefix- the common prefix of all property keys to obey- Returns:
- the property key matching best this system
- Throws:
NoSuchConfigurationKeyException- if no configuration keys for the given prefix exist- See Also:
retrieveOsDirectory(File)
-
retrieveOsSpecificProperty
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.- Parameters:
prefix- the common prefix of all property keys to obeydefaultValue- the default value to return is no such property exists- Returns:
- the property value of the best matching key or the given
defaultValueif no such key exists. - See Also:
retrieveOsConfigurationKey(String)
-
-