Class ConfigurationUtils

java.lang.Object
org.jppf.utils.configuration.ConfigurationUtils

public class ConfigurationUtils extends Object
Extract JPPF properties defined as public constants in a given class.
Author:
Laurent Cohen
  • Constructor Details

    • ConfigurationUtils

      public ConfigurationUtils()
  • Method Details

    • allProperties

      public static List<JPPFProperty<?>> allProperties(Class<?> c)
      Get the list of all predefined configuration properties in the specified class.
      Parameters:
      c - the class containing the proeprties constants.
      Returns:
      A list of JPPFProperty instances.
    • hidePasswords

      public static Properties hidePasswords(Properties props)
      Parameters:
      props - the properties to clean up.
      Returns:
      a new TypedProperties object where passwords are replaced with a dummy string.
    • parseDataSize

      public static long parseDataSize(String source)
      Parse a memory size value in format [size][unit] where:
      • size is a positive long value
      • 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'
      Examples: 2g, 1536M, 123456k, 123456789b
      Parameters:
      source - the string to parse.
      Returns:
      parse the used memory threshold that triggers user data offloading, from the configuration.
    • getFromEnv

      public static String getFromEnv(String envVariable, String defaultValue)
      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

      public static String getFromEnv(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.
      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

      public static boolean getBooleanFromEnv(String envVariable, boolean defaultValue)
      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.