Package org.jppf.utils
Class JPPFConfiguration
java.lang.Object
org.jppf.utils.JPPFConfiguration
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceImplement this interface to provide an alternate configuration source via anInputStream.static interfaceImplement this interface to provide an alternate configuration source via aReader. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the system property used to specified an alternate JPPF configuration source.static final StringName of the system property holding the location of the JPPF configuration file.static final StringDefault location of the JPPF configuration file. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancontainsProperty(JPPFProperty<?> property) Determine whether the JPPF configuration contains the specified property.static <T> Tget(JPPFProperty<T> property) Get the value of a predefined property.static <T> Tget(JPPFProperty<T> property, String... parameters) Get the value of a predefined parametrized property.static ReadergetConfigurationSourceReader(String configurationSourceName) Get an inputStream for a properties file located by the specified configuration source.static TypedPropertiesGet the configuration properties.static <T> Tremove(JPPFProperty<T> property) Remove the predefined property.static <T> Tremove(JPPFProperty<T> property, String... parameters) Remove the predefined parametrized property.static voidreset()Reset and reload the JPPF configuration.static voidreset(TypedProperties newConfig) Reset the JPPF configuration with the specified properties.static <T> TypedPropertiesset(JPPFProperty<T> property, T value) Set the value of a predefined property.static <T> TypedPropertiesset(JPPFProperty<T> property, T value, String... parameters) Set the value of a predefined parametrized property.
-
Field Details
-
CONFIG_PROPERTY
Name of the system property holding the location of the JPPF configuration file.- See Also:
-
CONFIG_PLUGIN_PROPERTY
The name of the system property used to specified an alternate JPPF configuration source.- See Also:
-
DEFAULT_FILE
Default location of the JPPF configuration file.- See Also:
-
-
Method Details
-
getProperties
Get the configuration properties.- Returns:
- a TypedProperties instance.
-
get
Get the value of a predefined property. This is the same as callingJPPFConfiguration.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
Get the value of a predefined parametrized property. This is the same as callingJPPFConfiguration.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
Set the value of a predefined property. This is the same as callingJPPFConfiguration.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
TypedPropertiesinstance in which the value is set.
-
set
Set the value of a predefined parametrized property. This is the same as callingJPPFConfiguration.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
TypedPropertiesinstance in which the value is set. - Since:
- 6.0
-
remove
Remove the predefined property. This is the same as callingJPPFConfiguration.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
Remove the predefined parametrized property. This is the same as callingJPPFConfiguration.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
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:
trueif the property or one of its aliases is found,falseotherwise.- 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
Reset the JPPF configuration with the specified properties.- Parameters:
newConfig- the properties to use as the new configuration.- Since:
- 6.0
-
getConfigurationSourceReader
Get an inputStream for a properties file located by the specified configuration source.- Parameters:
configurationSourceName- fully qualified name of a class implementingJPPFConfiguration.ConfigurationSourceorJPPFConfiguration.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.
-