Class DefaultOsConfigurationService

  • All Implemented Interfaces:
    OsConfigurationService

    public class DefaultOsConfigurationService
    extends java.lang.Object
    implements OsConfigurationService
    Standard implementation of the OsConfigurationService interface. This implementation works with String distance comparison for computing the best matching subdirectory or property key.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.io.FileFilter DIRECTORY_FILTER
      FileFilter accepting directories only.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DIRECTORY_FILTER

        public static final java.io.FileFilter DIRECTORY_FILTER
        FileFilter accepting directories only. Also directories which name start with a dot (.) are skipped.
    • Constructor Detail

      • DefaultOsConfigurationService

        public DefaultOsConfigurationService()
    • Method Detail

      • retrieveOsSpecificProperty

        public 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.
        Specified by:
        retrieveOsSpecificProperty in interface OsConfigurationService
        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:
        OsConfigurationService.retrieveOsSpecificProperty(String, String)
      • retrieveOsDirectory

        public java.io.File retrieveOsDirectory​(java.io.File rootDirectory)
        Evaluates the directory structure of the given rootDirectory and return the best matching os specific folder.
        Specified by:
        retrieveOsDirectory in interface OsConfigurationService
        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:
        OsConfigurationService.retrieveOsDirectory(File)
      • doRetrieveOsDirectory

        protected java.io.File doRetrieveOsDirectory​(java.io.File root)
        Resolves the os specific directory (without the caching).
        Parameters:
        root - the root directory to analyse.
        Returns:
        the best matching directory within the given root for the current operation system and architecture.
      • getOsName

        public java.lang.String getOsName()
        Accesses this systems operation system name. This property is preset to System.getProperty("os.name") , but can be overwritten through spring configuration.
        Returns:
        this systems operation system name.
        See Also:
        System.getProperties()
      • setOsName

        public void setOsName​(java.lang.String osName)
        Sets this systems operation system name. This property is preset to System.getProperty("os.name"), but can be overwritten through spring configuration.
        Parameters:
        osName - the name of this systems operation system.
        See Also:
        System.getProperties()
      • getOsArch

        public java.lang.String getOsArch()
        Accesses this systems operation system architecture. This property is preset to System.getProperty("os.arch"), but can be overwritten through spring configuration.
        Returns:
        this systems operation system architecture name.
        See Also:
        System.getProperties()
      • setOsArch

        public void setOsArch​(java.lang.String osArch)
        Sets this systems operation system architecture name. This property is preset to System.getProperty("os.arch"), but can be overwritten through spring configuration.
        Parameters:
        osArch - the name of this systems operation system architecture.
        See Also:
        System.getProperties()