com.webhydra.slug
Class PropertiesConfigParser

java.lang.Object
  extended by com.webhydra.slug.PropertiesConfigParser
All Implemented Interfaces:
ISlugConfigParser

public class PropertiesConfigParser
extends java.lang.Object
implements ISlugConfigParser

Property configuration parser. Loads and instantiates all ISlugRunner runners from a properties file.

The file format is as follows:
slug.runners
property defining a comma separated list of runner names. Each runner's name is a token composed by alphanumeric characters
slug.runner[runner's name].impl
defiens the ISlugRunner implementation class name for a runner's name defined in slug.runners property
slug.runner[runner's name].param[param name]
defines name/value pair parameter to the ISlugRunner implementation initialization. The name is used as provided by the param name and property's value is passed as a value for it. Zero or many parameters may be defined for each ISlugRunner implementation instance
slug.translatorsr
property defining a comma separated list of translator names. Each runner's name is a token composed by alphanumeric characters
slug.translator[translator's name].impl
defiens the IProcessStatusTranslator implementation class name for a translator's name defined in slug.translators property
slug.translator[translator's name].param[param name]
defines name/value pair parameter to the IProcessStatusTranslator implementation initialization. The name is used as provided by the param name and property's value is passed as a value for it. Zero or many parameters may be defined for each IProcessStatusTranslator implementation instance
Example properties file
 slug.runners=good,param_test
 slug.runner[good].runnerimpl=com.webhydra.slug.process.UnlimitedProcessRunner
 slug.runner[param_test].runnerimpl=com.webhydra.slug.SlugRunnerParamTest
 slug.runner[param_test].param[p1]=Test Patameter 1
 slug.runner[param_test].param[p2]=Test Parameter 2
 slug.translators=xml
 slug.translator[xml].impl=com.webhydra.slug.process.xml.XmlXsdProcessStatusTranslator
 

Author:
rossen

Constructor Summary
PropertiesConfigParser()
          Creates a new instance of PropertiesConfigParser
 
Method Summary
protected static java.lang.String extractParamName(java.lang.String key, java.lang.String preffix)
          Extract parameter name from an indexed parameters property.
 InstanceDef[] getRunnerDefs()
          Gets all ISlugRunner implementation definitions
 InstanceDef[] getTranslatorDefs()
          Gets all IProcessStatusTranslator implementation definitions
 void load(java.io.InputStream is)
          Initializes class instance.
protected  void load(java.util.Properties props)
          Initialize new PropertiesConfigParser instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesConfigParser

public PropertiesConfigParser()
Creates a new instance of PropertiesConfigParser

Method Detail

load

public void load(java.io.InputStream is)
          throws SlugInitializationException
Initializes class instance.

Specified by:
load in interface ISlugConfigParser
Parameters:
is - Slug's configuration properties input stream.
Throws:
SlugInitializationException - if provided configurataion file is not accessible or is invald.

load

protected void load(java.util.Properties props)
             throws SlugInitializationException
Initialize new PropertiesConfigParser instance.

Parameters:
props - Slug's configuration properties.
Throws:
SlugInitializationException - if provided properties are null or empty.

getRunnerDefs

public InstanceDef[] getRunnerDefs()
Gets all ISlugRunner implementation definitions

Specified by:
getRunnerDefs in interface ISlugConfigParser

getTranslatorDefs

public InstanceDef[] getTranslatorDefs()
Description copied from interface: ISlugConfigParser
Gets all IProcessStatusTranslator implementation definitions

Specified by:
getTranslatorDefs in interface ISlugConfigParser

extractParamName

protected static java.lang.String extractParamName(java.lang.String key,
                                                   java.lang.String preffix)
Extract parameter name from an indexed parameters property.

Parameters:
key - property key
preffix - runner property name prefix.