Package com.verisign.epp.util
Class Environment
- java.lang.Object
-
- com.verisign.epp.util.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 theenvInitialize
methods. After the properties have been loaded, the values can be retrieved by using one of theget
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 aProperties
attribute in the following search order:
File system System classpathEnvironment
class ClassLoader
If the configuration file can not be located, anEnvException
is thrown.void
envInitialize(java.lang.String aConfigFile, java.lang.ClassLoader aClassLoader)
Loads configuration file properties into aProperties
attribute using a customClassLoader
.: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 theEnvironment
properties using a clientProperties
object.static void
setProperty(java.lang.String aProperty, java.lang.String aValue)
Sets an individual property.
-
-
-
Method Detail
-
envInitialize
public void envInitialize(java.lang.String aConfigFile) throws EnvException
Loads configuration file properties into aProperties
attribute in the following search order:
- File system
- System classpath
Environment
class ClassLoader
If the configuration file can not be located, anEnvException
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 aProperties
attribute using a customClassLoader
.:- Parameters:
aConfigFile
- File name of configuration fileaClassLoader
- JavaClassLoader
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 nameaDefaultValue
- Default value if property is not found- Returns:
- Property value if defined;
aDefaultValue
otherwise
-
setProperties
public static void setProperties(java.util.Properties aProperties)
Sets theEnvironment
properties using a clientProperties
object. This is an option to using a configuration file with one of theenvInitialize
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. IfaValue
isnull
than the property will be removed.- Parameters:
aProperty
- Name of propertyaValue
- Property value
-
-