Package alpine
Class Config
java.lang.Object
alpine.Config
The Config class is responsible for reading the application.properties file.
- Since:
- 1.0.0
- Author:
- Steve Springett
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidEnables unit tests by setting 'alpine.unittests.enabled' system property to true.Returns the Application built timestamp.Returns the Application UUID.Returns the Application component name.Returns the Application version.Returns the fully qualified path to the configured data directory.Returns the Alpine built timestamp.Returns the Alpine UUID.Returns the Alpine component name.Returns the Alpine version.static ConfigReturns an instance of the Config object.getPassThroughProperties(String prefix) Get "pass-through" properties with a givenprefix.getProperty(Config.Key key) Return the configured value for the specified Key.getProperty(String key) Deprecated.getProperty(String key, String defaultValue) Deprecated.use {getProperty(Key)booleanReturn the configured value for the specified Key.intReturn the configured value for the specified Key.Return the configured value for the specified Key.longReturn the configured value for the specified Key.Check if key with _FILE postfix appended is a defined property name, either in the environment or in the properties configuration.Returns the UUID unique to a system deployment.static booleanDetermins is unit tests are enabled by checking if the 'alpine.unittests.enabled' system property is set to true or false.
-
Constructor Details
-
Config
public Config()
-
-
Method Details
-
getInstance
Returns an instance of the Config object.- Returns:
- a Config object
- Since:
- 1.0.0
-
getSystemUuid
Returns the UUID unique to a system deployment.- Returns:
- the UUID unique to a deployed system
- Since:
- 1.8.0
-
getFrameworkName
Returns the Alpine component name.- Returns:
- the Alpine name
- Since:
- 1.0.0
-
getFrameworkVersion
Returns the Alpine version.- Returns:
- the Alpine version
- Since:
- 1.0.0
-
getFrameworkBuildTimestamp
Returns the Alpine built timestamp.- Returns:
- the timestamp in which this version of Alpine was built
- Since:
- 1.0.0
-
getFrameworkBuildUuid
Returns the Alpine UUID.- Returns:
- the UUID unique to this build of Alpine
- Since:
- 1.3.0
-
getApplicationName
Returns the Application component name.- Returns:
- the Application name
- Since:
- 1.0.0
-
getApplicationVersion
Returns the Application version.- Returns:
- the Application version
- Since:
- 1.0.0
-
getApplicationBuildTimestamp
Returns the Application built timestamp.- Returns:
- the timestamp in which this version of the Application was built
- Since:
- 1.0.0
-
getApplicationBuildUuid
Returns the Application UUID.- Returns:
- the UUID unique to this build of the application
- Since:
- 1.3.0
-
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
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
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
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
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
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
-
getPropertyAsList
Return the configured value for the specified Key.- Parameters:
key- The Key to return the configuration for- Returns:
- a list of the comma-separated values of the configuration, or an empty list otherwise
- Since:
- 2.2.5
-
getPassThroughProperties
Get "pass-through" properties with a givenprefix.Pass-through properties do not have corresponding
Config.Keys. Their main use-case is to allow users to configure certain aspects of libraries and frameworks used by Alpine, without Alpine having to introduceConfig.AlpineKeys for every single option.Properties are read from both environment variables, and
PROP_FILE. When a property is defined in both environment andapplication.properties, environment takes precedence.Properties must be prefixed with
ALPINE_(for environment variables) oralpine.(forapplication.properties) respectively. The Alpine prefix will be removed in keys of the returnedMap, but the givenprefixwill be retained.- Parameters:
prefix- Prefix of the properties to fetch- Returns:
- A
Mapcontaining the matched properties - Since:
- 2.3.0
-
getProperty
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.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
-
getProperty(Key)}