Methods Summary |
---|
public static java.lang.String | get(java.lang.String name)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.
return getInstance().getImpl(name);
|
private static org.apache.struts2.config.Settings | getDefaultInstance()Creates a default Settings object.
A default implementation may be specified by the struts.configuration setting;
otherwise, this method instantiates {@link DefaultSettings} as the default implementation.
if (defaultImpl == null) {
// Create bootstrap implementation
defaultImpl = new DefaultSettings();
// Create default implementation
try {
String className = get(StrutsConstants.STRUTS_CONFIGURATION);
if (!className.equals(defaultImpl.getClass().getName())) {
try {
// singleton instances shouldn't be built accessing request or session-specific context data
defaultImpl = (Settings) ObjectFactory.getObjectFactory().buildBean(Thread.currentThread().getContextClassLoader().loadClass(className), null);
} catch (Exception e) {
LOG.error("Settings: Could not instantiate the struts.configuration object, substituting the default implementation.", e);
}
}
} catch (IllegalArgumentException ex) {
// ignore
}
}
return defaultImpl;
|
public java.lang.String | getImpl(java.lang.String name)Implements the {@link #get(String)} method.
return null;
|
public static org.apache.struts2.config.Settings | getInstance()Provides the Settings object.
This method will substitute the default instance if another instance is not registered.
return (settingsImpl == null) ? getDefaultInstance() : settingsImpl;
|
public static java.util.Locale | getLocale()Provides the Struts default locale.
This method utilizes the struts.locale setting, which should be given
as the Java {@link java.util.Locale#toString() 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.
if (locale == null) {
try {
StringTokenizer localeTokens = new StringTokenizer(get(StrutsConstants.STRUTS_LOCALE), "_");
String lang = null;
String country = null;
if (localeTokens.hasMoreTokens()) {
lang = localeTokens.nextToken();
}
if (localeTokens.hasMoreTokens()) {
country = localeTokens.nextToken();
}
locale = new Locale(lang, country);
} catch (Throwable t) {
// Default
LOG.warn("Settings: Could not parse struts.locale setting, substituting default VM locale");
locale = Locale.getDefault();
}
}
return locale;
|
public static com.opensymphony.xwork2.util.location.Location | getLocation(java.lang.String name)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.
return getInstance().getLocationImpl(name);
|
public com.opensymphony.xwork2.util.location.Location | getLocationImpl(java.lang.String name)Implements the {@link #getLocation(String)} method.
return null;
|
public static boolean | isSet(java.lang.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.
return getInstance().isSetImpl(name);
|
public boolean | isSetImpl(java.lang.String name)Implements the {@link #isSet(String)} method.
// this is dumb.. maybe it should just throw an unsupported op like the rest of the *Impl
// methods in this class.
return false;
|
public static java.util.Iterator | list()Provides an Iterator of all properties names.
return getInstance().listImpl();
|
public java.util.Iterator | listImpl()Implements the {@link #list()} method.
throw new UnsupportedOperationException("Settings: This implementation does not support listing the registered settings");
|
public static void | reset()Resets the default and any plugin Setting instance to null.
defaultImpl = null;
settingsImpl = null;
|
public static void | set(java.lang.String name, java.lang.String value)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.
getInstance().setImpl(name, value);
|
public void | setImpl(java.lang.String name, java.lang.String value)Implements the {@link #set(String, String)} method.
throw new UnsupportedOperationException("Settings: This implementation does not support setting a value.");
|
public static void | setInstance(org.apache.struts2.config.Settings config)Registers a custom Settings implementation (plugin),
and resets the cached locale.
This method can only be called once.
settingsImpl = config;
locale = null;
|