Class InstalledDependenciesSetup

java.lang.Object
de.iip_ecosphere.platform.support.setup.AbstractSetup
de.iip_ecosphere.platform.support.setup.InstalledDependenciesSetup

public class InstalledDependenciesSetup extends AbstractSetup
Provides access to installed dependencies on the actual resource, e.g., the location of a specific Java version or of Python. The instantiation process shall provide a YamlFile called installedDependencies.yml linking symbolic program/dependency names to installation folders where the respective binary can be found. The information shall be taken from service dependencies in the configuration model. Java versions shall be mapped to keys like "JAVAx" where x represents the Java major version, older just without the leading "1.", newer as the major version, see getJavaKey() for the actual version.
Author:
Holger Eichelberger, SSE
  • Field Details

  • Constructor Details

    • InstalledDependenciesSetup

      public InstalledDependenciesSetup()
      Sets up default values before overriding.
  • Method Details

    • setupDefaults

      private void setupDefaults()
      Sets up the default values.
    • addDefaultEntry

      private void addDefaultEntry(String key, File value)
      Adds a default location entry. Does not override existing values.
      Parameters:
      key - the key
      value - the value
    • getJavaKey

      public static String getJavaKey()
      Returns the program/dependency key for the actual Java version.
      Returns:
      the key
    • getLocations

      public Map<String,File> getLocations()
      Returns the locations.
      Returns:
      the locations
    • getLocation

      public File getLocation(String key)
      Returns the location for a given program/dependency key.
      Parameters:
      key - the key
      Returns:
      the location, may be null for none
    • getEnvironmentMapping

      public String getEnvironmentMapping(String key, String dflt)
      Returns an environment mapping for the given environment key. Environment mappings are generic environment key/name mappings and could, e.g., be used to map a service-specific Python Conda environment to an implemented environment produced during container generation.
      Parameters:
      key - the key
      dflt - the default value to return if there is no mapping
      Returns:
      the mapped value or dflt
    • setLocations

      public void setLocations(Map<String,File> locations)
      Changes the locations. [required by SnakeYaml]
      Parameters:
      locations - the locations
    • setEnvMappings

      public void setEnvMappings(Map<String,String> envMappings)
      Changes the locations. [required by SnakeYaml]
      Parameters:
      envMappings - the mappings
    • setLocation

      public void setLocation(String key, File location)
      Sets a single location, but ensures the default values.
      Parameters:
      key - the key to set
      location - the new location
    • readFromYaml

      public static InstalledDependenciesSetup readFromYaml(String fileName)
      Reads the given yaml file via the ResourceLoader, taking into account the system property PROPERTY_PATH, the current directory as additional resource folder and the file system root.
      Parameters:
      fileName - the file to read
      Returns:
      the setup instance, if not found the default instance
    • readFromYaml

      public static InstalledDependenciesSetup readFromYaml()
      Reads the default yaml file, taking into account the system property PROPERTY_PATH, the current directory as additional resource folder and the file system root.
      Returns:
      the setup instance, if not found the default instance
    • getInstance

      public static InstalledDependenciesSetup getInstance()
      Returns a singleton instance via readFromYaml().
      Returns:
      the instance
    • location

      public static File location(String key) throws ExecutionException
      Returns a location from getInstance() via getLocation(String), throws an exception if no such location is present.
      Parameters:
      key - the key to look for
      Returns:
      the location
      Throws:
      ExecutionException - if the key cannot be found