Class DefaultOsConfigurationService
- java.lang.Object
-
- de.hybris.platform.mediaconversion.os.config.DefaultOsConfigurationService
-
- All Implemented Interfaces:
OsConfigurationService
public class DefaultOsConfigurationService extends java.lang.Object implements OsConfigurationService
Standard implementation of theOsConfigurationServiceinterface. 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.FileFilterDIRECTORY_FILTERFileFilteraccepting directories only.
-
Constructor Summary
Constructors Constructor Description DefaultOsConfigurationService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringdoRetrieveOsConfigurationKey(java.lang.String prefix)Does the actual property key resolution (without the cache).protected java.io.FiledoRetrieveOsDirectory(java.io.File root)Resolves the os specific directory (without the caching).ConfigurationServicegetConfigurationService()Accesses theConfigurationServiceto use for property (key) resolution.java.lang.StringgetOsArch()Accesses this systems operation system architecture.java.lang.StringgetOsName()Accesses this systems operation system name.java.lang.StringretrieveOsConfigurationKey(java.lang.String prefix)Retrieves the best available configuration/property key for the given prefix.java.io.FileretrieveOsDirectory(java.io.File rootDirectory)Evaluates the directory structure of the givenrootDirectoryand return the best matching os specific folder.java.lang.StringretrieveOsSpecificProperty(java.lang.String prefix, java.lang.String defaultValue)Retrieves the best available configuration/property value instead of just retrieving the best matching key.voidsetConfigurationService(ConfigurationService configurationService)Sets theConfigurationServiceto use for property (key) resolution.voidsetOsArch(java.lang.String osArch)Sets this systems operation system architecture name.voidsetOsName(java.lang.String osName)Sets this systems operation system name.
-
-
-
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:
retrieveOsSpecificPropertyin interfaceOsConfigurationService- Parameters:
prefix- the common prefix of all property keys to obeydefaultValue- the default value to return is no such property exists- Returns:
- the property value of the best matching key or the given
defaultValueif no such key exists. - See Also:
OsConfigurationService.retrieveOsSpecificProperty(String, String)
-
retrieveOsConfigurationKey
public java.lang.String retrieveOsConfigurationKey(java.lang.String prefix) throws NoSuchConfigurationKeyExceptionRetrieves the best available configuration/property key for the given prefix. This method behaves exactly the same asOsConfigurationService.retrieveOsDirectory(File), but operates on theConfigurationServiceproperties instead of file system directories.- Specified by:
retrieveOsConfigurationKeyin interfaceOsConfigurationService- 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:
OsConfigurationService.retrieveOsConfigurationKey(java.lang.String)
-
doRetrieveOsConfigurationKey
protected java.lang.String doRetrieveOsConfigurationKey(java.lang.String prefix) throws NoSuchConfigurationKeyExceptionDoes the actual property key resolution (without the cache).- Parameters:
prefix- the prefix of the configuration key in question- Returns:
- the os specific configuration key
- Throws:
NoSuchConfigurationKeyException- if no such configuration key exists- See Also:
OsConfigurationService.retrieveOsConfigurationKey(String)
-
retrieveOsDirectory
public java.io.File retrieveOsDirectory(java.io.File rootDirectory)
Evaluates the directory structure of the givenrootDirectoryand return the best matching os specific folder.- Specified by:
retrieveOsDirectoryin interfaceOsConfigurationService- 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
rootfor the current operation system and architecture.
-
getConfigurationService
public ConfigurationService getConfigurationService()
Accesses theConfigurationServiceto use for property (key) resolution.- Returns:
- the
ConfigurationServiceto use
-
setConfigurationService
public void setConfigurationService(ConfigurationService configurationService)
Sets theConfigurationServiceto use for property (key) resolution. This setter is for Spring IoC wiring.- Parameters:
configurationService- theConfigurationServiceto use
-
getOsName
public java.lang.String getOsName()
Accesses this systems operation system name. This property is preset toSystem.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 toSystem.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 toSystem.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 toSystem.getProperty("os.arch"), but can be overwritten through spring configuration.- Parameters:
osArch- the name of this systems operation system architecture.- See Also:
System.getProperties()
-
-