net.sf.taverna.raven.appconfig.config
Class MyGridConfiguration

java.lang.Object
  extended by net.sf.taverna.raven.appconfig.bootstrap.AbstractConfiguration
      extended by net.sf.taverna.raven.appconfig.config.MyGridConfiguration

public class MyGridConfiguration
extends AbstractConfiguration

myGrid configuration, such as services to load in the workbench or LSID provider to use. The configuration is in the file mygrid.properties in the classpath.

The recommended way to get the configuration is to call the static methods getProperties() and getProperty().

For backwards compatability, loadMygridProperties() loads the mygrid properties into the system properties. This was previously done by a static block in org.embl.ebi.escience.scuflui.workbench.Workbench. This method should be called by the main() methods to allow legacy classes to retrieve myGrid configuration.

Author:
Stian Soiland-Reyes

Method Summary
static void flushProperties()
          Flush cache of properties.
static MyGridConfiguration getInstance()
          Provides access to the singleton instance of the MygridConfiguration, though most access will normally occur through the static methods rather than to the instance directly.
static java.lang.String getProperty(java.lang.String key)
          Look up a myGrid property.
static java.lang.String getProperty(java.lang.String key, java.lang.String def)
          Look up a myGrid property.
static java.io.File getStartupDir()
          Returns a File representing the Taverna startup directory.
static java.io.File getStartupDir(java.lang.String subfolder)
          Returns a File representing a subfolder within the Taverna startup directory.
static java.io.File getUserDir()
          Get the user's application directory according to taverna.home.
static java.io.File getUserDir(java.lang.String subDirectory)
          Get a subdirectory of the user's application directory.
static void loadMygridProperties()
          Deprecated. 
 
Methods inherited from class net.sf.taverna.raven.appconfig.bootstrap.AbstractConfiguration
flush, getProperties
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static MyGridConfiguration getInstance()
Provides access to the singleton instance of the MygridConfiguration, though most access will normally occur through the static methods rather than to the instance directly.

Returns:

getProperty

public static java.lang.String getProperty(java.lang.String key)
Look up a myGrid property.

This is a shorthand for getProperties().getProperty(key). Use this instead of the legacy System.getProperty("taverna.X"), which depends on loadMygridProperties() being previously called.

Parameters:
key -
Returns:
value

getProperty

public static java.lang.String getProperty(java.lang.String key,
                                           java.lang.String def)
Look up a myGrid property.

Like getProperty(String key) - but return def if the key is unknown.

Parameters:
key -
def - Default string if key not found
Returns:

flushProperties

public static void flushProperties()
Flush cache of properties. Next call to getProperties() or getProperty() will force a reload from files


loadMygridProperties

@Deprecated
public static void loadMygridProperties()
Deprecated. 

Load the myGrid properties and store them into the System properties. This function should be called as early as possible in your program.

This is provided for backwards compatibility only, as old code relies on System.getProperties() to be prepopulated with the myGrid configuration.

Do not rely on properties to have been loaded globally, instead use MyGridConfiguration.getProperties()

See Also:
MyGridConfiguration.getProperties()

getUserDir

public static java.io.File getUserDir()
Get the user's application directory according to taverna.home.

The system property taverna.home is assumed to have been set by Bootstrap.findUserDir() or externally. The directory is created if needed.

Returns:
File object representing the user directory for this application, or null if it could not be found or created.
See Also:
net.sf.taverna.tools.Bootstrap.findUserDir()

getStartupDir

public static java.io.File getStartupDir()
Returns a File representing the Taverna startup directory. This is the directory containing the startup script plus default configuration directories. This directory is determined by $taverna.startup. Returns null if this is not defined.

Returns:

getStartupDir

public static java.io.File getStartupDir(java.lang.String subfolder)
Returns a File representing a subfolder within the Taverna startup directory. If no startup directory is defined, then null is returned. There is no attempt to create the directory if it doesn't exist, since the location is likely to be read-only. The client calling this method is responsible for handling the possibility that the directory may not exist.

Parameters:
subfolder -
Returns:

getUserDir

public static java.io.File getUserDir(java.lang.String subDirectory)
Get a subdirectory of the user's application directory.

Like getUserDir(), but one level deeper. For instance, getUserDir("conf") on UNIX would return the file of /user/myusername/.myapplication/conf and assure that both .myapplication and conf are created.

Parameters:
subDirectory -
Returns:
See Also:
getUserDir()