|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.struts2.config.Settings
class Settings
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 |
---|
static Settings settingsImpl
setInstance(org.apache.struts2.config.Settings)
method.
static Settings defaultImpl
DefaultSettings
to use when another implementation is not provided (plugged in).
static Locale locale
struts.locale
setting.
getLocale()
private static final Logger LOG
Constructor Detail |
---|
Settings()
Method Detail |
---|
public static void setInstance(Settings config) throws IllegalStateException
This method can only be called once.
config
- a Settings implementation
IllegalStateException
- if an error occurs when setting the settings implementation.public static Settings getInstance()
This method will substitute the default instance if another instance is not registered.
public static Locale getLocale()
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.
Locale.getDefault()
public static boolean isSet(String name)
This method is useful for testing for the existance of setting without throwing an IllegalArgumentException.
name
- the name of a setting to test.
true
if the setting exists and has a value, false
otherwise.public static String get(String name) throws IllegalArgumentException
The method will throw an IllegalArgumentException
if an error occurs
while retrieveing the property or if the property doesn't exist.
name
- the name of the setting to retrieve.
IllegalArgumentException
- if an error occurs retrieving the property or the property does not exist.public static Location getLocation(String name) throws IllegalArgumentException
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.
name
- the name of the property to get.
IllegalArgumentException
- if an error occurs retrieving the property or the property does not exist.public static Iterator list()
public boolean isSetImpl(String name)
isSet(String)
method.
name
- Identifier for the setting value to change
isSet(String)
public static void set(String name, String value) throws IllegalArgumentException, UnsupportedOperationException
This method raises an exception if an error occurs when setting the value or if the settings implementation does not support setting values.
name
- the name of the setting.value
- the value to register for the setting.
IllegalArgumentException
- if an error occurs when setting the value.
UnsupportedOperationException
- if the config implementation does not support setting values.public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException
set(String, String)
method.
name
- Identifer for the setting to change.value
- The new value for the setting.
IllegalArgumentException
- if an error occurs when setting the value.
UnsupportedOperationException
- if the config implementation does not support setting values.set(String, String)
public String getImpl(String name) throws IllegalArgumentException
get(String)
method.
name
- The name of the setting value to retreive
IllegalArgumentException
- if an error occurs when retrieving the valueget(String)
public Location getLocationImpl(String name) throws IllegalArgumentException
getLocation(String)
method.
name
- Name of the setting to locate
IllegalArgumentException
- if an error occurs when retrieving the valuegetLocation(String)
public Iterator listImpl()
list()
method.
list()
private static Settings getDefaultInstance()
A default implementation may be specified by the struts.configuration
setting;
otherwise, this method instantiates DefaultSettings
as the default implementation.
public static void reset()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |