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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      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.
    • Method Detail

      • retrieveOsDirectory

        java.io.File retrieveOsDirectory​(java.io.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:
        System.getProperties()
      • 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 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:
        retrieveOsConfigurationKey(String)