com.radekzitek.userver
Class Configuration

java.lang.Object
  extended bycom.radekzitek.userver.Configuration

public class Configuration
extends java.lang.Object

Configuration class is used to manage the configuration data.

Author:
rzitek

Field Summary
private static org.apache.log4j.Logger LOG
           
private  java.util.Properties rawProperties
          Used to store the raw properties loaded from configuration file.
 
Constructor Summary
Configuration()
          Creates configuration by loading it from bin/userver.properties file.
Configuration(java.io.File file)
          Creates configuration by loading it from given file.
Configuration(java.io.InputStream inStream)
          Creates configuration by loading it from given input stream.
Configuration(java.lang.String fileName)
          Creates configuration by loading it from given file.
 
Method Summary
 java.util.Properties getListenerConfiguration(java.lang.String listenerName)
          For the given listener name retrieves all the configuration data.
 java.util.List getListenerNames()
          Retrieves the list of the names of the listenrs specified by the configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final org.apache.log4j.Logger LOG

rawProperties

private java.util.Properties rawProperties
Used to store the raw properties loaded from configuration file.

Constructor Detail

Configuration

public Configuration()
              throws java.io.FileNotFoundException,
                     java.io.IOException
Creates configuration by loading it from bin/userver.properties file.

Throws:
java.io.FileNotFoundException - Thrown if the gile is not found.
java.io.IOException - Thrown when there is problem reading from the file.

Configuration

public Configuration(java.lang.String fileName)
              throws java.io.FileNotFoundException,
                     java.io.IOException
Creates configuration by loading it from given file.

Parameters:
fileName - the name of the file to read the configuration from
Throws:
java.io.FileNotFoundException - Thrown if the gile is not found.
java.io.IOException - Thrown when there is problem reading from the file.

Configuration

public Configuration(java.io.File file)
              throws java.io.FileNotFoundException,
                     java.io.IOException
Creates configuration by loading it from given file.

Parameters:
file - the file to read the configuration from
Throws:
java.io.FileNotFoundException - Thrown if the gile is not found.
java.io.IOException - Thrown when there is problem reading from the file.

Configuration

public Configuration(java.io.InputStream inStream)
              throws java.io.IOException
Creates configuration by loading it from given input stream.

Parameters:
inStream - the input stream to read the configuration from
Throws:
java.io.IOException - Thrown when there is problem reading from the file.
Method Detail

getListenerNames

public java.util.List getListenerNames()
Retrieves the list of the names of the listenrs specified by the configuration. This is done by looking for propoerty com.radekzitek.userver.Listeners and then handling its value as comma separated list of listener names. White spaces characters are trimed.

Returns:
the list of strings representing names of the listeners

getListenerConfiguration

public java.util.Properties getListenerConfiguration(java.lang.String listenerName)
For the given listener name retrieves all the configuration data. This is done by looking for properties which names start with com.radekzitek.userver.listener.[listener name]. What is returned is all the properties found but the string com.radekzitek.userver.listener.[listener name] is striped from the new names of the returned properties. This makes the configuration data independent from the name of the listener.

Parameters:
listenerName - the name of the listener to retrieve the configuration for
Returns:
properties relevant to the given listener name