Package org.jppf.utils.configuration
Class ConfigurationUtils
java.lang.Object
org.jppf.utils.configuration.ConfigurationUtils
Extract JPPF properties defined as public constants in a given class.
- Author:
- Laurent Cohen
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<JPPFProperty<?>>allProperties(Class<?> c) Get the list of all predefined configuration properties in the specified class.static booleangetBooleanFromEnv(String envVariable, boolean defaultValue) Get a boolean value from a specified environment variable, or a default value if the variable is not set.static StringgetFromEnv(String envVariable, String defaultValue) Get a value from a specified environment variable, or a default value if the variable is not set.static StringgetFromEnv(String envVar1, String envVar2, String defaultValue) Get a value from a first environment variable, or a second environment variable if the first is not set, or a default value if the variables are not set.static PropertieshidePasswords(Properties props) static longparseDataSize(String source) Parse a memory size value in format [size][unit] where: size is a positivelongvalue unit is one of 'g', 'm', 'k', 'b' or uppercase equivalents 'G', 'M', 'K', 'B'.
-
Constructor Details
-
ConfigurationUtils
public ConfigurationUtils()
-
-
Method Details
-
allProperties
Get the list of all predefined configuration properties in the specified class.- Parameters:
c- the class containing the proeprties constants.- Returns:
- A list of
JPPFPropertyinstances.
-
hidePasswords
- Parameters:
props- the properties to clean up.- Returns:
- a new
TypedPropertiesobject where passwords are replaced with a dummy string.
-
parseDataSize
Parse a memory size value in format [size][unit] where:- size is a positive
longvalue - unit is one of 'g', 'm', 'k', 'b' or uppercase equivalents 'G', 'M', 'K', 'B'. If the unit string is anything else then it defaults to 'b'
- Parameters:
source- the string to parse.- Returns:
- parse the used memory threshold that triggers user data offloading, from the configuration.
- size is a positive
-
getFromEnv
Get a value from a specified environment variable, or a default value if the variable is not set.- Parameters:
envVariable- the environment variable name.defaultValue- the default value to use.- Returns:
- the value of the enviornement variable if it is not null, or the default value.
-
getFromEnv
Get a value from a first environment variable, or a second environment variable if the first is not set, or a default value if the variables are not set.- Parameters:
envVar1- the first environment variable name.envVar2- the second environment variable name.defaultValue- the default value to use.- Returns:
- the value of the enviornement variable if it is not null, or the default value.
-
getBooleanFromEnv
Get a boolean value from a specified environment variable, or a default value if the variable is not set.- Parameters:
envVariable- the environment variable name.defaultValue- the default value to use.- Returns:
- the value of the enviornement variable if it is not null, or the default value.
-