com.opensymphony.webwork.config
Class Configuration

java.lang.Object
  extended by com.opensymphony.webwork.config.Configuration
Direct Known Subclasses:
DefaultConfiguration, DelegatingConfiguration, PropertiesConfiguration

public class Configuration
extends Object

Handles all WebWork2 config properties. Implementation of this class is pluggable (the default implementation is DefaultConfiguration). This gives developers to ability to customize how WebWork2 properties are set and retrieved. As an example, a developer may wish to check a separate property store before delegating to the WebWork one.

Key methods:

Key methods for subclassers:

Author:
Rickard ???berg, Jason Carreira, Bill Lynch (docs)

Constructor Summary
Configuration()
           
 
Method Summary
static Object get(String name)
          Returns a property as an Object.
static Configuration getConfiguration()
          Gets the current configuration implementation.
 Object getImpl(String aName)
          Implementation of the get(String) method.
static Locale getLocale()
          Returns the WebWork2 locale.
static String getString(String name)
          Returns a property as a String.
static boolean isSet(String name)
          Determines whether or not a value has been set.
 boolean isSetImpl(String name)
          Implementation of the isSet(String) method.
static Iterator list()
          Returns an Iterator of all properties names.
 Iterator listImpl()
          Implementation of the list() method.
static void reset()
           
static void set(String name, Object value)
          Sets a property.
static void setConfiguration(Configuration config)
          Sets the current configuration implementation.
 void setImpl(String name, Object value)
          Implementation of the set(String, Object) method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Configuration

public Configuration()
Method Detail

setConfiguration

public static void setConfiguration(Configuration config)
                             throws IllegalStateException
Sets the current configuration implementation. Can only be called once.

Parameters:
config - a Configuration implementation
Throws:
IllegalStateException - if an error occurs when setting the configuration implementation.

getConfiguration

public static Configuration getConfiguration()
Gets the current configuration implementation.

Returns:
the current configuration implementation.

getLocale

public static Locale getLocale()
Returns the WebWork2 locale. Keys off the property webwork.locale which should be set as the Java toString() representation of a Locale object (i.e., "en", "de_DE", "_GB", "en_US_WIN", "de__POSIX", "fr_MAC", etc).

If no locale is specified then the default VM locale is used (Locale.getDefault()).

Returns:
the WebWork2 locale if specified or the VM default locale.

isSet

public static boolean isSet(String name)
Determines whether or not a value has been set. Useful for testing for the existance of parameter without throwing an IllegalArgumentException.

Parameters:
name - the name of the property to test.
Returns:
true if the property exists and has a value, false otherwise.

getString

public static String getString(String name)
                        throws IllegalArgumentException
Returns a property as a String. This will throw an IllegalArgumentException if an error occurs while retrieveing the property or if the property doesn't exist.

Parameters:
name - the name of the property to get.
Returns:
the property as a String
Throws:
IllegalArgumentException - if an error occurs retrieveing the property or the property does not exist.

get

public static Object get(String name)
                  throws IllegalArgumentException
Returns a property as an Object. This will throw an IllegalArgumentException if an error occurs while retrieveing the property or if the property doesn't exist.

Parameters:
name - the name of the property to get.
Returns:
the property as an Object.
Throws:
IllegalArgumentException - if an error occurs retrieveing the property or the property does not exist.

list

public static Iterator list()
Returns an Iterator of all properties names.

Returns:
an Iterator of all properties names.

isSetImpl

public boolean isSetImpl(String name)
Implementation of the isSet(String) method.

See Also:
isSet(String)

set

public static void set(String name,
                       Object value)
                throws IllegalArgumentException,
                       UnsupportedOperationException
Sets a property. Throws an exception if an error occurs when setting the property or if the Configuration implementation does not support setting properties.

Parameters:
name - the name of the property to set.
value - the property to set.
Throws:
IllegalArgumentException - if an error occurs when setting the property.
UnsupportedOperationException - if the config implementation does not support setting properties.

setImpl

public void setImpl(String name,
                    Object value)
             throws IllegalArgumentException,
                    UnsupportedOperationException
Implementation of the set(String, Object) method.

Throws:
IllegalArgumentException
UnsupportedOperationException
See Also:
set(String, Object)

getImpl

public Object getImpl(String aName)
               throws IllegalArgumentException
Implementation of the get(String) method.

Throws:
IllegalArgumentException
See Also:
get(String)

listImpl

public Iterator listImpl()
Implementation of the list() method.

See Also:
list()

reset

public static void reset()

WebWork Project Page