Version: ${maven.project.version}

org.soaplab.services
Class Config

java.lang.Object
  extended by org.soaplab.services.Config

public abstract class Config
extends java.lang.Object

An abstract class giving access to the global Soaplab configuration. It also allows to add additional configuration files (which may be useful for Soaplab's plugins, for example).

It also contains names and description of (most of) the Soaplab configuration properties.

The class uses Apache Commons Configuration - the method get() gives back directly an Apache's CompositeConfiguration instance allowing to fine-tune your configuration. But in most cases, few convenient methods are used.

Version:
$Id: Config.java,v 1.26 2009/12/10 09:40:34 smoretti Exp $
Author:
Martin Senger

Field Summary
static java.lang.String DEFAULT_JOB_FACTORY_CLASS
          A default name for a class representing a Job factory.
static java.lang.String LSF_ARCH
          A property name.
static java.lang.String LSF_ENABLED
          A property name.
static java.lang.String LSF_PROJECT
          A property name.
static java.lang.String LSF_QUEUENAME
          A property name.
static java.lang.String PREFIX_SYNONYM
          A part of property names.
static java.lang.String PROP_ACCEPT_ANY_EXITCODE
          A property name.
static java.lang.String PROP_ADDTOPATH_DIR
          A property name.
static java.lang.String PROP_APPLIST_FILENAME
          A property name.
static java.lang.String PROP_BASE_DIR
          A property name.
static java.lang.String PROP_ENVAR
          A property name.
static java.lang.String PROP_EVENT_IGNORE_HEARBEAT
          A property name.
static java.lang.String PROP_EVENT_LOG_LEVEL
          A property name.
static java.lang.String PROP_JOBS_CLEANING_INTERVAL
          A property name.
static java.lang.String PROP_JOBS_TIMEOUT
          A property name.
static java.lang.String PROP_JOBS_WAITFOR_TIMEOUT
          A property name.
static java.lang.String PROP_KEEP_INPUTS
          A property name.
static java.lang.String PROP_LAUNCHER
          A property name.
static java.lang.String PROP_METADATA_DIR
          A property name.
static java.lang.String PROP_METADATA_FILE
          A part of a property name.
static java.lang.String PROP_RESULTS_DIR
          A property name.
static java.lang.String PROP_RESULTS_URL
          A property name.
static java.lang.String PROP_RESULTS_URL_DIR
          A property name.
static java.lang.String PROP_RESULTS_URL_IGNORE
          A property name.
static java.lang.String PROP_SANDBOX_DIR
          A property name.
static java.lang.String PROP_SCRIPTS_DIR
          A property name.
static java.lang.String PROP_SERVICES_CLEANING_INTERVAL
          A property name.
static java.lang.String PROP_SOAPLAB_CONFIGURATION
          A property name.
static java.lang.String PROP_SUPPLIER
          A property name.
static java.lang.String PROP_TOMCAT_HOST
          A property name.
static java.lang.String PROP_TOMCAT_PORT
          A property name.
static java.lang.String PROP_WORKING_DIR
          A property name.
static java.lang.String SOAPLAB_CONFIG_FILENAME
          A filename indicating a file containing Soaplab run-time properties.
 
Constructor Summary
Config()
           
 
Method Summary
static boolean addConfigPropertyFile(java.lang.String configFilename)
          Add new configuration properties from a property file.
static boolean addConfigXMLFile(java.lang.String configFilename)
          Add new configuration properties from an XML file.
static org.apache.commons.configuration.CompositeConfiguration get()
          The main method returning a configuration object.
static java.io.File[] getConfigFiles()
           
static int getInt(java.lang.String key, int defaultValue, java.lang.String serviceName, java.lang.Object owner)
          Almost the same functionality as getString method - see there details about parameters - except that it expects property value to be an integer.
static java.util.Properties getMatchingProperties(java.lang.String prefix, java.lang.String serviceName, java.lang.Object owner)
          Get all properties contained in the configuration whose keys (names) match the specified prefix.
static java.lang.String getString(java.lang.String key, java.lang.String defaultValue, java.lang.String serviceName, java.lang.Object owner)
          Get a string associated with the given configuration key, or - if not found - get the given default value (which still may be null).
static java.lang.String[] getStrings(java.lang.String key, java.lang.String defaultValue, java.lang.String serviceName, java.lang.Object owner)
          Almost the same functionality as getString method - see there details about parameters.
static boolean isEnabled(java.lang.String key, boolean defaultValue, java.lang.String serviceName, java.lang.Object owner)
          Almost the same functionality as getString method - see there details about parameters - except that it expects property value to be a boolean.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOAPLAB_CONFIG_FILENAME

public static final java.lang.String SOAPLAB_CONFIG_FILENAME
A filename indicating a file containing Soaplab run-time properties. This file name can be changed by setting Java property PROP_SOAPLAB_CONFIGURATION to point to a different file name.

See Also:
Constant Field Values

PREFIX_SYNONYM

public static final java.lang.String PREFIX_SYNONYM
A part of property names. It indicates that the whole property represents a synonym and its resolution. For example:
PREFIX_SYNONYM.module = org.soaplab.plugins.God
means that the class name org.soaplab.plugins.God is known under a synonym module.

See Also:
Constant Field Values

DEFAULT_JOB_FACTORY_CLASS

public static final java.lang.String DEFAULT_JOB_FACTORY_CLASS
A default name for a class representing a Job factory. This is used only if all other ways fail. The other ways are: (a) take the class name from the service metadata (TBD, not yet), (b) take the class name from the module tag in the applications list, (c) use the module tag in the applications list as a synonym and take the class name from the run-time configuration file.

See Also:
Constant Field Values

PROP_SOAPLAB_CONFIGURATION

public static final java.lang.String PROP_SOAPLAB_CONFIGURATION
A property name. Its value contains a filename indicating a file containing Soaplab configuration properties. Default value is SOAPLAB_CONFIG_FILENAME.

See Also:
Constant Field Values

PROP_APPLIST_FILENAME

public static final java.lang.String PROP_APPLIST_FILENAME
A property name. Its value is a filename containing a list of analysis provided by this list. The property name can be also prefixed by this class full name.

There is no default value.

See Also:
Constant Field Values

PROP_JOBS_CLEANING_INTERVAL

public static final java.lang.String PROP_JOBS_CLEANING_INTERVAL
A property name. Its value (an integer, number of milliseconds) indicates to the JobManager how often to scan a list of completed jobs in order to remove them from the memory (not to destroy them; their results will still be available).

Default value is 60000 (one minute).

See Also:
Constant Field Values

PROP_JOBS_TIMEOUT

public static final java.lang.String PROP_JOBS_TIMEOUT
A property name. Its value (an integer, number of milliseconds) indicates to the JobManager how long after it is started a job should be terminated if it is still runnig.

Default value is 864000000 (10 days).

See Also:
Constant Field Values

PROP_JOBS_WAITFOR_TIMEOUT

public static final java.lang.String PROP_JOBS_WAITFOR_TIMEOUT
A property name. Its value (an integer, number of milliseconds) indicates to Soaplab how long after a waitfor call made the call should return if the job is still running after that period.

Default value is 864000000 (10 days).

See Also:
Constant Field Values

PROP_SERVICES_CLEANING_INTERVAL

public static final java.lang.String PROP_SERVICES_CLEANING_INTERVAL
A property name. Its value (an integer, number of milliseconds) indicates to the AnalysisService how often to scan a list of instantiated services in order to remove them from the memory (they can be still later instantiated if a request comes).

Default value is 300000 (five minutes).

See Also:
Constant Field Values

PROP_RESULTS_DIR

public static final java.lang.String PROP_RESULTS_DIR
A property name. Its value is an absolute path to a directory where FileStorage handler keeps analysis results.

Default value (also used when the given directory is not writable to the current user) is "soaplab.results" in the system-dependent default temporary-file directory (the default temporary-file directory is specified by the system property "java.io.tmpdir").

See Also:
Constant Field Values

PROP_METADATA_DIR

public static final java.lang.String PROP_METADATA_DIR
A property name. Its value is a name of a directory containing analysis metadata.

There is no default value.

See Also:
Constant Field Values

PROP_METADATA_FILE

public static final java.lang.String PROP_METADATA_FILE
A part of a property name. Its value is a name of a file containing metadata for a concrete analysis.

The property name must be prefixed by the analysis (service) name whose metadata this file contains. For example, for service "edit.seqret", the full property name should be: "edit.seqret" + PROP_METADATA_FILE.

There is no default value.

See Also:
Constant Field Values

PROP_EVENT_IGNORE_HEARBEAT

public static final java.lang.String PROP_EVENT_IGNORE_HEARBEAT
A property name. Its boolean true value indicates that event listeners should ignore Heartbeat Progress events (because there may be too many of them).

Default value is false.

See Also:
Constant Field Values

PROP_EVENT_LOG_LEVEL

public static final java.lang.String PROP_EVENT_LOG_LEVEL
A property name. Its value indicates a logging level under which class DefaultEventListener logs Soaplab's events. The accepted values are (in case-insensitive way): trace, debug, info, warn, error, fatal, and off ('off' means no logging at all).

Default value is debug.

See Also:
Constant Field Values

PROP_WORKING_DIR

public static final java.lang.String PROP_WORKING_DIR
A property name. Its value contains a directory name where the inputs and outputs of the running external process will be stored in.

No default value; instead a temporary directory will be used.

See Also:
Constant Field Values

PROP_SANDBOX_DIR

public static final java.lang.String PROP_SANDBOX_DIR
A property name. The same meaning as PROP_WORKING_DIR.

See Also:
Constant Field Values

PROP_KEEP_INPUTS

public static final java.lang.String PROP_KEEP_INPUTS
A property name. Its boolean true value indicates that inputs are kept in the working directory (in the "sandbox") even after they had been used by an external program. This is good for debugging.

Default value is false.

See Also:
Constant Field Values

PROP_SUPPLIER

public static final java.lang.String PROP_SUPPLIER
A property name. Its value contains a URL for Gowlab-based services.

See Also:
Constant Field Values

PROP_LAUNCHER

public static final java.lang.String PROP_LAUNCHER
A property name. Its value specifies a service launcher.

See Also:
Constant Field Values

PROP_ENVAR

public static final java.lang.String PROP_ENVAR
A property name. Its value is a prefix used in names of those properties who will become environment variables.

See Also:
Constant Field Values

PROP_ADDTOPATH_DIR

public static final java.lang.String PROP_ADDTOPATH_DIR
A property name. Its value contains one or more directory names (separated by commas) that are added to the PATH environment variable before starting an external tool.

There is no default value.

See Also:
Constant Field Values

PROP_SCRIPTS_DIR

public static final java.lang.String PROP_SCRIPTS_DIR
A property name. Its value is a directory name with scripts that could be called by Soaplab services. In order to achieve it, however, the same directory must be also added to the property PROP_ADDTOPATH_DIR - Soaplab does not do it automatically. But Soaplab tries to make these scripts executable by changing their permissions appropriately. This is useful when the scripts were transported to the servlet container in a war file (because unpacking the war file does not preserve the files permissions).

There is no default value.

See Also:
Constant Field Values

PROP_ACCEPT_ANY_EXITCODE

public static final java.lang.String PROP_ACCEPT_ANY_EXITCODE
A property name. Its boolean true value indicates that any exit code returned by the invoked external program is treated as a good one (used in sowa). Otherwise only zero exit code is acceptable as a good one.

Default value is false.

See Also:
Constant Field Values

PROP_RESULTS_URL_IGNORE

public static final java.lang.String PROP_RESULTS_URL_IGNORE
A property name. Its boolean true value indicates to ignore creation of the results of type URL.

Default value is false.

See Also:
Constant Field Values

PROP_TOMCAT_HOST

public static final java.lang.String PROP_TOMCAT_HOST
A property name. Its value is a hostname where a Tomcat server is serving Soaplab2 services from.

Default value is localhost.

See Also:
Constant Field Values

PROP_TOMCAT_PORT

public static final java.lang.String PROP_TOMCAT_PORT
A property name. Its integer value is a port number where a Tomcat server is serving Soaplab2 services from.

Default value is 8080.

See Also:
Constant Field Values

PROP_RESULTS_URL_DIR

public static final java.lang.String PROP_RESULTS_URL_DIR
A property name. Its value is a directory (usually with the full path) where Soaplab will be copying results that should be viewed (accessed) via protocols such as HTTP or FTP. This property is a full path of the same directory where the property PROP_RESULTS_URL points to as a URL.

Default value depends on the context: if a Soaplab service is running in a servlet container (such as Tomcat - which is a usual case), a default directory is created inside Soaplab web application. Otherwise, there is no default (which means that the URL-based results will not be created).

See Also:
Constant Field Values

PROP_RESULTS_URL

public static final java.lang.String PROP_RESULTS_URL
A property name. Its value is a URL (without the last file name) where the Soaplab's results are accessible from. This URL points to the same place as specified by the property PROP_RESULTS_URL_DIR.

Default value is http://localhost:8080/soaplab2/results.

See Also:
Constant Field Values

PROP_BASE_DIR

public static final java.lang.String PROP_BASE_DIR
A property name. Its value contains a full path to directory that is "home" directory of the project.

Default value depends on the context: if a Soaplab service is running in a servlet container (such as Tomcat - which is a usual case), a default value points to the Soaplab web application (inside Tomcat). Otherwise, it is usually the place current directory.

See Also:
Constant Field Values

LSF_ENABLED

public static final java.lang.String LSF_ENABLED
A property name. Its boolean true value indicates that sowa jobs are executed using LSF.

See Also:
Constant Field Values

LSF_QUEUENAME

public static final java.lang.String LSF_QUEUENAME
A property name. Its value is a queue name for submitting LSF jobs.

See Also:
Constant Field Values

LSF_ARCH

public static final java.lang.String LSF_ARCH
A property name. Its value is an architecture for submitting LSF jobs on.

See Also:
Constant Field Values

LSF_PROJECT

public static final java.lang.String LSF_PROJECT
A property name. Its value is a project name for LSF jobs.

See Also:
Constant Field Values
Constructor Detail

Config

public Config()
Method Detail

get

public static org.apache.commons.configuration.CompositeConfiguration get()
The main method returning a configuration object. The returned object is a singleton - but its contents (the properties it carries) can be changed dynamically (the properties are reloaded if their files are modified).

The configuration object contains all Java system properties and properties read from the Soaplab configuration file. This file name is given by the system property PROP_SOAPLAB_CONFIGURATION, or using a default name SOAPLAB_CONFIG_FILENAME. If the filename does not specify an absolute path, the file will be searched automatically in the following locations:

The System properties take precedence over properties read from the Soaplab property file.

The configuration object can be anytime extended by properties from other sources by using either methods defined in the CompositeConfiguration's API, or using a convenient methods addConfigPropertyFile(java.lang.String) and addConfigXMLFile(java.lang.String) defined here. Properties from these additional files have higher priority than properties added earlier - except System properties, they are always the most prioritized.

Returns:
a configuration object

addConfigPropertyFile

public static boolean addConfigPropertyFile(java.lang.String configFilename)
Add new configuration properties from a property file.

The newly added properties have higher priority than properties added earlier - except System properties, they are always the most prioritized.

Parameters:
configFilename - is a filename indicating a file (formatted as a Java properties file) with new properties (see get() explaining where is this file looked for)
Returns:
true if 'configFilename' is successfully added, false otherwise (in which case the cause is recorded in the log)

addConfigXMLFile

public static boolean addConfigXMLFile(java.lang.String configFilename)
Add new configuration properties from an XML file. The details of such XML file structure are explained in Apache Commons Configuration.

The newly added properties have higher priority than properties added earlier - except System properties, they are always the most prioritized.

Parameters:
configFilename - is an XML filename indicating a file with new properties (see get() explaining where is this file looked for)
Returns:
true if 'configFilename' is successfully added, false otherwise (in which case the cause is recorded in the log)

getString

public static java.lang.String getString(java.lang.String key,
                                         java.lang.String defaultValue,
                                         java.lang.String serviceName,
                                         java.lang.Object owner)
Get a string associated with the given configuration key, or - if not found - get the given default value (which still may be null).

So far, it looks like the same-named method in org.apache.commons.configuration.Configuration. So if you need just that functionality, go directly there. For example, do this:

 String value = Config.get().getString ("my.property", "yes");
The other two parameters, 'serviceName' and 'owner' - if not null - act as prefixes of the given property key, and they are tried first. This way you can select some property to be used only for specified service, or for a specified class name. For example, a property file can have these properties:
    applist = ...
    org.soaplab.lists.MyList.applist = ...
or:
    delay = ...
    big.service.delay = ...
The method looks first for property <serviceName>.<key>. Then, if not found, for property <class-name>.<key>. And finally, just for <key>. The class-name is a fuly-qualified class name of 'owner'.

Parameters:
key - is a property name
defaultValue - used if the 'key' cannot be found
serviceName - is a preferred prefix for the 'key'
owner - is a preferred prefix for the 'key': if 'owner' is of type Class its name is used, otherwise, the name of the class of the instance 'owner' is used
Returns:
the property value, or 'defaultValue' if such property does not exist

getStrings

public static java.lang.String[] getStrings(java.lang.String key,
                                            java.lang.String defaultValue,
                                            java.lang.String serviceName,
                                            java.lang.Object owner)
Almost the same functionality as getString method - see there details about parameters. The different is the return value - it allows to return several values of the same property. In the configuration file, the property can be repeated, or can have several comma-separated values.

Returns:
all values of the given property, or - if such property does not exist - return a one-element array with the 'defaultValue' unless the 'defaultValue' is also null in which case return an empty array

getInt

public static int getInt(java.lang.String key,
                         int defaultValue,
                         java.lang.String serviceName,
                         java.lang.Object owner)
Almost the same functionality as getString method - see there details about parameters - except that it expects property value to be an integer.

If the key is found but its value is not an integer, or if it is not found at all, it returns the given default value.


isEnabled

public static boolean isEnabled(java.lang.String key,
                                boolean defaultValue,
                                java.lang.String serviceName,
                                java.lang.Object owner)
Almost the same functionality as getString method - see there details about parameters - except that it expects property value to be a boolean.

For the property values 'true', 'on', 'yes' (case insensitive), and for an empty value it returns true. For other values, false is returned. If the property does not exist at all, the 'defaultValue' is returned.


getMatchingProperties

public static java.util.Properties getMatchingProperties(java.lang.String prefix,
                                                         java.lang.String serviceName,
                                                         java.lang.Object owner)
Get all properties contained in the configuration whose keys (names) match the specified prefix.

The remaining parameters are used in the similar way as in getString method. Meaning if they are not null, the following prefixes are actually tried:

 <prefix>.
 <class-of-owner>.<prefix>.
 <serviceName>.<prefix>.
These prefixes are tried in the order as indicated above - causing the properties with earlier prefixes being overwritten by those having newer ones. For example, having the following properties in the configuration (classic.helloworld is a name of a service):
 classic.helloworld.grid.env.One = ein
 classic.helloworld.grid.env.Two = zwei
 grid.env.One = un
 grid.env.Two = deux
 grid.env.Three = trois
and calling:
 getMatchingProperties ("grid.env", "classic.helloworld", null)
will return properties:
 One = ein
 Two = zwei
 Three = troi

Parameters:
prefix - is a part of property name (may or may not end with a dot)
serviceName - is a possibly 'prefix' for the 'prefix' (can be null)
owner - is another possible 'prefix' for the 'prefix': if 'owner' is of type Class its name is used, otherwise, the name of the class of the instance 'owner' is used
Returns:
properties matching the prefix - the prefix is not part of the returned property names; if nothing matches, an empty list is returned (not null)

getConfigFiles

public static java.io.File[] getConfigFiles()

Version: ${maven.project.version}

Submit a bug or feature
Generated: Tue Jun 14 15:18:14 AST 2011