Interface OsConfigurationService

All Known Implementing Classes:
DefaultOsConfigurationService

public interface OsConfigurationService
Service 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 rootFolder respectively 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
            |
            |-- amd64
 

Note, 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

    Modifier and Type
    Method
    Description
    Retrieves the best available configuration/property key for the given prefix.
    retrieveOsDirectory(File rootDirectory)
    Evaluates the directory structure of the given rootDirectory and return the best matching os specific folder.
    retrieveOsSpecificProperty(String prefix, String defaultValue)
    Retrieves the best available configuration/property value instead of just retrieving the best matching key.
  • Method Details

    • retrieveOsDirectory

      File retrieveOsDirectory(File rootDirectory)
      Evaluates the directory structure of the given rootDirectory and 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:
    • retrieveOsConfigurationKey

      String retrieveOsConfigurationKey(String prefix) throws NoSuchConfigurationKeyException
      Retrieves the best available configuration/property key for the given prefix. This method behaves exactly the same as retrieveOsDirectory(File), but operates on the ConfigurationService properties 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:
    • retrieveOsSpecificProperty

      String retrieveOsSpecificProperty(String prefix, 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 obey
      defaultValue - the default value to return is no such property exists
      Returns:
      the property value of the best matching key or the given defaultValue if no such key exists.
      See Also: