nl.uva.vlet
Class Global

java.lang.Object
  extended by nl.uva.vlet.Global

public class Global
extends java.lang.Object

Global system variables, runtime environment etc. Use getProperty() to check environment variables, System properties, and/or user configuration file(s) (all in one method).


Field Summary
static java.lang.String ARCH_LINUX
           
static java.lang.String ARCH_WINDOWS
           
static java.lang.String FIREWALL_PORT_RANGE
           
static java.lang.String GLOBUS_TCP_PORT_RANGE
          Globus enviroment string
static java.lang.String GRID_CERTIFICATE_LOCATION
           
static java.lang.String GRID_PROXY_LOCATION
           
static java.lang.String JAVA_OS_ARCH
           
static java.lang.String JAVA_OS_NAME
           
static java.lang.String JAVA_OS_VERSION
           
static java.lang.String PASSIVE_MODE
           
static java.lang.String SKIP_FLOPPY_SCAN
           
static java.lang.String VADAPTORS_PROP
           
static java.lang.String VERSION
           
static java.lang.String X509_USER_PROXY
          X509_USER_PROXY environment variable
 
Constructor Summary
Global()
           
 
Method Summary
static void debugPrint(java.lang.Object o, java.lang.String msg)
           
static void debugPrintException(java.lang.String className, VlException e)
          convenience method to check and print the VlException
static void debugPrintln(java.lang.Object o, java.lang.String msg)
           
static void debugPrintStacktrace(java.lang.Exception e)
           
static void errorPrint(java.lang.Object o, java.lang.String string)
           
static void errorPrintln(java.lang.Object o, java.lang.String string)
           
static void errorPrintStacktrace(java.lang.Throwable e)
           
static java.lang.String getArch()
           
static boolean getBoolProperty(java.lang.String name, boolean defVal)
          Returns boolean property or the default value
static VRL getCodeBaseLocation()
          Returns base location of installed code of Global class
static VAttributeSet getConfigurationAttributes()
          Return configurable properties as AttributeSet
static java.io.PrintStream getDebugStream()
           
static java.io.PrintStream getErrorStream()
           
static int[] getFirewallPortRange()
           
static java.lang.String getFirewallPortRangeString()
           
static java.lang.String getGridCertificateLocation()
          Return OPTIONAL grid certificate location can be null.
static java.lang.String getGridProxyLocation()
          Return OPTIONAL grid proxy location.
static VRL getHelpUrl(java.lang.String string)
           
static java.lang.String getHostname()
           
static VRL getInstallationBinDir()
          Returns vlet.install.bindir property or (default) VLET_INSTALL/bin
static VRL getInstallationConfigDir()
          Returns vlet.install.sysconfdir property or (default) VLET_INSTALL/etc
static VRL getInstallationDocDir()
          Returns vlet.install.libdir property or (default) VLET_INSTALL/lib
static VRL getInstallationLibDir()
          Returns vlet.install.libdir property or (default) VLET_INSTALL/lib
static VRL getInstallBaseDir()
          Returns base dir of installed software a.k.a VLET_INSTALL.
static java.lang.String getOSName()
           
static java.lang.String getOSVersion()
           
static boolean getPassiveMode()
          When true only passive connections are allowed.
static java.lang.String getProperty(java.lang.String name)
          Unified Global getProperty/getEnv method.
static boolean getShowDebug()
           
static java.lang.String getSystemProperty(java.lang.String key)
          Only query system properties, do NOT consult user properties or environment variables
static VRL getUserConfigDir()
          Get VFS compatible User Configuration VRL.
static java.lang.String getUserHome()
          Returns "user.home" system property ($HOME under unix).
static VRL getUserHomeLocation()
          Get VFS compatible User Home VRL.
static java.lang.String getUsername()
          Returns "user.name" system property.
static java.lang.String getVersion()
           
static java.lang.String getX50UserProxyLocation()
           
static void init()
          Even though this method does nothing, the class Global will be initialized ! This because this class is referenced (a method is called)! The real initialization is done in the class object.
static boolean isLinux()
           
static boolean isWindows()
           
static void loadJarsFrom(VRL location)
          Loads all jars found in the specified location.
static java.util.Properties loadProperties(java.net.URL url)
           
static java.util.Properties loadProperties(VRL loc)
          Load properties file from specified location.
IMPORTANT: When this method is used and the URL stream factory handler HAS NOT BEEN SET, only default url schemes can be used ! (file:/,http://).
static java.util.Properties loadPropertiesFromClasspath(java.lang.String urlstr)
          Load a property file specified on the classpath
static void messagePrint(java.lang.Object o, java.lang.String string)
           
static void messagePrintln(java.lang.Object source, int level, java.lang.String message)
           
static void messagePrintln(java.lang.Object o, java.lang.String string)
           
static java.lang.String[] parseArguments(java.lang.String[] args)
          Parses property arguments in the style: -Dname=val.
static void saveProperties(VRL loc, java.util.Properties props)
          Save properties file to specified location.
static void setDebug(boolean b)
           
static boolean setFireWallPortRange(java.lang.String rangestr)
           
static void setPassiveMode(boolean val)
           
static void setSystemProperty(java.lang.String name, java.lang.String value)
           
static void setUserProperty(java.lang.String name, java.lang.String value)
          Only user property can be set.
static void setVerbose(int v)
           
static boolean toggleShowDebug()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X509_USER_PROXY

public static final java.lang.String X509_USER_PROXY
X509_USER_PROXY environment variable

See Also:
Constant Field Values

GLOBUS_TCP_PORT_RANGE

public static final java.lang.String GLOBUS_TCP_PORT_RANGE
Globus enviroment string

See Also:
Constant Field Values

FIREWALL_PORT_RANGE

public static final java.lang.String FIREWALL_PORT_RANGE
See Also:
Constant Field Values

VERSION

public static final java.lang.String VERSION
See Also:
Constant Field Values

JAVA_OS_ARCH

public static final java.lang.String JAVA_OS_ARCH
See Also:
Constant Field Values

JAVA_OS_NAME

public static final java.lang.String JAVA_OS_NAME
See Also:
Constant Field Values

JAVA_OS_VERSION

public static final java.lang.String JAVA_OS_VERSION
See Also:
Constant Field Values

ARCH_LINUX

public static final java.lang.String ARCH_LINUX
See Also:
Constant Field Values

ARCH_WINDOWS

public static final java.lang.String ARCH_WINDOWS
See Also:
Constant Field Values

SKIP_FLOPPY_SCAN

public static final java.lang.String SKIP_FLOPPY_SCAN
See Also:
Constant Field Values

PASSIVE_MODE

public static final java.lang.String PASSIVE_MODE
See Also:
Constant Field Values

GRID_PROXY_LOCATION

public static final java.lang.String GRID_PROXY_LOCATION
See Also:
Constant Field Values

GRID_CERTIFICATE_LOCATION

public static final java.lang.String GRID_CERTIFICATE_LOCATION
See Also:
Constant Field Values

VADAPTORS_PROP

public static final java.lang.String VADAPTORS_PROP
See Also:
Constant Field Values
Constructor Detail

Global

public Global()
Method Detail

setUserProperty

public static void setUserProperty(java.lang.String name,
                                   java.lang.String value)
Only user property can be set.


getUserHome

public static final java.lang.String getUserHome()
Returns "user.home" system property ($HOME under unix). Can be overriden if in the installation property the value 'user.home' has been defined which may be a relative path to the installion for personalized installation settings.

See INSTALLDIR/etc/vletrc.prop, value "user.home".


getUserHomeLocation

public static final VRL getUserHomeLocation()
Get VFS compatible User Home VRL. By avoiding location file paths and (re)use the VFS interface, file and configuration can be stored anywhere ! Use this one instead of getUserHome().

Returns:

getUserConfigDir

public static final VRL getUserConfigDir()
Get VFS compatible User Configuration VRL. By avoiding location file paths and (re)use the VFS interface, file and configuration information can be stored anywhere ! Default is $HOME/.vletrc

Returns:

getUsername

public static final java.lang.String getUsername()
Returns "user.name" system property. $USER under unix


getInstallBaseDir

public static final VRL getInstallBaseDir()
Returns base dir of installed software a.k.a VLET_INSTALL. Dynamically tries to figure out where it is started from.

If VLET_INSTALL is set, it will return this value as VRL. else the startup will be used and strip from "/lib/.jar"


getInstallationConfigDir

public static VRL getInstallationConfigDir()
Returns vlet.install.sysconfdir property or (default) VLET_INSTALL/etc


getInstallationLibDir

public static VRL getInstallationLibDir()
Returns vlet.install.libdir property or (default) VLET_INSTALL/lib


getInstallationDocDir

public static VRL getInstallationDocDir()
Returns vlet.install.libdir property or (default) VLET_INSTALL/lib


getInstallationBinDir

public static VRL getInstallationBinDir()
Returns vlet.install.bindir property or (default) VLET_INSTALL/bin


getSystemProperty

public static java.lang.String getSystemProperty(java.lang.String key)
Only query system properties, do NOT consult user properties or environment variables


setDebug

public static void setDebug(boolean b)

getShowDebug

public static boolean getShowDebug()

toggleShowDebug

public static boolean toggleShowDebug()

errorPrint

public static void errorPrint(java.lang.Object o,
                              java.lang.String string)

errorPrintln

public static void errorPrintln(java.lang.Object o,
                                java.lang.String string)

messagePrint

public static void messagePrint(java.lang.Object o,
                                java.lang.String string)

messagePrintln

public static void messagePrintln(java.lang.Object o,
                                  java.lang.String string)

debugPrint

public static void debugPrint(java.lang.Object o,
                              java.lang.String msg)

debugPrintln

public static void debugPrintln(java.lang.Object o,
                                java.lang.String msg)

getErrorStream

public static java.io.PrintStream getErrorStream()

getDebugStream

public static java.io.PrintStream getDebugStream()

debugPrintStacktrace

public static void debugPrintStacktrace(java.lang.Exception e)

errorPrintStacktrace

public static void errorPrintStacktrace(java.lang.Throwable e)

getHostname

public static java.lang.String getHostname()

parseArguments

public static java.lang.String[] parseArguments(java.lang.String[] args)
Parses property arguments in the style: -Dname=val. When the JVM is given a -Dprop=val argument, it is already filtered, but when the argument is given after the start class, the argument is in the args list. Note: parsed arguments are not yet eaten (removed from args[])


getProperty

public static java.lang.String getProperty(java.lang.String name)
Unified Global getProperty/getEnv method.

Check system property settings in the following order (high prio first):

 
 I)   Check system properties GlobalConfig.getSystemProperty (command line) 
       for user specified (and optional overriden) properties. 
 II)  Check user stored properties (.vletrc/vletrc.prop)
 III) Check Installation stored properties ($INSTALL/etc/vletrc.prop)
 IV)  Check Environment Variable GlobalConfig.getSystemEnv(); 
 

Parameters:
name -
Returns:

getX50UserProxyLocation

public static java.lang.String getX50UserProxyLocation()

debugPrintException

public static void debugPrintException(java.lang.String className,
                                       VlException e)
convenience method to check and print the VlException


getFirewallPortRangeString

public static java.lang.String getFirewallPortRangeString()

getFirewallPortRange

public static int[] getFirewallPortRange()

setFireWallPortRange

public static boolean setFireWallPortRange(java.lang.String rangestr)

loadProperties

public static java.util.Properties loadProperties(VRL loc)
                                           throws VlException
Load properties file from specified location.
IMPORTANT: When this method is used and the URL stream factory handler HAS NOT BEEN SET, only default url schemes can be used ! (file:/,http://).

Throws:
VlException

loadProperties

public static java.util.Properties loadProperties(java.net.URL url)
                                           throws VlException
Throws:
VlException

loadPropertiesFromClasspath

public static java.util.Properties loadPropertiesFromClasspath(java.lang.String urlstr)
                                                        throws VlException
Load a property file specified on the classpath

Parameters:
urlstr -
Returns:
Throws:
VlException

saveProperties

public static void saveProperties(VRL loc,
                                  java.util.Properties props)
                           throws VlException
Save properties file to specified location. When the VRS environment is configured, any VRL can be used. But at startup these locations might be limitid to local locations.

Throws:
VlException

getCodeBaseLocation

public static VRL getCodeBaseLocation()
Returns base location of installed code of Global class


getConfigurationAttributes

public static VAttributeSet getConfigurationAttributes()
Return configurable properties as AttributeSet


init

public static void init()
Even though this method does nothing, the class Global will be initialized ! This because this class is referenced (a method is called)! The real initialization is done in the class object.

This allows for multiple calls to init() !

Call this method first to ensure proper initialization of the configured settings, etc.


getVersion

public static java.lang.String getVersion()

loadJarsFrom

public static void loadJarsFrom(VRL location)
Loads all jars found in the specified location. Effectively loads all jars from: location/*.jar (not recursive) Very usefull for dynamic class loading !


isLinux

public static boolean isLinux()

isWindows

public static boolean isWindows()

getArch

public static java.lang.String getArch()

getOSName

public static java.lang.String getOSName()

getOSVersion

public static java.lang.String getOSVersion()

getHelpUrl

public static VRL getHelpUrl(java.lang.String string)

setSystemProperty

public static void setSystemProperty(java.lang.String name,
                                     java.lang.String value)

getBoolProperty

public static boolean getBoolProperty(java.lang.String name,
                                      boolean defVal)
Returns boolean property or the default value


getGridProxyLocation

public static java.lang.String getGridProxyLocation()
Return OPTIONAL grid proxy location. Can be null


getGridCertificateLocation

public static java.lang.String getGridCertificateLocation()
Return OPTIONAL grid certificate location can be null.


getPassiveMode

public static boolean getPassiveMode()
When true only passive connections are allowed. This means no incoming tcp/ip connections are allowed or possible.

Returns:

setPassiveMode

public static void setPassiveMode(boolean val)

messagePrintln

public static void messagePrintln(java.lang.Object source,
                                  int level,
                                  java.lang.String message)

setVerbose

public static void setVerbose(int v)