public final class UtlEnv extends Object
The environment maintained here is used by various platform components in 2 fashions. First and foremost it provides a way for overall global configuration values to be specified in the environment or system properties to augment configuration at runtime. Secondly, in the absence of higher level configuration mechanism being initialized, it provides a way for low level platform components to source configuration before higher level configuration mechanism have been initialized that can reinitialize or augment the environment dynamically for other configuration sources.
When higher level configuration mechanisms are used the initial environment loaded by this
class can be thought of as bootstrap environment until initialized. In support of this this
class provides an initialize(Properties)
method than can be used by applications to
indicate when the environment can be considered to have been full initialized,
UtlConstants.APP_PROPFILE_PROPNAME
if exists
and can be loaded. UtlConstants.APP_PROPFILE_DEFAULT
itself is resolved by first looking in System.getenv(String)
or in System.getProperty(String)
if not defined in the environment.
System.getenv()
are applied by taking them and replacing any instance of '_' with a '.'
This class MAY be used by end users, however its usage is not suppport unless one is directed to do so by Neeve Support.
Constructor and Description |
---|
UtlEnv() |
Modifier and Type | Method and Description |
---|---|
static Properties |
getEnvProps()
Returns the environment properties.
|
static Properties |
getEnvPropsNoWarn()
Returns the normalized environment properties.
|
static String |
getLocalHostAddress()
Deprecated.
This method has been moved to
UtlNet |
static String |
getLocalHostAddressForDisplay(String defaultValue)
Deprecated.
This method has been moved to
UtlNet |
static InetAddress |
getLocalHostInetAddress()
Deprecated.
This method has been moved to
UtlNet |
static String |
getLocalHostName()
Deprecated.
This method has been moved to
UtlNet |
static String |
getLocalHostNameForDisplay(String defaultValue)
Deprecated.
This method has been moved to
UtlNet |
static String |
getPid()
Deprecated.
This method has been moved to
UtlProc |
static String |
getValue(String name)
Get the value of a property from the environment props.
|
static boolean |
getValue(String name,
boolean defValue)
Convenience method to return an environment property value as a boolean value
|
static double |
getValue(String name,
double defValue)
Convenience method to return a property from the environment as a numeric value.
|
static int |
getValue(String name,
int defValue)
Convenience method to return a property from the environment as an int value.
|
static short |
getValue(String name,
short defValue)
Convenience method to return a property from the environment as an short value.
|
static String |
getValue(String name,
String defValue)
Convenience method to return a property value as a String value from the environment
|
static void |
initialize(Properties env)
Initializes the environment.
|
static void |
reset()
Resets the environment to its pre-initialized state.
|
static void |
update(Properties val)
Update the environment.
|
public static final void reset()
This method can be used to reset the environment to its original state. It is not intended for use in production environments and serves primarily as a mechanism for clearing out the environment in unit testing scenarios.
This method IS NOT recommend to be used by end users and may be removed or altered without notice
public static void initialize(Properties env)
env
- The environment to initialize.public static void update(Properties val)
props
- The props to updatepublic static Properties getEnvPropsNoWarn()
public static Properties getEnvProps()
The caller should not modify the returned set of properties. All mutative operations on the environment should be done via calls to this class instead.
public static String getValue(String name)
name
- The property namepublic static final boolean getValue(String name, boolean defValue)
name
- The property namedefValue
- The default property value to return in case the property
could not be found in the property table.
This method is a convenience method that returns a property value as a
boolean value. It uses getValue(java.lang.String)
to retrieve the property
value. The default value is returned in case the no property with the
provided name exists in the property table.
public static final double getValue(String name, double defValue)
name
- The property namedefValue
- The default property value to return in case the property
could not be found in the property table.
This method is a convenience method that returns a property value as a
numeric value. It uses getValue(java.lang.String)
to retrieve the property
value. The default value is returned in case the no property with the
provided name exists in the property table.
public static final int getValue(String name, int defValue)
name
- The property namedefValue
- The default property value to return in case the property
could not be found in the property table.
This method is a convenience method that returns a property value as an
int value. It uses getValue(String)
to retrieve the property
value. The default value is returned in case the no property with the
provided name exists in the property table.
public static final short getValue(String name, short defValue)
name
- The property namedefValue
- The default property value to return in case the property
could not be found in the property table.
This method is a convenience method that returns a property value as a
numeric value. It uses getValue(java.lang.String)
to retrieve the property
value. The default value is returned in case the no property with the
provided name exists in the property table.
public static String getValue(String name, String defValue)
name
- The property namedefValue
- The default property value to return in case the property
could not be found in the property table.
This method is a convenience method that returns a property value as a
string value. It uses getValue(java.lang.String)
to retrieve the property
value. The default value is returned in case the no property with the
provided name exists in the property table.
@Deprecated public static final String getPid()
UtlProc
This method returns the process id of the current process
@Deprecated public static final InetAddress getLocalHostInetAddress() throws UnknownHostException
UtlNet
InetAddress
representing the local host IP + hostname.UnknownHostException
- Thrown if a local InetAddress could not
be determined.@Deprecated public static final String getLocalHostNameForDisplay(String defaultValue)
UtlNet
defaultValue
- The value to return if a local host name could not be
determined.
This method returns the name of the local host machine on which the X process is running. The defaultValue is returned if the local host name could not be determined for whatever reason
@Deprecated public static final String getLocalHostName() throws UnknownHostException
UtlNet
This method returns the local host name using the following:
- InetAddress.getLocalHost().getHostName
.
If a host name could not be determined, then this method throws
an UnknownHostException exception.
UnknownHostException
- Thrown if the local host name could not
be determined via InetAddress.getLocalHost().getHostName
@Deprecated public static final String getLocalHostAddressForDisplay(String defaultValue)
UtlNet
defaultValue
- The value to return if a local host address could not be
determined.
This method returns the address of the local host machine on which the X process
is running as returned by InetAddress.getLocalHost().getHostAddress
.
The defaultValue is returned if the local host address could not be determined
for whatever reason
@Deprecated public static final String getLocalHostAddress() throws UnknownHostException
UtlNet
This method returns the local host address using the following:
- InetAddress.getLocalHost().getHostAddress
.
If a host address could not be determined, then this method throws
an UnknownHostException exception.
UnknownHostException
- Thrown if the local host address could not
be determined via InetAddress.getLocalHost().getHostAddress
Copyright © 2019 Neeve Research, LLC. All Rights Reserved.