Class InstalledDependenciesSetup
- java.lang.Object
-
- de.iip_ecosphere.platform.support.setup.AbstractSetup
-
- de.iip_ecosphere.platform.support.iip_aas.config.AbstractSetup
-
- de.iip_ecosphere.platform.services.environment.InstalledDependenciesSetup
-
public class InstalledDependenciesSetup extends de.iip_ecosphere.platform.support.iip_aas.config.AbstractSetupProvides 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 calledinstalledDependencies.ymllinking 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, seegetJavaKey()for the actual version.- Author:
- Holger Eichelberger, SSE
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_FNAMEName of the default configuration file with extension (no path).static java.lang.StringDEFAULT_NAMEJust the name of the default configuration file, no extension, no path.private static InstalledDependenciesSetupinstancestatic java.lang.StringKEY_JAVA_11static java.lang.StringKEY_JAVA_8static java.lang.StringKEY_PREFIX_JAVAThe prefix for Java program/dependency keys.private java.util.Map<java.lang.String,java.io.File>locationsstatic java.lang.StringPROPERTY_PATH
-
Constructor Summary
Constructors Constructor Description InstalledDependenciesSetup()Sets up default values before overriding.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddDefaultEntry(java.lang.String key, java.io.File value)Adds a default location entry.static InstalledDependenciesSetupgetInstance()Returns a singleton instance viareadFromYaml().static java.lang.StringgetJavaKey()Returns the program/dependency key for the actual Java version.java.io.FilegetLocation(java.lang.String key)Returns the location for a given program/dependency key.java.util.Map<java.lang.String,java.io.File>getLocations()Returns the locations.static java.io.Filelocation(java.lang.String key)Returns a location fromgetInstance()viagetLocation(String), throws an exception if no such location is present.static InstalledDependenciesSetupreadFromYaml()Reads the default yaml file, taking into account the system propertyPROPERTY_PATH, the current directory as additional resource folder and the file system root.static InstalledDependenciesSetupreadFromYaml(java.lang.String fileName)Reads the given yaml file via theResourceLoader, taking into account the system propertyPROPERTY_PATH, the current directory as additional resource folder and the file system root.voidsetLocation(java.lang.String key, java.io.File location)Sets a single location, but ensures the default values.voidsetLocations(java.util.Map<java.lang.String,java.io.File> locations)Changes the locations.private voidsetupDefaults()Sets up the default values.
-
-
-
Field Detail
-
PROPERTY_PATH
public static final java.lang.String PROPERTY_PATH
- See Also:
- Constant Field Values
-
DEFAULT_NAME
public static final java.lang.String DEFAULT_NAME
Just the name of the default configuration file, no extension, no path.- See Also:
- Constant Field Values
-
DEFAULT_FNAME
public static final java.lang.String DEFAULT_FNAME
Name of the default configuration file with extension (no path).- See Also:
- Constant Field Values
-
KEY_PREFIX_JAVA
public static final java.lang.String KEY_PREFIX_JAVA
The prefix for Java program/dependency keys.- See Also:
- Constant Field Values
-
KEY_JAVA_8
public static final java.lang.String KEY_JAVA_8
- See Also:
- Constant Field Values
-
KEY_JAVA_11
public static final java.lang.String KEY_JAVA_11
- See Also:
- Constant Field Values
-
instance
private static InstalledDependenciesSetup instance
-
locations
private java.util.Map<java.lang.String,java.io.File> locations
-
-
Method Detail
-
setupDefaults
private void setupDefaults()
Sets up the default values.
-
addDefaultEntry
private void addDefaultEntry(java.lang.String key, java.io.File value)Adds a default location entry. Does not override existing values.- Parameters:
key- the keyvalue- the value
-
getJavaKey
public static java.lang.String getJavaKey()
Returns the program/dependency key for the actual Java version.- Returns:
- the key
-
getLocations
public java.util.Map<java.lang.String,java.io.File> getLocations()
Returns the locations.- Returns:
- the locations
-
getLocation
public java.io.File getLocation(java.lang.String key)
Returns the location for a given program/dependency key.- Parameters:
key- the key- Returns:
- the location, may be null for none
-
setLocations
public void setLocations(java.util.Map<java.lang.String,java.io.File> locations)
Changes the locations. [required by SnakeYaml]- Parameters:
locations- the locations
-
setLocation
public void setLocation(java.lang.String key, java.io.File location)Sets a single location, but ensures the default values.- Parameters:
key- the key to setlocation- the new location
-
readFromYaml
public static InstalledDependenciesSetup readFromYaml(java.lang.String fileName)
Reads the given yaml file via theResourceLoader, taking into account the system propertyPROPERTY_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 propertyPROPERTY_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 viareadFromYaml().- Returns:
- the instance
-
location
public static java.io.File location(java.lang.String key) throws java.util.concurrent.ExecutionExceptionReturns a location fromgetInstance()viagetLocation(String), throws an exception if no such location is present.- Parameters:
key- the key to look for- Returns:
- the location
- Throws:
java.util.concurrent.ExecutionException- if the key cannot be found
-
-