Class EnvironmentConfiguration

All Implemented Interfaces:
Cloneable, Configuration, EventSource, ImmutableConfiguration, SynchronizerSupport

A Configuration implementation that reads the platform specific environment variables using the map returned by System.getenv().

This configuration implementation is read-only. It allows read access to the defined OS environment variables, but their values cannot be changed. Any attempts to add or remove a property will throw an UnsupportedOperationException

Usage of this class is easy: After an instance has been created the get methods provided by the Configuration interface can be used for querying environment variables, e.g.:

 Configuration envConfig = new EnvironmentConfiguration();
 System.out.println("JAVA_HOME=" + envConfig.getString("JAVA_HOME");
 
Since:
1.5
  • Constructor Details

  • Method Details

    • addPropertyDirect

      protected void addPropertyDirect(String key, Object value)
      Adds a property to this configuration. Because this configuration is read-only, this operation is not allowed and will cause an exception.
      Overrides:
      addPropertyDirect in class MapConfiguration
      Parameters:
      key - the key of the property to be added
      value - the property value
    • clearInternal

      protected void clearInternal()
      Removes all properties from this configuration. Because this configuration is read-only, this operation is not allowed and will cause an exception.
      Overrides:
      clearInternal in class AbstractConfiguration
    • clearPropertyDirect

      protected void clearPropertyDirect(String key)
      Removes a property from this configuration. Because this configuration is read-only, this operation is not allowed and will cause an exception.
      Overrides:
      clearPropertyDirect in class MapConfiguration
      Parameters:
      key - the key of the property to be removed