Class Environment

  • Direct Known Subclasses:
    EPPEnv

    public abstract class Environment
    extends java.lang.Object
    This class loads properties from a properties configuration file with one of the envInitialize methods. After the properties have been loaded, the values can be retrieved by using one of the get methods.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.util.Properties properties
      Properties loaded from the configuration file
    • Constructor Summary

      Constructors 
      Constructor Description
      Environment()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void envInitialize​(java.lang.String aConfigFile)
      Loads configuration file properties into a Properties attribute in the following search order:

      File system System classpath Environment class ClassLoader
      If the configuration file can not be located, an EnvException is thrown.
      void envInitialize​(java.lang.String aConfigFile, java.lang.ClassLoader aClassLoader)
      Loads configuration file properties into a Properties attribute using a custom ClassLoader.:
      static java.lang.String getEnv​(java.lang.String aProperty)
      This Method gets the given value from properties.
      static java.lang.String getOption​(java.lang.String aProperty)
      This Method gets a property value, but will not throw an exception if it does not exist.
      static java.lang.String getProperty​(java.lang.String aProperty)
      Gets a property loaded from the EPP configuration file.
      static java.lang.String getProperty​(java.lang.String aProperty, java.lang.String aDefaultValue)
      Gets a property loaded from the EPP configuration file and if it doesn't exist, will return the passed default value (aDefaultValue).
      static void setProperties​(java.util.Properties aProperties)
      Sets the Environment properties using a client Properties object.
      static void setProperty​(java.lang.String aProperty, java.lang.String aValue)
      Sets an individual property.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • properties

        protected static java.util.Properties properties
        Properties loaded from the configuration file
    • Constructor Detail

      • Environment

        public Environment()
    • Method Detail

      • envInitialize

        public void envInitialize​(java.lang.String aConfigFile)
                           throws EnvException
        Loads configuration file properties into a Properties attribute in the following search order:

        1. File system
        2. System classpath
        3. Environment class ClassLoader

        If the configuration file can not be located, an EnvException is thrown.
        Parameters:
        aConfigFile - - File name of configuration file
        Throws:
        EnvException - Error finding or loading configuration file
      • envInitialize

        public void envInitialize​(java.lang.String aConfigFile,
                                  java.lang.ClassLoader aClassLoader)
                           throws EnvException
        Loads configuration file properties into a Properties attribute using a custom ClassLoader.:
        Parameters:
        aConfigFile - File name of configuration file
        aClassLoader - Java ClassLoader to load the configuration file from.
        Throws:
        EnvException - Error finding or loading configuration file
      • getEnv

        public static java.lang.String getEnv​(java.lang.String aProperty)
                                       throws EnvException
        This Method gets the given value from properties. It is to provide the higher layers easy access to properties
        Parameters:
        aProperty - - this String contains property name.
        Returns:
        Trimmed property value
        Throws:
        EnvException - Property is not defined
      • getOption

        public static java.lang.String getOption​(java.lang.String aProperty)
        This Method gets a property value, but will not throw an exception if it does not exist.
        Parameters:
        aProperty - Property name
        Returns:
        Trimmed property value if defined; null otherwise
      • getProperty

        public static java.lang.String getProperty​(java.lang.String aProperty)
        Gets a property loaded from the EPP configuration file. This method simply returns the raw property value with no trimming.
        Parameters:
        aProperty - Property name
        Returns:
        Property value if defined; null otherwise
      • getProperty

        public static java.lang.String getProperty​(java.lang.String aProperty,
                                                   java.lang.String aDefaultValue)
        Gets a property loaded from the EPP configuration file and if it doesn't exist, will return the passed default value (aDefaultValue).
        Parameters:
        aProperty - Property name
        aDefaultValue - Default value if property is not found
        Returns:
        Property value if defined; aDefaultValue otherwise
      • setProperties

        public static void setProperties​(java.util.Properties aProperties)
        Sets the Environment properties using a client Properties object. This is an option to using a configuration file with one of the envInitialize methods.
        Parameters:
        aProperties - A set of EPP configuration properties
      • setProperty

        public static void setProperty​(java.lang.String aProperty,
                                       java.lang.String aValue)
        Sets an individual property. If aValue is null than the property will be removed.
        Parameters:
        aProperty - Name of property
        aValue - Property value