org.starhope.appius.util
Class BraqueConfig

java.lang.Object
  extended by org.starhope.appius.util.AppiusConfig

public final class BraqueConfig
extends Object

This static class is the singleton responsible for configuration, factories, etc.

Author:
brpocock

Field Summary
private static Properties config
          The internal configuration database is really a Java Properties object.
private static Connection dbh
          This is the data source for SQL queries.
 
Constructor Summary
BraqueConfig()
           
 
Method Summary
static com.whirlycott.cache.Cache getCache()
           
static String getChatFilterName()
           
static String getConfig(String key)
          This fetches up a configuration property in general.
static boolean getConfigBool(String string)
           
static boolean getConfigBoolOrFalse(String string)
          The same as getConfigBool(String) but returns a "false" if the key is not found
static String getConfigOrDefault(String key, String defaultValue)
           
static String getConfigOrNull(String string)
          This calls @see(#getConfig), but doesn't throw any exceptions, it just returns a null if the string isn't found in the configuration.
static Connection getDatabaseConnection()
           This routine currently returns a single, shared object.
static String getDNS_JNDI()
          This returns the DNS URL to be used in JNDI queries for DNS lookups.
static int getInt(String string)
           
static int getIntOrZero(String string)
           
static Logger getLogger()
           
static String getLoginFilterName()
           
static javax.mail.Address getMailSender()
          Get a Java mail Address object for sending automated eMails.
static String getServerName()
           
static String getSFSName()
           
static int getSFSPort()
           
static String getSMTPHost()
           
static void init()
          Initialize the configuration system from the Properties system and any other relevant sources.
static void setConfig(String key, String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

config

private static Properties config
The internal configuration database is really a Java Properties object. This whole class exists to disguise that implementation detail.


dbh

private static volatile Connection dbh
This is the data source for SQL queries. Once a connection has been opened, we re-use it. It is a private object because we may want to move to a pool of connections or something similar, at some point.

Constructor Detail

BraqueConfig

public BraqueConfig()
Method Detail

getCache

public static com.whirlycott.cache.Cache getCache()
Returns:
the Whirley Cache

getChatFilterName

public static String getChatFilterName()
Returns:
The name (database filter title) of the filter to be used for chat

getConfig

public static String getConfig(String key)
                        throws NotFoundException
This fetches up a configuration property in general.

Parameters:
key - The identifier of the configuration value to be queried
Returns:
The configuration string
Throws:
NotFoundException - If the configuration string is not found

getConfigBool

public static boolean getConfigBool(String string)
                             throws NotFoundException
Parameters:
string - the configuration identifier string
Returns:
true or false, based on the configuration string
Throws:
NotFoundException - if the value can't be found or isn't a boolean (literal "true" or "false" only)

getConfigBoolOrFalse

public static boolean getConfigBoolOrFalse(String string)
The same as getConfigBool(String) but returns a "false" if the key is not found

Parameters:
string - the config identifier string
Returns:
false, if not found or not boolean, or configured as false; true, only if configured as "true"

getConfigOrDefault

public static String getConfigOrDefault(String key,
                                        String defaultValue)
Parameters:
key - configuration key
defaultValue - default value
Returns:
the configured value of the key, or if not found, the default value given

getConfigOrNull

public static String getConfigOrNull(String string)
This calls @see(#getConfig), but doesn't throw any exceptions, it just returns a null if the string isn't found in the configuration.

Parameters:
string - The identifier of the configuration being queries
Returns:
Either the config string, or (if it's not found) a null

getDatabaseConnection

public static Connection getDatabaseConnection()
                                        throws SQLException

This routine currently returns a single, shared object. In the future, we might move to a pool of available connection objects or similar.

Tomcat instructions

FIXME: http://onjava.com/pub/a/onjava/2006/04/19/database-connection -pooling-with-tomcat.html?page=2

Returns:
Gets a connection to the database.
Throws:
SQLException - (bubbled up from underlying layers)

getDNS_JNDI

public static String getDNS_JNDI()
This returns the DNS URL to be used in JNDI queries for DNS lookups.

Returns:
A "dns://" URL for the DNS server which is to be queried.

getInt

public static int getInt(String string)
                  throws NumberFormatException,
                         NotFoundException
Parameters:
string - the configuration key
Returns:
the configured value as an integer
Throws:
NotFoundException - if the key isn't found in the configuration
NumberFormatException - if the key can't be parsed as an integer

getIntOrZero

public static int getIntOrZero(String string)
Parameters:
string - the configuration key
Returns:
the configured value as an integer, or if the value is not configured or not parseable as an integer, returns 0 as a ‘safety’ value instead.

getLogger

public static Logger getLogger()
Returns:
logger (not used)

getLoginFilterName

public static String getLoginFilterName()
Returns:
The name (database filter title) of the filter to be used for login name selections

getMailSender

public static javax.mail.Address getMailSender()
Get a Java mail Address object for sending automated eMails. This is taken from the $system user's eMail address.

Returns:
The address from which automated mails come

getServerName

public static String getServerName()

getSFSName

public static String getSFSName()
Returns:

getSFSPort

public static int getSFSPort()
Returns:

getSMTPHost

public static String getSMTPHost()
Returns:
the SMTP hostname for outbound eMail

init

public static void init()
Initialize the configuration system from the Properties system and any other relevant sources. This is normally performed once, at startup.


setConfig

public static void setConfig(String key,
                             String value)
Parameters:
key - The configuration value to be set
value - The new value