| java.lang.Object com.knowgate.misc.Environment
Environment | public class Environment (Code) | | Reads and keeps in memory properties from .cnf initialization files.
author: Sergio Montoro Ten version: 3.0 |
DEFAULT_PROFILES_DIR | public static String DEFAULT_PROFILES_DIR(Code) | | |
getEnvVar | public static String getEnvVar(String sVarName) throws IllegalArgumentException(Code) | | Get value for an environment variable.
This is not a Pure Java method since it uses the Runtime obeject for calling
OS specific shell commands.
Parameters: sVarName - Name of the variable to be readed. Value of variable or null if no environment variable with such name was found. throws: IllegalArgumentException - If there is a Malformed \\uxxxx encoding or any other type of intrinsic error at the environment variables values |
getEnvVar | public static String getEnvVar(String sVarName, String sDefault) throws IllegalArgumentException(Code) | | Get value for an environment variable.
This is not a Pure Java method since it uses the Runtime obeject for calling
OS specific shell commands.
Parameters: sVarName - Name of the variable to be readed. Value of variable or sDefault if no environment variable with such name was found. |
getProfile | public static Properties getProfile(String sProfile)(Code) | | Get a Properties collection from a .CNF file
Property files must be in the directory pointed by a operating system environment variable names
KNOWGATE_PROFILES. If KNOWGATE_PROFILES environment variable is not found, the files will
be seeked by default on C:\WINNT\ or C:\WINDOWS\ on Window Systems and /etc/ on UNIX systems.
Parameters: sProfile - Properties file to read (for example "hipergate.cnf") since: v2.2 The behaviour of this function has changed: it first tries to get KNOWGATE_PROFILES since: from Java environment variables as set on startup "java -DKNOWGATE_PROFILES=..." if there is no since: Java property named KNOWGATE_PROFILES then operating system environment variabled are scanned and since: last if neither is found the default C:\WINNT\ C:\WINDOWS\ or /etc/ is returned |
getProfilePath | public static String getProfilePath(String sProfile, String sVarName)(Code) | | Get a property from a .CNF file representing a file path.
This method is equivalent to getProfileVar except that a
file separator is always appended to the end of the readed value.
Parameters: sProfile - .CNF file name Parameters: sVarName - Property Name Value terminated with a file separator or null if no property with such name was found. |
getProfileVar | public static String getProfileVar(String sProfile, String sVarName)(Code) | | Get a single property from a .CNF file.
Properties are readed once from disk and then cached in memory.
If .CNF file is changed, refresh() method must be called for refreshing
in-memory cached values.
Parameters: sProfile - .CNF file name Parameters: sVarName - Property Name Value of property or null if no property with such name was found. |
getProfileVar | public static String getProfileVar(String sProfile, String sVarName, String sDefault)(Code) | | Get a single property from a .CNF file.
Parameters: sProfile - .CNF file name Parameters: sVarName - Property Name Parameters: sDefault - Default Value Value of property or sDefault if no property with such name was found. |
getProfileVarSet | public static Set getProfileVarSet(String sProfile)(Code) | | Get names of all properties in a profile
Parameters: sProfile - Profile Name Set of property names |
getProfilesSet | public static Set getProfilesSet()(Code) | | Get a Set with all loaded profiles names
Set of profile names |
getTempDir | public static String getTempDir() throws IllegalArgumentException(Code) | | Get temporary directory
For UNIX Sytems this function always return "/tmp/". For Windows Systems getTempDir() returns the value set at the environmentvariable "TEMP" or C:\\%WINDIR%\\TEMP\\ if TEMP variable is not set. throws: IllegalArgumentException - |
loadProfile | public static Properties loadProfile(String sProfile, String sPath)(Code) | | Load a Profile from a Properties file
The loaded Profile is cached in memory and will be returned in
future calls to getProfile()
If profile had been already loaded, then it is overwritten.
Parameters: sProfile - Profile name, for example "hipergate" Parameters: sPath - Full path to properties file, fo example "/etc/knowgate/hipergate.cnf" |
refresh | public static void refresh()(Code) | | Refresh in-memory cached properties by re-reading then from disk files.
|
setProfileVar | public static void setProfileVar(String sProfile, String sVarName, String sVarValue)(Code) | | Set value for a profile property
Value is change in memory cache but not saved to disk.
Parameters: sProfile - Profile Name Parameters: sVarName - Property Name Parameters: sVarValue - Prioperty Value |
updateSystemTime | public static void updateSystemTime(long lTime)(Code) | | Update system time
This is an alpha testing method, do not use in production environments.
Parameters: lTime - New System Date |
|
|