Save This Page
Home » struts-2.0.11.2-src » org.apache » struts2 » config » [javadoc | source]
org.apache.struts2.config
class: Settings [javadoc | source]
java.lang.Object
   org.apache.struts2.config.Settings

Direct Known Subclasses:
    DefaultSettings, DelegatingSettings, PropertiesSettings

Settings retrieves and exposes default values used by the framework. An application can override a factory default and provide its own value for a setting.

Implementation of the class is pluggable (the default implementation is DefaultSettings ). Pluggability gives applications to ability to customize how settings are retrieved. As an example, an application may wish to check some custom property store before delegating to the usual configuration and property files.

Key methods:

Key methods for subclasses (plugins):

Field Summary
static  Settings settingsImpl    A pluggable implementation of Settings, provided through the #setInstance method. 
static  Settings defaultImpl    An instance of DefaultSettings to use when another implementation is not provided (plugged in). 
static  Locale locale    An instance of the default locale as specified by the struts.locale setting. 
Method from org.apache.struts2.config.Settings Summary:
get,   getImpl,   getInstance,   getLocale,   getLocation,   getLocationImpl,   isSet,   isSetImpl,   list,   listImpl,   reset,   set,   setImpl,   setInstance
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.struts2.config.Settings Detail:
 public static String get(String name) throws IllegalArgumentException 
    Provides a setting value as a String.

    The method will throw an IllegalArgumentException if an error occurs while retrieveing the property or if the property doesn't exist.

 public String getImpl(String name) throws IllegalArgumentException 
 public static Settings getInstance() 
    Provides the Settings object.

    This method will substitute the default instance if another instance is not registered.

 public static Locale getLocale() 
    Provides the Struts default locale.

    This method utilizes the struts.locale setting, which should be given as the Java toString() representation of a Locale object ("en", "de_DE", "_GB", "en_US_WIN", "de__POSIX", "fr_MAC", and so forth).

    If a struts.locale setting is not registered, then the default virtual machine locale is substituted and cached.

 public static Location getLocation(String name) throws IllegalArgumentException 
    Provides the Location of a setting.

    The Location is utilized as part of precise error reporting.

    This method will throw an IllegalArgumentException if an error occurs while retrieving the value or if the setting doesn't exist.

 public Location getLocationImpl(String name) throws IllegalArgumentException 
 public static boolean isSet(String name) 
    Determines whether or not a setting has a registered value.

    This method is useful for testing for the existance of setting without throwing an IllegalArgumentException.

 public boolean isSetImpl(String name) 
 public static Iterator list() 
    Provides an Iterator of all properties names.
 public Iterator listImpl() 
 public static  void reset() 
    Resets the default and any plugin Setting instance to null.
 public static  void set(String name,
    String value) throws IllegalArgumentException, UnsupportedOperationException 
    Registers a value for a setting.

    This method raises an exception if an error occurs when setting the value or if the settings implementation does not support setting values.

 public  void setImpl(String name,
    String value) throws IllegalArgumentException, UnsupportedOperationException 
 public static  void setInstance(Settings config) throws IllegalStateException 
    Registers a custom Settings implementation (plugin), and resets the cached locale.

    This method can only be called once.