org.apache.commons.latka
Class LatkaProperties

java.lang.Object
  extended by org.apache.commons.latka.LatkaProperties

public class LatkaProperties
extends Object

Stores properties for Latka. This class is backed by a ThreadLocal variable, so every Thread is guaranteed to get a unique Properties object. Note, however, that inside an environment utilizing a Thread pool, such as many Servlet engines, it is possible for the Properties object to travel quite widely. Use the resetProperties() method to reset the Properties object for a Thread to its default values.

Author:
Morgan Delagrange, dIon Gillard (javadoc changes)

Field Summary
protected static Properties _initProps
          default Properties file for Latka
protected static org.apache.log4j.Category _log
          log4j category to append output to
protected static ThreadLocal _propsThreadLocal
          This ThreadLocal is automatically instantiated per thread with a Properties object containing the default properties.
 
Constructor Summary
LatkaProperties()
           
 
Method Summary
static Properties getProperties()
          Returns the unique Properties object for the current Thread.
protected static Properties loadDefaultProps()
          Loads the default Properties from the first "latka.properties" file located encountered in the classpath.
protected static Properties loadPropsFromClasspath(String classpathLocation)
          Load properties specified from context class path
protected static Properties loadUserProps()
          Load latka.properties from classpath
static void resetProperties()
          Resets the Latka properties to their initial value (getProperties() will still return the same Object).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_log

protected static final org.apache.log4j.Category _log
log4j category to append output to


_initProps

protected static Properties _initProps
default Properties file for Latka


_propsThreadLocal

protected static ThreadLocal _propsThreadLocal
This ThreadLocal is automatically instantiated per thread with a Properties object containing the default properties.

Constructor Detail

LatkaProperties

public LatkaProperties()
Method Detail

getProperties

public static Properties getProperties()
Returns the unique Properties object for the current Thread. The Properties object is initialized with the default Latka Properties.

Returns:
Latka Properties object

resetProperties

public static void resetProperties()
Resets the Latka properties to their initial value (getProperties() will still return the same Object). One use for this method is to reset state inside a Thread-pooling environment.


loadDefaultProps

protected static Properties loadDefaultProps()
Loads the default Properties from the first "latka.properties" file located encountered in the classpath.

Returns:
A Properties object generated from the contents of the default property file

loadUserProps

protected static Properties loadUserProps()
Load latka.properties from classpath

Returns:
loaded properties

loadPropsFromClasspath

protected static Properties loadPropsFromClasspath(String classpathLocation)
                                            throws IOException
Load properties specified from context class path

Parameters:
classpathLocation - Resource name to load
Returns:
initialized properties object
Throws:
IOException - from loading resource


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.