org.apache.struts2.config
Class Settings

java.lang.Object
  extended by org.apache.struts2.config.Settings
Direct Known Subclasses:
DefaultSettings, DelegatingSettings, PropertiesSettings

Deprecated. Since Struts 2.1.2

 class Settings
extends Object

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
(package private) static Settings defaultImpl
          Deprecated. An instance of DefaultSettings to use when another implementation is not provided (plugged in).
(package private) static Locale locale
          Deprecated. An instance of the default locale as specified by the struts.locale setting.
private static Logger LOG
          Deprecated. The Logging instance for this class.
(package private) static Settings settingsImpl
          Deprecated. A pluggable implementation of Settings, provided through the setInstance(org.apache.struts2.config.Settings) method.
 
Constructor Summary
Settings()
          Deprecated.  
 
Method Summary
static String get(String name)
          Deprecated. Provides a setting value as a String.
private static Settings getDefaultInstance()
          Deprecated. Creates a default Settings object.
 String getImpl(String name)
          Deprecated. Implements the get(String) method.
static Settings getInstance()
          Deprecated. Provides the Settings object.
static Locale getLocale()
          Deprecated. Provides the Struts default locale.
static Location getLocation(String name)
          Deprecated. Provides the Location of a setting.
 Location getLocationImpl(String name)
          Deprecated. Implements the getLocation(String) method.
static boolean isSet(String name)
          Deprecated. Determines whether or not a setting has a registered value.
 boolean isSetImpl(String name)
          Deprecated. Implements the isSet(String) method.
static Iterator list()
          Deprecated. Provides an Iterator of all properties names.
 Iterator listImpl()
          Deprecated. Implements the list() method.
static void reset()
          Deprecated. Resets the default and any plugin Setting instance to null.
static void set(String name, String value)
          Deprecated. Registers a value for a setting.
 void setImpl(String name, String value)
          Deprecated. Implements the set(String, String) method.
static void setInstance(Settings config)
          Deprecated. Registers a custom Settings implementation (plugin), and resets the cached locale.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

settingsImpl

static Settings settingsImpl
Deprecated. 
A pluggable implementation of Settings, provided through the setInstance(org.apache.struts2.config.Settings) method.


defaultImpl

static Settings defaultImpl
Deprecated. 
An instance of DefaultSettings to use when another implementation is not provided (plugged in).


locale

static Locale locale
Deprecated. 
An instance of the default locale as specified by the struts.locale setting.

See Also:
getLocale()

LOG

private static final Logger LOG
Deprecated. 
The Logging instance for this class.

Constructor Detail

Settings

Settings()
Deprecated. 
Method Detail

setInstance

public static void setInstance(Settings config)
                        throws IllegalStateException
Deprecated. 
Registers a custom Settings implementation (plugin), and resets the cached locale.

This method can only be called once.

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

getInstance

public static Settings getInstance()
Deprecated. 
Provides the Settings object.

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

Returns:
the Settings object.

getLocale

public static Locale getLocale()
Deprecated. 
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.

Returns:
the Struts default locale if specified or the VM default locale.
See Also:
Locale.getDefault()

isSet

public static boolean isSet(String name)
Deprecated. 
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.

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

get

public static String get(String name)
                  throws IllegalArgumentException
Deprecated. 
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.

Parameters:
name - the name of the setting to retrieve.
Returns:
the setting value as a String.
Throws:
IllegalArgumentException - if an error occurs retrieving the property or the property does not exist.

getLocation

public static Location getLocation(String name)
                            throws IllegalArgumentException
Deprecated. 
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.

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

list

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

Returns:
an Iterator of all properties names.

isSetImpl

public boolean isSetImpl(String name)
Deprecated. 
Implements the isSet(String) method.

Parameters:
name - Identifier for the setting value to change
Returns:
True if the setting exists and has a value, false otherwise.
See Also:
isSet(String)

set

public static void set(String name,
                       String value)
                throws IllegalArgumentException,
                       UnsupportedOperationException
Deprecated. 
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.

Parameters:
name - the name of the setting.
value - the value to register for the setting.
Throws:
IllegalArgumentException - if an error occurs when setting the value.
UnsupportedOperationException - if the config implementation does not support setting values.

setImpl

public void setImpl(String name,
                    String value)
             throws IllegalArgumentException,
                    UnsupportedOperationException
Deprecated. 
Implements the set(String, String) method.

Parameters:
name - Identifer for the setting to change.
value - The new value for the setting.
Throws:
IllegalArgumentException - if an error occurs when setting the value.
UnsupportedOperationException - if the config implementation does not support setting values.
See Also:
set(String, String)

getImpl

public String getImpl(String name)
               throws IllegalArgumentException
Deprecated. 
Implements the get(String) method.

Parameters:
name - The name of the setting value to retreive
Returns:
The setting value as a String
Throws:
IllegalArgumentException - if an error occurs when retrieving the value
See Also:
get(String)

getLocationImpl

public Location getLocationImpl(String name)
                         throws IllegalArgumentException
Deprecated. 
Implements the getLocation(String) method.

Parameters:
name - Name of the setting to locate
Returns:
The location of the setting
Throws:
IllegalArgumentException - if an error occurs when retrieving the value
See Also:
getLocation(String)

listImpl

public Iterator listImpl()
Deprecated. 
Implements the list() method.

Returns:
A list of the settings as an iterator
See Also:
list()

getDefaultInstance

private static Settings getDefaultInstance()
Deprecated. 
Creates a default Settings object.

A default implementation may be specified by the struts.configuration setting; otherwise, this method instantiates DefaultSettings as the default implementation.

Returns:
A default Settings object.

reset

public static void reset()
Deprecated. 
Resets the default and any plugin Setting instance to null.



Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.