Class Environment

java.lang.Object
com.verisign.epp.util.Environment
Direct Known Subclasses:
EPPEnv

public abstract class Environment extends 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 Properties
    Properties loaded from the configuration file
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    envInitialize(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(String aConfigFile, ClassLoader aClassLoader)
    Loads configuration file properties into a Properties attribute using a custom ClassLoader.:
    static String
    getEnv(String aProperty)
    This Method gets the given value from properties.
    static String
    getOption(String aProperty)
    This Method gets a property value, but will not throw an exception if it does not exist.
    static String
    getProperty(String aProperty)
    Gets a property loaded from the EPP configuration file.
    static String
    getProperty(String aProperty, 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
    Sets the Environment properties using a client Properties object.
    static void
    setProperty(String aProperty, 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 Details

    • properties

      protected static Properties properties
      Properties loaded from the configuration file
  • Constructor Details

    • Environment

      public Environment()
  • Method Details

    • envInitialize

      public void envInitialize(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(String aConfigFile, 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 String getEnv(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 String getOption(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 String getProperty(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 String getProperty(String aProperty, 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(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(String aProperty, String aValue)
      Sets an individual property. If aValue is null than the property will be removed.
      Parameters:
      aProperty - Name of property
      aValue - Property value