Class EnvironmentConfiguration

  • All Implemented Interfaces:
    java.lang.Cloneable, Configuration

    public class EnvironmentConfiguration
    extends MapConfiguration

    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
    Version:
    $Id: EnvironmentConfiguration.java 1210171 2011-12-04 18:32:07Z oheger $
    Author:
    Nicolas De Loof
    • Constructor Detail

      • EnvironmentConfiguration

        public EnvironmentConfiguration()
        Create a Configuration based on the environment variables.
        See Also:
        System.getenv()
    • Method Detail

      • addPropertyDirect

        protected void addPropertyDirect​(java.lang.String key,
                                         java.lang.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
      • clearProperty

        public void clearProperty​(java.lang.String key)
        Removes a property from this configuration. Because this configuration is read-only, this operation is not allowed and will cause an exception.
        Specified by:
        clearProperty in interface Configuration
        Overrides:
        clearProperty in class AbstractConfiguration
        Parameters:
        key - the key of the property to be removed
      • clear

        public void clear()
        Removes all properties from this configuration. Because this configuration is read-only, this operation is not allowed and will cause an exception.
        Specified by:
        clear in interface Configuration
        Overrides:
        clear in class AbstractConfiguration