Class JPPFConfiguration

java.lang.Object
org.jppf.utils.JPPFConfiguration

public final class JPPFConfiguration extends Object
Utility class for loading and accessing the JPPF configuration properties.

The configuration file path is set through the system property CONFIG_PROPERTY, whose value is "jppf.config".
As an example, it can be configured by adding the JVM argument "-Djppf.config=jppf-config.properties".

Modified to allow users to get configuration properties from an alternate source. Any user-provided class that implements JPPFConfiguration.ConfigurationSource and returns a stream with the same configuration values provided in the properties file.
The configuration source must then configured via the system property -Djppf.config.plugin = mypackage.MyConfigurationSource"

Author:
Laurent Cohen, Jonathan Newbrough
  • Field Details

    • CONFIG_PROPERTY

      public static final String CONFIG_PROPERTY
      Name of the system property holding the location of the JPPF configuration file.
      See Also:
    • CONFIG_PLUGIN_PROPERTY

      public static final String CONFIG_PLUGIN_PROPERTY
      The name of the system property used to specified an alternate JPPF configuration source.
      See Also:
    • DEFAULT_FILE

      public static final String DEFAULT_FILE
      Default location of the JPPF configuration file.
      See Also:
  • Method Details

    • getProperties

      public static TypedProperties getProperties()
      Get the configuration properties.
      Returns:
      a TypedProperties instance.
    • get

      public static <T> T get(JPPFProperty<T> property)
      Get the value of a predefined property. This is the same as calling JPPFConfiguration.getProperties().get(property).
      Type Parameters:
      T - the type of the property.
      Parameters:
      property - the property whose value to retrieve.
      Returns:
      the value of the property according to its type.
    • get

      public static <T> T get(JPPFProperty<T> property, String... parameters)
      Get the value of a predefined parametrized property. This is the same as calling JPPFConfiguration.getProperties().get(property, parameters).
      Type Parameters:
      T - the type of the property.
      Parameters:
      property - the property whose value to retrieve.
      parameters - the values to replace the property's parameters with.
      Returns:
      the value of the property according to its type.
      Since:
      6.0
    • set

      public static <T> TypedProperties set(JPPFProperty<T> property, T value)
      Set the value of a predefined property. This is the same as calling JPPFConfiguration.getProperties().set(property, value).
      Type Parameters:
      T - the type of the property.
      Parameters:
      property - the property whose value to set.
      value - the value to set.
      Returns:
      the TypedProperties instance in which the value is set.
    • set

      public static <T> TypedProperties set(JPPFProperty<T> property, T value, String... parameters)
      Set the value of a predefined parametrized property. This is the same as calling JPPFConfiguration.getProperties().set(property, value, parameters).
      Type Parameters:
      T - the type of the property.
      Parameters:
      property - the property whose value to set.
      value - the value to set.
      parameters - the values to replace the property's parameters with.
      Returns:
      the TypedProperties instance in which the value is set.
      Since:
      6.0
    • remove

      public static <T> T remove(JPPFProperty<T> property)
      Remove the predefined property. This is the same as calling JPPFConfiguration.getProperties().remove(property).
      Type Parameters:
      T - the type of the property.
      Parameters:
      property - the property whose value to retrieve.
      Returns:
      the value of the property according to its type.
    • remove

      public static <T> T remove(JPPFProperty<T> property, String... parameters)
      Remove the predefined parametrized property. This is the same as calling JPPFConfiguration.getProperties().remove(property).
      Type Parameters:
      T - the type of the property.
      Parameters:
      property - the property whose value to retrieve.
      parameters - the values to replace the property's parameters with.
      Returns:
      the value of the property according to its type.
      Since:
      6.0
    • containsProperty

      public static boolean containsProperty(JPPFProperty<?> property)
      Determine whether the JPPF configuration contains the specified property. The lookkup is performed on the property's name first, then on its aliases if the name is not found.
      Parameters:
      property - the property to look for.
      Returns:
      true if the property or one of its aliases is found, false otherwise.
      Since:
      6.0
    • reset

      public static void reset()
      Reset and reload the JPPF configuration. This allows reloading the configuration from a different source or file (after changing the values of the related system properties for instance).
    • reset

      public static void reset(TypedProperties newConfig)
      Reset the JPPF configuration with the specified properties.
      Parameters:
      newConfig - the properties to use as the new configuration.
      Since:
      6.0
    • getConfigurationSourceReader

      public static Reader getConfigurationSourceReader(String configurationSourceName) throws Exception
      Get an inputStream for a properties file located by the specified configuration source.
      Parameters:
      configurationSourceName - fully qualified name of a class implementing JPPFConfiguration.ConfigurationSource or JPPFConfiguration.ConfigurationSourceReader.
      Returns:
      an input stream that can be used to load the properties.
      Throws:
      Exception - if any error occurs while trying to obtain the stream.