Package alpine
Class Config
- java.lang.Object
-
- alpine.Config
-
public class Config extends Object
The Config class is responsible for reading the application.properties file.- Since:
- 1.0.0
- Author:
- Steve Springett
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConfig.AlpineKeystatic interfaceConfig.Key
-
Constructor Summary
Constructors Constructor Description Config()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidenableUnitTests()Enables unit tests by setting 'alpine.unittests.enabled' system property to true.StringgetApplicationBuildTimestamp()Returns the Application built timestamp.StringgetApplicationBuildUuid()Returns the Application UUID.StringgetApplicationName()Returns the Application component name.StringgetApplicationVersion()Returns the Application version.FilegetDataDirectorty()Returns the fully qualified path to the configured data directory.StringgetFrameworkBuildTimestamp()Returns the Alpine built timestamp.StringgetFrameworkBuildUuid()Returns the Alpine UUID.StringgetFrameworkName()Returns the Alpine component name.StringgetFrameworkVersion()Returns the Alpine version.static ConfiggetInstance()Returns an instance of the Config object.StringgetProperty(Config.Key key)Return the configured value for the specified Key.StringgetProperty(String key)Deprecated.use {getProperty(Key)}StringgetProperty(String key, String defaultValue)Deprecated.use {getProperty(Key)booleangetPropertyAsBoolean(Config.Key key)Return the configured value for the specified Key.intgetPropertyAsInt(Config.Key key)Return the configured value for the specified Key.longgetPropertyAsLong(Config.Key key)Return the configured value for the specified Key.StringgetPropertyOrFile(Config.AlpineKey key)Check if key with _FILE postfix appended is a defined property name, either in the environment or in the properties configuration.StringgetSystemUuid()Returns the UUID unique to a system deployment.static booleanisUnitTestsEnabled()Determins is unit tests are enabled by checking if the 'alpine.unittests.enabled' system property is set to true or false.
-
-
-
Method Detail
-
getInstance
public static Config getInstance()
Returns an instance of the Config object.- Returns:
- a Config object
- Since:
- 1.0.0
-
getSystemUuid
public String getSystemUuid()
Returns the UUID unique to a system deployment.- Returns:
- the UUID unique to a deployed system
- Since:
- 1.8.0
-
getFrameworkName
public String getFrameworkName()
Returns the Alpine component name.- Returns:
- the Alpine name
- Since:
- 1.0.0
-
getFrameworkVersion
public String getFrameworkVersion()
Returns the Alpine version.- Returns:
- the Alpine version
- Since:
- 1.0.0
-
getFrameworkBuildTimestamp
public String getFrameworkBuildTimestamp()
Returns the Alpine built timestamp.- Returns:
- the timestamp in which this version of Alpine was built
- Since:
- 1.0.0
-
getFrameworkBuildUuid
public String getFrameworkBuildUuid()
Returns the Alpine UUID.- Returns:
- the UUID unique to this build of Alpine
- Since:
- 1.3.0
-
getApplicationName
public String getApplicationName()
Returns the Application component name.- Returns:
- the Application name
- Since:
- 1.0.0
-
getApplicationVersion
public String getApplicationVersion()
Returns the Application version.- Returns:
- the Application version
- Since:
- 1.0.0
-
getApplicationBuildTimestamp
public String getApplicationBuildTimestamp()
Returns the Application built timestamp.- Returns:
- the timestamp in which this version of the Application was built
- Since:
- 1.0.0
-
getApplicationBuildUuid
public String getApplicationBuildUuid()
Returns the Application UUID.- Returns:
- the UUID unique to this build of the application
- Since:
- 1.3.0
-
getDataDirectorty
public File getDataDirectorty()
Returns the fully qualified path to the configured data directory. Expects a fully qualified path or a path starting with ~/ Defaults to ~/.alpine if data directory is not specified.- Returns:
- a File object of the data directory
- Since:
- 1.0.0
-
getProperty
public String getProperty(Config.Key key)
Return the configured value for the specified Key. As of v1.4.3, this method will first check if the key has been specified as an environment variable. If it has, the method will return the value. If it hasn't been specified in the environment, it will retrieve the value (and optional default value) from the properties configuration. This method is Docker-friendly in that configuration can be specified via environment variables which is a common method of configuration when configuration files are not easily accessible.- Parameters:
key- The Key to return the configuration for- Returns:
- a String of the value of the configuration
- Since:
- 1.0.0
-
getPropertyOrFile
public String getPropertyOrFile(Config.AlpineKey key)
Check if key with _FILE postfix appended is a defined property name, either in the environment or in the properties configuration. If yes, the named file is read and its content will be the key's value. This method is defined so that passwords can be read from docker secret.- Parameters:
key- The Key to return the configuration for- Returns:
- a String of the value of the configuration
- Since:
- 1.7.0
-
getPropertyAsInt
public int getPropertyAsInt(Config.Key key)
Return the configured value for the specified Key.- Parameters:
key- The Key to return the configuration for- Returns:
- a int of the value of the configuration
- Since:
- 1.0.0
-
getPropertyAsLong
public long getPropertyAsLong(Config.Key key)
Return the configured value for the specified Key.- Parameters:
key- The Key to return the configuration for- Returns:
- a long of the value of the configuration
- Since:
- 1.0.0
-
getPropertyAsBoolean
public boolean getPropertyAsBoolean(Config.Key key)
Return the configured value for the specified Key.- Parameters:
key- The Key to return the configuration for- Returns:
- a boolean of the value of the configuration
- Since:
- 1.0.0
-
getProperty
@Deprecated public String getProperty(String key)
Deprecated.use {getProperty(Key)}Return the configured value for the specified Key.- Parameters:
key- The Key to return the configuration for- Returns:
- a String of the value of the configuration
- Since:
- 1.0.0
-
getProperty
@Deprecated public String getProperty(String key, String defaultValue)
Deprecated.use {getProperty(Key)Return the configured value for the specified Key.- Parameters:
key- The String of the key to return the configuration fordefaultValue- The default value if the key cannot be found- Returns:
- a String of the value of the configuration
- Since:
- 1.0.0
-
isUnitTestsEnabled
public static boolean isUnitTestsEnabled()
Determins is unit tests are enabled by checking if the 'alpine.unittests.enabled' system property is set to true or false.- Returns:
- true if unit tests are enabled, false if not
- Since:
- 1.0.0
-
enableUnitTests
public static void enableUnitTests()
Enables unit tests by setting 'alpine.unittests.enabled' system property to true.- Since:
- 1.0.0
-
-