diff --git a/core/src/main/java/org/apache/struts2/StrutsTestCase.java b/core/src/main/java/org/apache/struts2/StrutsTestCase.java index 6ac9eb668..12b275227 100644 --- a/core/src/main/java/org/apache/struts2/StrutsTestCase.java +++ b/core/src/main/java/org/apache/struts2/StrutsTestCase.java @@ -17,7 +17,7 @@ */ package org.apache.struts2; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.config.StrutsXMLConfigurationProvider; import org.apache.struts2.dispatcher.Dispatcher; import org.springframework.mock.web.MockServletContext; @@ -38,7 +38,7 @@ public abstract class StrutsTestCase extends XWorkTestCase { */ protected void setUp() throws Exception { super.setUp(); - Configuration.reset(); + Settings.reset(); LocalizedTextUtil.clearDefaultResourceBundles(); Dispatcher du = new Dispatcher(new MockServletContext()); Dispatcher.setInstance(du); diff --git a/core/src/main/java/org/apache/struts2/components/Form.java b/core/src/main/java/org/apache/struts2/components/Form.java index a81e825f3..ff79ed507 100644 --- a/core/src/main/java/org/apache/struts2/components/Form.java +++ b/core/src/main/java/org/apache/struts2/components/Form.java @@ -102,8 +102,8 @@ public class Form extends ClosingUIBean { protected static boolean compatibilityMode = false; static { - if (org.apache.struts2.config.Configuration.isSet(StrutsConstants.STRUTS_COMPATIBILITY_MODE)) { - compatibilityMode = "true".equals(org.apache.struts2.config.Configuration.get(StrutsConstants.STRUTS_COMPATIBILITY_MODE)); + if (org.apache.struts2.config.Settings.isSet(StrutsConstants.STRUTS_COMPATIBILITY_MODE)) { + compatibilityMode = "true".equals(org.apache.struts2.config.Settings.get(StrutsConstants.STRUTS_COMPATIBILITY_MODE)); } } diff --git a/core/src/main/java/org/apache/struts2/components/Head.java b/core/src/main/java/org/apache/struts2/components/Head.java index 0faa9e1cb..44fae4c4f 100644 --- a/core/src/main/java/org/apache/struts2/components/Head.java +++ b/core/src/main/java/org/apache/struts2/components/Head.java @@ -18,7 +18,7 @@ package org.apache.struts2.components; import com.opensymphony.xwork2.util.OgnlValueStack; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.StrutsConstants; import javax.servlet.http.HttpServletRequest; @@ -101,7 +101,7 @@ public class Head extends UIBean { } } - addParameter("encoding", Configuration.get(StrutsConstants.STRUTS_I18N_ENCODING)); + addParameter("encoding", Settings.get(StrutsConstants.STRUTS_I18N_ENCODING)); addParameter("debug", Boolean.valueOf(debug).toString()); } diff --git a/core/src/main/java/org/apache/struts2/components/Include.java b/core/src/main/java/org/apache/struts2/components/Include.java index 3cb4b77e5..cb123d73b 100644 --- a/core/src/main/java/org/apache/struts2/components/Include.java +++ b/core/src/main/java/org/apache/struts2/components/Include.java @@ -17,7 +17,7 @@ */ package org.apache.struts2.components; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.util.FastByteArrayOutputStream; import org.apache.struts2.RequestUtils; import org.apache.struts2.StrutsConstants; @@ -264,7 +264,7 @@ public class Include extends Component { private static String getEncoding() { if (encodingDefined) { try { - encoding = Configuration.getString(StrutsConstants.STRUTS_I18N_ENCODING); + encoding = Settings.get(StrutsConstants.STRUTS_I18N_ENCODING); } catch (IllegalArgumentException e) { encoding = System.getProperty("file.encoding"); encodingDefined = false; diff --git a/core/src/main/java/org/apache/struts2/components/UIBean.java b/core/src/main/java/org/apache/struts2/components/UIBean.java index 8d10bf019..77f8811fd 100644 --- a/core/src/main/java/org/apache/struts2/components/UIBean.java +++ b/core/src/main/java/org/apache/struts2/components/UIBean.java @@ -22,7 +22,7 @@ import org.apache.struts2.components.template.Template; import org.apache.struts2.components.template.TemplateEngine; import org.apache.struts2.components.template.TemplateEngineManager; import org.apache.struts2.components.template.TemplateRenderingContext; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.views.util.ContextUtil; import com.opensymphony.xwork2.config.ConfigurationException; import com.opensymphony.xwork2.util.OgnlValueStack; @@ -512,7 +512,7 @@ public abstract class UIBean extends Component { // Default template set if ((templateDir == null) || (templateDir.equals(""))) { - templateDir = Configuration.getString(StrutsConstants.STRUTS_UI_TEMPLATEDIR); + templateDir = Settings.get(StrutsConstants.STRUTS_UI_TEMPLATEDIR); } // Defaults to 'template' @@ -545,7 +545,7 @@ public abstract class UIBean extends Component { // Default theme set if ((theme == null) || (theme.equals(""))) { - theme = Configuration.getString(StrutsConstants.STRUTS_UI_THEME); + theme = Settings.get(StrutsConstants.STRUTS_UI_THEME); } return theme; diff --git a/core/src/main/java/org/apache/struts2/components/template/TemplateEngineManager.java b/core/src/main/java/org/apache/struts2/components/template/TemplateEngineManager.java index b6d6baf91..93339e7f6 100644 --- a/core/src/main/java/org/apache/struts2/components/template/TemplateEngineManager.java +++ b/core/src/main/java/org/apache/struts2/components/template/TemplateEngineManager.java @@ -17,7 +17,7 @@ */ package org.apache.struts2.components.template; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import java.util.HashMap; import java.util.Map; @@ -69,8 +69,8 @@ public class TemplateEngineManager { templateType = templateName.substring(templateName.indexOf(".") + 1); } else if (templateTypeOverride !=null && templateTypeOverride.length() > 0) { templateType = templateTypeOverride; - } else if (Configuration.isSet(DEFAULT_TEMPLATE_TYPE_CONFIG_KEY)) { - templateType = (String) Configuration.get(DEFAULT_TEMPLATE_TYPE_CONFIG_KEY); + } else if (Settings.isSet(DEFAULT_TEMPLATE_TYPE_CONFIG_KEY)) { + templateType = (String) Settings.get(DEFAULT_TEMPLATE_TYPE_CONFIG_KEY); } return (TemplateEngine) MANAGER.templateEngines.get(templateType); } diff --git a/core/src/main/java/org/apache/struts2/config/DefaultConfiguration.java b/core/src/main/java/org/apache/struts2/config/DefaultSettings.java similarity index 72% rename from core/src/main/java/org/apache/struts2/config/DefaultConfiguration.java rename to core/src/main/java/org/apache/struts2/config/DefaultSettings.java index 23411eac5..5086033ba 100644 --- a/core/src/main/java/org/apache/struts2/config/DefaultConfiguration.java +++ b/core/src/main/java/org/apache/struts2/config/DefaultSettings.java @@ -28,41 +28,41 @@ import java.util.StringTokenizer; /** - * Default implementation of Configuration - creates and delegates to other configurations by using an internal - * {@link DelegatingConfiguration}. + * Default implementation of Settings - creates and delegates to other settingss by using an internal + * {@link DelegatingSettings}. */ -public class DefaultConfiguration extends Configuration { +public class DefaultSettings extends Settings { protected Log log = LogFactory.getLog(this.getClass()); - Configuration config; + Settings config; /** - * Creates a new DefaultConfiguration object by loading all property files - * and creating an internal {@link DelegatingConfiguration} object. All calls to get and set - * in this class will call that configuration object. + * Creates a new DefaultSettings object by loading all property files + * and creating an internal {@link DelegatingSettings} object. All calls to get and set + * in this class will call that settings object. */ - public DefaultConfiguration() { + public DefaultSettings() { // Create default implementations // Use default properties and struts.properties - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList(); try { - list.add(new PropertiesConfiguration("struts")); + list.add(new PropertiesSettings("struts")); } catch (Exception e) { log.warn("Could not find or error in struts.properties", e); } try { - list.add(new PropertiesConfiguration("org/apache/struts2/default")); + list.add(new PropertiesSettings("org/apache/struts2/default")); } catch (Exception e) { log.error("Could not find org/apache/struts2/default.properties", e); } - Configuration[] configList = new Configuration[list.size()]; - config = new DelegatingConfiguration((Configuration[]) list.toArray(configList)); + Settings[] configList = new Settings[list.size()]; + config = new DelegatingSettings((Settings[]) list.toArray(configList)); - // Add list of additional properties configurations + // Add list of additional properties settingss try { StringTokenizer configFiles = new StringTokenizer((String) config.getImpl(StrutsConstants.STRUTS_CUSTOM_PROPERTIES), ","); @@ -70,16 +70,16 @@ public class DefaultConfiguration extends Configuration { String name = configFiles.nextToken(); try { - list.add(new PropertiesConfiguration(name)); + list.add(new PropertiesSettings(name)); } catch (Exception e) { log.error("Could not find " + name + ".properties. Skipping"); } } - configList = new Configuration[list.size()]; - config = new DelegatingConfiguration((Configuration[]) list.toArray(configList)); + configList = new Settings[list.size()]; + config = new DelegatingSettings((Settings[]) list.toArray(configList)); } catch (IllegalArgumentException e) { - // thrown when Configuration is unable to find a certain property + // thrown when Settings is unable to find a certain property // eg. struts.custom.properties in default.properties which is commented // out } @@ -108,9 +108,9 @@ public class DefaultConfiguration extends Configuration { /** * Sets the given property - delegates to the internal config implementation. * - * @see #set(String, Object) + * @see #set(String, String) */ - public void setImpl(String aName, Object aValue) throws IllegalArgumentException, UnsupportedOperationException { + public void setImpl(String aName, String aValue) throws IllegalArgumentException, UnsupportedOperationException { config.setImpl(aName, aValue); } @@ -119,7 +119,7 @@ public class DefaultConfiguration extends Configuration { * * @see #get(String) */ - public Object getImpl(String aName) throws IllegalArgumentException { + public String getImpl(String aName) throws IllegalArgumentException { // Delegate return config.getImpl(aName); } diff --git a/core/src/main/java/org/apache/struts2/config/DelegatingConfiguration.java b/core/src/main/java/org/apache/struts2/config/DelegatingSettings.java similarity index 83% rename from core/src/main/java/org/apache/struts2/config/DelegatingConfiguration.java rename to core/src/main/java/org/apache/struts2/config/DelegatingSettings.java index 645840072..6580686dd 100644 --- a/core/src/main/java/org/apache/struts2/config/DelegatingConfiguration.java +++ b/core/src/main/java/org/apache/struts2/config/DelegatingSettings.java @@ -23,22 +23,22 @@ import java.util.Set; /** - * A Configuration implementation which stores an internal list of configuration objects. Each time - * a config method is called (get, set, list, etc..) this class will go through the list of configurations + * A Settings implementation which stores an internal list of settings objects. Each time + * a config method is called (get, set, list, etc..) this class will go through the list of settingss * and call the method until successful. * */ -public class DelegatingConfiguration extends Configuration { +public class DelegatingSettings extends Settings { - Configuration[] configList; + Settings[] configList; /** - * Creates a new DelegatingConfiguration object given a list of {@link Configuration} implementations. + * Creates a new DelegatingSettings object given a list of {@link Settings} implementations. * - * @param aConfigList a list of Configuration implementations. + * @param aConfigList a list of Settings implementations. */ - public DelegatingConfiguration(Configuration[] aConfigList) { + public DelegatingSettings(Settings[] aConfigList) { configList = aConfigList; } @@ -47,11 +47,11 @@ public class DelegatingConfiguration extends Configuration { * Sets the given property - calls setImpl(String, Object) method on config objects in the config * list until successful. * - * @see #set(String, Object) + * @see #set(String, String) */ - public void setImpl(String name, Object value) throws IllegalArgumentException, UnsupportedOperationException { + public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { // Determine which config to use by using get - // Delegate to the other configurations + // Delegate to the other settingss IllegalArgumentException e = null; for (int i = 0; i < configList.length; i++) { @@ -79,8 +79,8 @@ public class DelegatingConfiguration extends Configuration { * * @see #get(String) */ - public Object getImpl(String name) throws IllegalArgumentException { - // Delegate to the other configurations + public String getImpl(String name) throws IllegalArgumentException { + // Delegate to the other settings IllegalArgumentException e = null; for (int i = 0; i < configList.length; i++) { diff --git a/core/src/main/java/org/apache/struts2/config/PropertiesConfiguration.java b/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java similarity index 85% rename from core/src/main/java/org/apache/struts2/config/PropertiesConfiguration.java rename to core/src/main/java/org/apache/struts2/config/PropertiesSettings.java index bbb00cbcf..dc2420810 100644 --- a/core/src/main/java/org/apache/struts2/config/PropertiesConfiguration.java +++ b/core/src/main/java/org/apache/struts2/config/PropertiesSettings.java @@ -26,21 +26,21 @@ import org.apache.struts2.StrutsException; /** - * A class to handle configuration via a properties file. + * A class to handle settings via a properties file. */ -public class PropertiesConfiguration extends Configuration { +public class PropertiesSettings extends Settings { Properties settings; /** * Creates a new properties config given the name of a properties file. The name is expected to NOT have - * the ".properties" file extension. So when new PropertiesConfiguration("foo") is called + * the ".properties" file extension. So when new PropertiesSettings("foo") is called * this class will look in the classpath for the foo.properties file. * * @param name the name of the properties file, excluding the ".properties" extension. */ - public PropertiesConfiguration(String name) { + public PropertiesSettings(String name) { settings = new Properties(); URL settingsUrl = Thread.currentThread().getContextClassLoader().getResource(name + ".properties"); @@ -61,10 +61,10 @@ public class PropertiesConfiguration extends Configuration { /** * Sets a property in the properties file. * - * @see #set(String, Object) + * @see #set(String, String) */ - public void setImpl(String aName, Object aValue) { - settings.put(aName, aValue); + public void setImpl(String aName, String aValue) { + settings.setProperty(aName, aValue); } /** @@ -72,8 +72,8 @@ public class PropertiesConfiguration extends Configuration { * * @see #get(String) */ - public Object getImpl(String aName) throws IllegalArgumentException { - Object setting = settings.get(aName); + public String getImpl(String aName) throws IllegalArgumentException { + String setting = settings.getProperty(aName); if (setting == null) { throw new IllegalArgumentException("No such setting:" + aName); diff --git a/core/src/main/java/org/apache/struts2/config/Configuration.java b/core/src/main/java/org/apache/struts2/config/Settings.java similarity index 66% rename from core/src/main/java/org/apache/struts2/config/Configuration.java rename to core/src/main/java/org/apache/struts2/config/Settings.java index 4a7bca4c8..1d5132f76 100644 --- a/core/src/main/java/org/apache/struts2/config/Configuration.java +++ b/core/src/main/java/org/apache/struts2/config/Settings.java @@ -29,50 +29,50 @@ import java.util.StringTokenizer; /** * Handles all Struts config properties. Implementation of this class is pluggable (the - * default implementation is {@link DefaultConfiguration}). This gives developers to ability to customize how + * default implementation is {@link DefaultSettings}). This gives developers to ability to customize how * Struts properties are set and retrieved. As an example, a developer may wish to check a separate property * store before delegating to the Struts one.

*

* Key methods:

    *

    *

  • {@link #getLocale()}
  • - *
  • {@link #getString(String)}
  • - *
  • {@link #set(String, Object)}
  • + *
  • {@link #get(String)}
  • + *
  • {@link #set(String, String)}
  • *
  • {@link #list()}
*

* Key methods for subclassers:

    *

    *

  • {@link #getImpl(String)}
  • - *
  • {@link #setImpl(String, Object)}
  • + *
  • {@link #setImpl(String, String)}
  • *
  • {@link #listImpl()}
  • *
  • {@link #isSetImpl(String)}
*/ -public class Configuration { +public class Settings { - static Configuration configurationImpl; - static Configuration defaultImpl; + static Settings settingsImpl; + static Settings defaultImpl; static Locale locale; // Cached locale - private static final Log LOG = LogFactory.getLog(Configuration.class); + private static final Log LOG = LogFactory.getLog(Settings.class); /** - * Sets the current configuration implementation. Can only be called once. + * Sets the current settings implementation. Can only be called once. * - * @param config a Configuration implementation - * @throws IllegalStateException if an error occurs when setting the configuration implementation. + * @param config a Settings implementation + * @throws IllegalStateException if an error occurs when setting the settings implementation. */ - public static void setConfiguration(Configuration config) throws IllegalStateException { - configurationImpl = config; + public static void setInstance(Settings config) throws IllegalStateException { + settingsImpl = config; locale = null; // Reset cached locale } /** - * Gets the current configuration implementation. + * Gets the current settings implementation. * - * @return the current configuration implementation. + * @return the current settings implementation. */ - public static Configuration getConfiguration() { - return (configurationImpl == null) ? getDefaultConfiguration() : configurationImpl; + public static Settings getInstance() { + return (settingsImpl == null) ? getDefaultInstance() : settingsImpl; } /** @@ -87,7 +87,7 @@ public class Configuration { public static Locale getLocale() { if (locale == null) { try { - StringTokenizer localeTokens = new StringTokenizer(getString(StrutsConstants.STRUTS_LOCALE), "_"); + StringTokenizer localeTokens = new StringTokenizer(get(StrutsConstants.STRUTS_LOCALE), "_"); String lang = null; String country = null; @@ -118,21 +118,7 @@ public class Configuration { * @return true if the property exists and has a value, false otherwise. */ public static boolean isSet(String name) { - return getConfiguration().isSetImpl(name); - } - - /** - * 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. - * - * @param name the name of the property to get. - * @return the property as a String - * @throws IllegalArgumentException if an error occurs retrieveing the property or the property does not exist. - */ - public static String getString(String name) throws IllegalArgumentException { - String val = get(name).toString(); - - return val; + return getInstance().isSetImpl(name); } /** @@ -143,8 +129,8 @@ public class Configuration { * @return the property as an Object. * @throws IllegalArgumentException if an error occurs retrieveing the property or the property does not exist. */ - public static Object get(String name) throws IllegalArgumentException { - Object val = getConfiguration().getImpl(name); + public static String get(String name) throws IllegalArgumentException { + String val = getInstance().getImpl(name); return val; } @@ -155,7 +141,7 @@ public class Configuration { * @return an Iterator of all properties names. */ public static Iterator list() { - return getConfiguration().listImpl(); + return getInstance().listImpl(); } /** @@ -171,24 +157,24 @@ public class Configuration { /** * Sets a property. Throws an exception if an error occurs when setting the property or if the - * Configuration implementation does not support setting properties. + * Settings implementation does not support setting properties. * * @param name the name of the property to set. * @param value the property to set. * @throws IllegalArgumentException if an error occurs when setting the property. * @throws UnsupportedOperationException if the config implementation does not support setting properties. */ - public static void set(String name, Object value) throws IllegalArgumentException, UnsupportedOperationException { - getConfiguration().setImpl(name, value); + public static void set(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { + getInstance().setImpl(name, value); } /** - * Implementation of the {@link #set(String, Object)} method. + * Implementation of the {@link #set(String, String)} method. * - * @see #set(String, Object) + * @see #set(String, String) */ - public void setImpl(String name, Object value) throws IllegalArgumentException, UnsupportedOperationException { - throw new UnsupportedOperationException("This configuration does not support updating a setting"); + public void setImpl(String name, String value) throws IllegalArgumentException, UnsupportedOperationException { + throw new UnsupportedOperationException("This settings does not support updating a setting"); } /** @@ -196,7 +182,7 @@ public class Configuration { * * @see #get(String) */ - public Object getImpl(String aName) throws IllegalArgumentException { + public String getImpl(String aName) throws IllegalArgumentException { return null; } @@ -206,24 +192,24 @@ public class Configuration { * @see #list() */ public Iterator listImpl() { - throw new UnsupportedOperationException("This configuration does not support listing the settings"); + throw new UnsupportedOperationException("This settings does not support listing the settings"); } - private static Configuration getDefaultConfiguration() { + private static Settings getDefaultInstance() { if (defaultImpl == null) { // Create bootstrap implementation - defaultImpl = new DefaultConfiguration(); + defaultImpl = new DefaultSettings(); // Create default implementation try { - String className = getString(StrutsConstants.STRUTS_CONFIGURATION); + 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 = (Configuration) ObjectFactory.getObjectFactory().buildBean(Thread.currentThread().getContextClassLoader().loadClass(className), null); + defaultImpl = (Settings) ObjectFactory.getObjectFactory().buildBean(Thread.currentThread().getContextClassLoader().loadClass(className), null); } catch (Exception e) { - LOG.error("Could not instantiate configuration", e); + LOG.error("Could not instantiate settings", e); } } } catch (IllegalArgumentException ex) { @@ -236,6 +222,6 @@ public class Configuration { public static void reset() { defaultImpl = null; - configurationImpl = null; + settingsImpl = null; } } diff --git a/core/src/main/java/org/apache/struts2/config_browser/ActionNamesAction.java b/core/src/main/java/org/apache/struts2/config_browser/ActionNamesAction.java index 5a571423e..407ada55c 100644 --- a/core/src/main/java/org/apache/struts2/config_browser/ActionNamesAction.java +++ b/core/src/main/java/org/apache/struts2/config_browser/ActionNamesAction.java @@ -19,7 +19,7 @@ package org.apache.struts2.config_browser; import com.opensymphony.xwork2.ActionSupport; import com.opensymphony.xwork2.config.entities.ActionConfig; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.StrutsConstants; import java.util.Set; @@ -60,7 +60,7 @@ public class ActionNamesAction extends ActionSupport { public String getExtension() { if ( extension == null) { - String ext = (String) Configuration.get(StrutsConstants.STRUTS_ACTION_EXTENSION); + String ext = (String) Settings.get(StrutsConstants.STRUTS_ACTION_EXTENSION); if ( ext == null || ext.equals("")) { extension = "action"; } else { diff --git a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java index 1ef1bb715..4700f2a75 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java @@ -35,7 +35,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.struts2.ServletActionContext; import org.apache.struts2.StrutsConstants; import org.apache.struts2.StrutsStatics; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.config.StrutsXMLConfigurationProvider; import org.apache.struts2.dispatcher.mapper.ActionMapping; import org.apache.struts2.dispatcher.multipart.MultiPartRequest; @@ -166,11 +166,11 @@ public class Dispatcher { * @param servletContext The servlet context */ private void init(ServletContext servletContext) { - boolean reloadi18n = Boolean.valueOf((String) Configuration.get(StrutsConstants.STRUTS_I18N_RELOAD)).booleanValue(); + boolean reloadi18n = Boolean.valueOf((String) Settings.get(StrutsConstants.STRUTS_I18N_RELOAD)).booleanValue(); LocalizedTextUtil.setReloadBundles(reloadi18n); - if (Configuration.isSet(StrutsConstants.STRUTS_OBJECTFACTORY)) { - String className = (String) Configuration.get(StrutsConstants.STRUTS_OBJECTFACTORY); + if (Settings.isSet(StrutsConstants.STRUTS_OBJECTFACTORY)) { + String className = (String) Settings.get(StrutsConstants.STRUTS_OBJECTFACTORY); if (className.equals("spring")) { // note: this class name needs to be in string form so we don't put hard // dependencies on spring, since it isn't technically required. @@ -195,8 +195,8 @@ public class Dispatcher { } } - if (Configuration.isSet(StrutsConstants.STRUTS_OBJECTTYPEDETERMINER)) { - String className = (String) Configuration.get(StrutsConstants.STRUTS_OBJECTTYPEDETERMINER); + if (Settings.isSet(StrutsConstants.STRUTS_OBJECTTYPEDETERMINER)) { + String className = (String) Settings.get(StrutsConstants.STRUTS_OBJECTTYPEDETERMINER); if (className.equals("tiger")) { // note: this class name needs to be in string form so we don't put hard // dependencies on xwork-tiger, since it isn't technically required. @@ -215,19 +215,19 @@ public class Dispatcher { } } - if ("true".equals(Configuration.get(StrutsConstants.STRUTS_DEVMODE))) { + if ("true".equals(Settings.get(StrutsConstants.STRUTS_DEVMODE))) { devMode = true; - Configuration.set(StrutsConstants.STRUTS_I18N_RELOAD, "true"); - Configuration.set(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "true"); + Settings.set(StrutsConstants.STRUTS_I18N_RELOAD, "true"); + Settings.set(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "true"); } //check for configuration reloading - if ("true".equalsIgnoreCase(Configuration.getString(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD))) { + if ("true".equalsIgnoreCase(Settings.get(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD))) { FileManager.setReloadingConfigs(true); } - if (Configuration.isSet(StrutsConstants.STRUTS_CONTINUATIONS_PACKAGE)) { - String pkg = Configuration.getString(StrutsConstants.STRUTS_CONTINUATIONS_PACKAGE); + if (Settings.isSet(StrutsConstants.STRUTS_CONTINUATIONS_PACKAGE)) { + String pkg = Settings.get(StrutsConstants.STRUTS_CONTINUATIONS_PACKAGE); ObjectFactory.setContinuationPackage(pkg); } @@ -236,8 +236,8 @@ public class Dispatcher { && servletContext.getServerInfo().indexOf("WebLogic") >= 0) { LOG.info("WebLogic server detected. Enabling Struts parameter access work-around."); paramsWorkaroundEnabled = true; - } else if (Configuration.isSet(StrutsConstants.STRUTS_DISPATCHER_PARAMETERSWORKAROUND)) { - paramsWorkaroundEnabled = "true".equals(Configuration.get(StrutsConstants.STRUTS_DISPATCHER_PARAMETERSWORKAROUND)); + } else if (Settings.isSet(StrutsConstants.STRUTS_DISPATCHER_PARAMETERSWORKAROUND)) { + paramsWorkaroundEnabled = "true".equals(Settings.get(StrutsConstants.STRUTS_DISPATCHER_PARAMETERSWORKAROUND)); } else { LOG.debug("Parameter access work-around disabled."); } @@ -397,8 +397,8 @@ public class Dispatcher { extraContext.put(ActionContext.APPLICATION, applicationMap); Locale locale = null; - if (Configuration.isSet(StrutsConstants.STRUTS_LOCALE)) { - locale = LocalizedTextUtil.localeFromString(Configuration.getString(StrutsConstants.STRUTS_LOCALE), request.getLocale()); + if (Settings.isSet(StrutsConstants.STRUTS_LOCALE)) { + locale = LocalizedTextUtil.localeFromString(Settings.get(StrutsConstants.STRUTS_LOCALE), request.getLocale()); } else { locale = request.getLocale(); } @@ -430,7 +430,7 @@ public class Dispatcher { private static int getMaxSize() { Integer maxSize = new Integer(Integer.MAX_VALUE); try { - String maxSizeStr = Configuration.getString(StrutsConstants.STRUTS_MULTIPART_MAXSIZE); + String maxSizeStr = Settings.get(StrutsConstants.STRUTS_MULTIPART_MAXSIZE); if (maxSizeStr != null) { try { @@ -458,7 +458,7 @@ public class Dispatcher { * @return the path to save uploaded files to */ private String getSaveDir(ServletContext servletContext) { - String saveDir = Configuration.getString(StrutsConstants.STRUTS_MULTIPART_SAVEDIR).trim(); + String saveDir = Settings.get(StrutsConstants.STRUTS_MULTIPART_SAVEDIR).trim(); if (saveDir.equals("")) { File tempdir = (File) servletContext.getAttribute("javax.servlet.context.tempdir"); @@ -490,13 +490,13 @@ public class Dispatcher { */ public void prepare(HttpServletRequest request, HttpServletResponse response) { String encoding = null; - if (Configuration.isSet(StrutsConstants.STRUTS_I18N_ENCODING)) { - encoding = Configuration.getString(StrutsConstants.STRUTS_I18N_ENCODING); + if (Settings.isSet(StrutsConstants.STRUTS_I18N_ENCODING)) { + encoding = Settings.get(StrutsConstants.STRUTS_I18N_ENCODING); } Locale locale = null; - if (Configuration.isSet(StrutsConstants.STRUTS_LOCALE)) { - locale = LocalizedTextUtil.localeFromString(Configuration.getString(StrutsConstants.STRUTS_LOCALE), request.getLocale()); + if (Settings.isSet(StrutsConstants.STRUTS_LOCALE)) { + locale = LocalizedTextUtil.localeFromString(Settings.get(StrutsConstants.STRUTS_LOCALE), request.getLocale()); } if (encoding != null) { diff --git a/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java b/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java index 70fda17f7..df1035697 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java @@ -44,7 +44,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.struts2.RequestUtils; import org.apache.struts2.StrutsConstants; import org.apache.struts2.StrutsStatics; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.dispatcher.mapper.ActionMapper; import org.apache.struts2.dispatcher.mapper.ActionMapperFactory; import org.apache.struts2.dispatcher.mapper.ActionMapping; @@ -222,7 +222,7 @@ public class FilterDispatcher implements Filter, StrutsStatics { resourcePath = request.getPathInfo(); } - if ("true".equals(Configuration.get(StrutsConstants.STRUTS_SERVE_STATIC_CONTENT)) + if ("true".equals(Settings.get(StrutsConstants.STRUTS_SERVE_STATIC_CONTENT)) && resourcePath.startsWith("/struts")) { String name = resourcePath.substring("/struts".length()); findStaticResource(name, response); @@ -272,7 +272,7 @@ public class FilterDispatcher implements Filter, StrutsStatics { response.setContentType(contentType); } - if ("true".equals(Configuration.get(StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE))) { + if ("true".equals(Settings.get(StrutsConstants.STRUTS_SERVE_STATIC_BROWSER_CACHE))) { // set heading information for caching static content Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); response.setHeader("Date",df.format(cal.getTime())+" GMT"); @@ -360,7 +360,7 @@ public class FilterDispatcher implements Filter, StrutsStatics { resourcePath = packagePrefix + name; } - String enc = (String) Configuration.get(StrutsConstants.STRUTS_I18N_ENCODING); + String enc = (String) Settings.get(StrutsConstants.STRUTS_I18N_ENCODING); resourcePath = URLDecoder.decode(resourcePath, enc); return ClassLoaderUtil.getResourceAsStream(resourcePath, getClass()); diff --git a/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java b/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java index acb0d6506..58a9e43f0 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/VelocityResult.java @@ -19,7 +19,7 @@ package org.apache.struts2.dispatcher; import org.apache.struts2.ServletActionContext; import org.apache.struts2.StrutsConstants; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.views.JspSupportServlet; import org.apache.struts2.views.velocity.VelocityManager; import com.opensymphony.xwork2.ActionContext; @@ -167,7 +167,7 @@ public class VelocityResult extends StrutsResultSupport { * @return The encoding associated with this template (defaults to the value of 'struts.i18n.encoding' property) */ protected String getEncoding(String templateLocation) { - String encoding = (String) Configuration.get(StrutsConstants.STRUTS_I18N_ENCODING); + String encoding = (String) Settings.get(StrutsConstants.STRUTS_I18N_ENCODING); if (encoding == null) { encoding = System.getProperty("file.encoding"); } diff --git a/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapperFactory.java b/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapperFactory.java index dc039b4fb..f7fa868e2 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapperFactory.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/mapper/ActionMapperFactory.java @@ -17,7 +17,7 @@ */ package org.apache.struts2.dispatcher.mapper; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.StrutsConstants; import org.apache.struts2.StrutsException; @@ -48,7 +48,7 @@ public class ActionMapperFactory { */ public static ActionMapper getMapper() { synchronized (classMap) { - String clazz = (String) Configuration.get(StrutsConstants.STRUTS_MAPPER_CLASS); + String clazz = (String) Settings.get(StrutsConstants.STRUTS_MAPPER_CLASS); try { ActionMapper mapper = (ActionMapper) classMap.get(clazz); if (mapper == null) { diff --git a/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java b/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java index c506d7d71..8ecc8eb2d 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapper.java @@ -151,8 +151,8 @@ public class DefaultActionMapper implements ActionMapper { private PrefixTrie prefixTrie = null; private boolean compatibilityMode = false; public DefaultActionMapper() { - if (org.apache.struts2.config.Configuration.isSet(StrutsConstants.STRUTS_COMPATIBILITY_MODE)) { - compatibilityMode = "true".equals(org.apache.struts2.config.Configuration.get(StrutsConstants.STRUTS_COMPATIBILITY_MODE)); + if (org.apache.struts2.config.Settings.isSet(StrutsConstants.STRUTS_COMPATIBILITY_MODE)) { + compatibilityMode = "true".equals(org.apache.struts2.config.Settings.get(StrutsConstants.STRUTS_COMPATIBILITY_MODE)); } prefixTrie = new PrefixTrie() { { @@ -323,7 +323,7 @@ public class DefaultActionMapper implements ActionMapper { * Returns null if no extension is specified. */ static List getExtensions() { - String extensions = (String) org.apache.struts2.config.Configuration.get(StrutsConstants.STRUTS_ACTION_EXTENSION); + String extensions = (String) org.apache.struts2.config.Settings.get(StrutsConstants.STRUTS_ACTION_EXTENSION); if ("".equals(extensions)) { return null; diff --git a/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java b/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java index 0997f18e3..502c153a8 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/multipart/MultiPartRequestWrapper.java @@ -17,7 +17,7 @@ */ package org.apache.struts2.dispatcher.multipart; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.dispatcher.StrutsRequestWrapper; import org.apache.struts2.StrutsConstants; import org.apache.struts2.util.ClassLoaderUtils; @@ -68,7 +68,7 @@ public class MultiPartRequestWrapper extends StrutsRequestWrapper { if (request instanceof MultiPartRequest) { multi = (MultiPartRequest) request; } else { - String parser = Configuration.getString(StrutsConstants.STRUTS_MULTIPART_PARSER); + String parser = Settings.get(StrutsConstants.STRUTS_MULTIPART_PARSER); // If it's not set, use Jakarta if (parser.equals("")) { diff --git a/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java b/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java index 6c6afe0c0..12f770f43 100644 --- a/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java +++ b/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java @@ -38,7 +38,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts2.StrutsConstants; import org.apache.struts2.StrutsStatics; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.dispatcher.ApplicationMap; import org.apache.struts2.dispatcher.Dispatcher; import org.apache.struts2.dispatcher.RequestMap; @@ -204,13 +204,13 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics, .addDefaultResourceBundle("org/apache/struts2/struts-messages"); //check for configuration reloading - if ("true".equalsIgnoreCase(Configuration - .getString(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD))) { + if ("true".equalsIgnoreCase(Settings + .get(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD))) { FileManager.setReloadingConfigs(true); } - if (Configuration.isSet(StrutsConstants.STRUTS_OBJECTFACTORY)) { - String className = (String) Configuration + if (Settings.isSet(StrutsConstants.STRUTS_OBJECTFACTORY)) { + String className = (String) Settings .get(StrutsConstants.STRUTS_OBJECTFACTORY); if (className.equals("spring")) { // note: this class name needs to be in string form so we don't put hard @@ -358,8 +358,8 @@ public class Jsr168Dispatcher extends GenericPortlet implements StrutsStatics, extraContext.put(ActionContext.APPLICATION, applicationMap); Locale locale = null; - if (Configuration.isSet(StrutsConstants.STRUTS_LOCALE)) { - locale = LocalizedTextUtil.localeFromString(Configuration.getString(StrutsConstants.STRUTS_LOCALE), request.getLocale()); + if (Settings.isSet(StrutsConstants.STRUTS_LOCALE)) { + locale = LocalizedTextUtil.localeFromString(Settings.get(StrutsConstants.STRUTS_LOCALE), request.getLocale()); } else { locale = request.getLocale(); } diff --git a/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java b/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java index 52e2f06bb..43fc4190f 100644 --- a/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java +++ b/core/src/main/java/org/apache/struts2/portlet/result/PortletVelocityResult.java @@ -19,7 +19,7 @@ package org.apache.struts2.portlet.result; import org.apache.struts2.ServletActionContext; import org.apache.struts2.StrutsConstants; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.dispatcher.StrutsResultSupport; import org.apache.struts2.portlet.PortletActionConstants; import org.apache.struts2.portlet.context.PortletActionContext; @@ -221,7 +221,7 @@ public class PortletVelocityResult extends StrutsResultSupport { * of 'struts.i18n.encoding' property) */ protected String getEncoding(String templateLocation) { - String encoding = (String) Configuration + String encoding = (String) Settings .get(StrutsConstants.STRUTS_I18N_ENCODING); if (encoding == null) { encoding = System.getProperty("file.encoding"); diff --git a/core/src/main/java/org/apache/struts2/sitegraph/entities/FileBasedView.java b/core/src/main/java/org/apache/struts2/sitegraph/entities/FileBasedView.java index 639bf5178..4894fd5d5 100644 --- a/core/src/main/java/org/apache/struts2/sitegraph/entities/FileBasedView.java +++ b/core/src/main/java/org/apache/struts2/sitegraph/entities/FileBasedView.java @@ -18,7 +18,7 @@ package org.apache.struts2.sitegraph.entities; import com.opensymphony.util.FileUtils; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.sitegraph.model.Link; import org.apache.struts2.StrutsConstants; @@ -60,7 +60,7 @@ public abstract class FileBasedView implements View { } protected Pattern getLinkPattern() { - Object ext = Configuration.get(StrutsConstants.STRUTS_ACTION_EXTENSION); + Object ext = Settings.get(StrutsConstants.STRUTS_ACTION_EXTENSION); String actionRegex = "([A-Za-z0-9\\._\\-\\!]+\\." + ext + ")"; return Pattern.compile(actionRegex); } diff --git a/core/src/main/java/org/apache/struts2/sitegraph/renderers/DOTRenderer.java b/core/src/main/java/org/apache/struts2/sitegraph/renderers/DOTRenderer.java index 27d48a7cd..9ead67c2e 100644 --- a/core/src/main/java/org/apache/struts2/sitegraph/renderers/DOTRenderer.java +++ b/core/src/main/java/org/apache/struts2/sitegraph/renderers/DOTRenderer.java @@ -17,7 +17,7 @@ */ package org.apache.struts2.sitegraph.renderers; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.sitegraph.StrutsConfigRetriever; import org.apache.struts2.sitegraph.entities.Target; import org.apache.struts2.sitegraph.entities.View; @@ -90,7 +90,7 @@ public class DOTRenderer { } String location = getViewLocation((String) resultConfig.getParams().get("location"), namespace); - if (location.endsWith((String) Configuration.get(StrutsConstants.STRUTS_ACTION_EXTENSION))) { + if (location.endsWith((String) Settings.get(StrutsConstants.STRUTS_ACTION_EXTENSION))) { addTempLink(action, location, Link.TYPE_RESULT, resultConfig.getName()); } else { ViewNode view = new ViewNode(stripLocation(location)); @@ -110,7 +110,7 @@ public class DOTRenderer { } else if (resultClassName.indexOf("Redirect") != -1) { // check if the redirect is to an action -- if so, link it String location = getViewLocation((String) resultConfig.getParams().get("location"), namespace); - if (location.endsWith((String) Configuration.get(StrutsConstants.STRUTS_ACTION_EXTENSION))) { + if (location.endsWith((String) Settings.get(StrutsConstants.STRUTS_ACTION_EXTENSION))) { addTempLink(action, location, Link.TYPE_REDIRECT, resultConfig.getName()); } else { ViewNode view = new ViewNode(stripLocation(location)); @@ -145,8 +145,8 @@ public class DOTRenderer { for (Iterator iterator = links.iterator(); iterator.hasNext();) { TempLink temp = (TempLink) iterator.next(); String location = temp.location; - if (location.endsWith((String) Configuration.get(StrutsConstants.STRUTS_ACTION_EXTENSION))) { - location = location.substring(0, location.indexOf((String) Configuration.get(StrutsConstants.STRUTS_ACTION_EXTENSION)) - 1); + if (location.endsWith((String) Settings.get(StrutsConstants.STRUTS_ACTION_EXTENSION))) { + location = location.substring(0, location.indexOf((String) Settings.get(StrutsConstants.STRUTS_ACTION_EXTENSION)) - 1); if (location.indexOf('!') != -1) { temp.label = temp.label + "\\n(" + location.substring(location.indexOf('!')) + ")"; diff --git a/core/src/main/java/org/apache/struts2/sitemesh/TemplatePageFilter.java b/core/src/main/java/org/apache/struts2/sitemesh/TemplatePageFilter.java index 74c233263..81256bcd2 100644 --- a/core/src/main/java/org/apache/struts2/sitemesh/TemplatePageFilter.java +++ b/core/src/main/java/org/apache/struts2/sitemesh/TemplatePageFilter.java @@ -23,7 +23,7 @@ import com.opensymphony.module.sitemesh.filter.PageFilter; import org.apache.struts2.ServletActionContext; import org.apache.struts2.dispatcher.Dispatcher; import org.apache.struts2.StrutsConstants; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import com.opensymphony.xwork2.*; import com.opensymphony.xwork2.interceptor.PreResultListener; @@ -102,7 +102,7 @@ public abstract class TemplatePageFilter extends PageFilter { * Gets the L18N encoding of the system. The default is UTF-8. */ protected String getEncoding() { - String encoding = (String) Configuration.get(StrutsConstants.STRUTS_I18N_ENCODING); + String encoding = (String) Settings.get(StrutsConstants.STRUTS_I18N_ENCODING); if (encoding == null) { encoding = System.getProperty("file.encoding"); } diff --git a/core/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java b/core/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java index 84af25241..6c8b13fe8 100644 --- a/core/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java +++ b/core/src/main/java/org/apache/struts2/spring/StrutsSpringObjectFactory.java @@ -17,7 +17,7 @@ */ package org.apache.struts2.spring; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.util.ObjectFactoryInitializable; import org.apache.struts2.StrutsConstants; import com.opensymphony.xwork2.spring.SpringObjectFactory; @@ -63,7 +63,7 @@ public class StrutsSpringObjectFactory extends SpringObjectFactory implements Ob this.setApplicationContext(appContext); - String autoWire = Configuration.getString(StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE); + String autoWire = Settings.get(StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE); int type = AutowireCapableBeanFactory.AUTOWIRE_BY_NAME; // default if ("name".equals(autoWire)) { type = AutowireCapableBeanFactory.AUTOWIRE_BY_NAME; @@ -76,7 +76,7 @@ public class StrutsSpringObjectFactory extends SpringObjectFactory implements Ob } this.setAutowireStrategy(type); - boolean useClassCache = "true".equals(Configuration.getString(StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_USE_CLASS_CACHE)); + boolean useClassCache = "true".equals(Settings.get(StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_USE_CLASS_CACHE)); this.setUseClassCache(useClassCache); log.info("... initialized Struts-Spring integration successfully"); diff --git a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java index c0c7dc63c..1e252e374 100644 --- a/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java +++ b/core/src/main/java/org/apache/struts2/views/freemarker/FreemarkerManager.java @@ -18,7 +18,7 @@ package org.apache.struts2.views.freemarker; import com.opensymphony.util.FileManager; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.views.JspSupportServlet; import org.apache.struts2.views.freemarker.tags.StrutsModels; import org.apache.struts2.views.util.ContextUtil; @@ -120,8 +120,8 @@ public class FreemarkerManager { if (instance == null) { String classname = FreemarkerManager.class.getName(); - if (Configuration.isSet(StrutsConstants.STRUTS_FREEMARKER_MANAGER_CLASSNAME)) { - classname = Configuration.getString(StrutsConstants.STRUTS_FREEMARKER_MANAGER_CLASSNAME).trim(); + if (Settings.isSet(StrutsConstants.STRUTS_FREEMARKER_MANAGER_CLASSNAME)) { + classname = Settings.get(StrutsConstants.STRUTS_FREEMARKER_MANAGER_CLASSNAME).trim(); } try { @@ -299,8 +299,8 @@ public class FreemarkerManager { configuration.setObjectWrapper(getObjectWrapper()); - if (Configuration.isSet(StrutsConstants.STRUTS_I18N_ENCODING)) { - configuration.setDefaultEncoding(Configuration.getString(StrutsConstants.STRUTS_I18N_ENCODING)); + if (Settings.isSet(StrutsConstants.STRUTS_I18N_ENCODING)) { + configuration.setDefaultEncoding(Settings.get(StrutsConstants.STRUTS_I18N_ENCODING)); } loadSettings(servletContext, configuration); diff --git a/core/src/main/java/org/apache/struts2/views/freemarker/StrutsBeanWrapper.java b/core/src/main/java/org/apache/struts2/views/freemarker/StrutsBeanWrapper.java index d0ff942cf..0e6ca0dd0 100644 --- a/core/src/main/java/org/apache/struts2/views/freemarker/StrutsBeanWrapper.java +++ b/core/src/main/java/org/apache/struts2/views/freemarker/StrutsBeanWrapper.java @@ -43,7 +43,7 @@ import java.util.Set; */ public class StrutsBeanWrapper extends BeansWrapper { private static final boolean altMapWrapper - = "true".equals(org.apache.struts2.config.Configuration.get("struts.freemarker.wrapper.altMap")); + = "true".equals(org.apache.struts2.config.Settings.get("struts.freemarker.wrapper.altMap")); public TemplateModel wrap(Object object) throws TemplateModelException { if (object instanceof TemplateBooleanModel) { diff --git a/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java b/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java index 83e5a9fc7..1d4020924 100644 --- a/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java +++ b/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java @@ -21,7 +21,7 @@ import com.opensymphony.xwork2.util.OgnlValueStack; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.ActionContext; import org.apache.struts2.views.jsp.ui.OgnlTool; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.util.StrutsUtil; import org.apache.struts2.StrutsConstants; @@ -74,7 +74,7 @@ public class ContextUtil { // We didn't make altSyntax static cause, if so, struts.configuration.xml.reload will not work // plus the Configuration implementation should cache the properties, which WW's // configuration implementation does - boolean altSyntax = "true".equals(Configuration.getString(StrutsConstants.STRUTS_TAG_ALTSYNTAX)); + boolean altSyntax = "true".equals(Settings.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX)); return altSyntax ||( (context.containsKey("useAltSyntax") && context.get("useAltSyntax") != null && diff --git a/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java b/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java index ea6af1b77..f31087559 100644 --- a/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java +++ b/core/src/main/java/org/apache/struts2/views/util/UrlHelper.java @@ -19,7 +19,7 @@ package org.apache.struts2.views.util; import org.apache.struts2.ServletActionContext; import org.apache.struts2.StrutsConstants; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.util.OgnlValueStack; import com.opensymphony.xwork2.util.TextParseUtil; @@ -73,14 +73,14 @@ public class UrlHelper { int httpPort = DEFAULT_HTTP_PORT; try { - httpPort = Integer.parseInt((String) Configuration.get(StrutsConstants.STRUTS_URL_HTTP_PORT)); + httpPort = Integer.parseInt((String) Settings.get(StrutsConstants.STRUTS_URL_HTTP_PORT)); } catch (Exception ex) { } int httpsPort = DEFAULT_HTTPS_PORT; try { - httpsPort = Integer.parseInt((String) Configuration.get(StrutsConstants.STRUTS_URL_HTTPS_PORT)); + httpsPort = Integer.parseInt((String) Settings.get(StrutsConstants.STRUTS_URL_HTTPS_PORT)); } catch (Exception ex) { } @@ -250,8 +250,8 @@ public class UrlHelper { private static String getEncodingFromConfiguration() { final String encoding; - if (Configuration.isSet(StrutsConstants.STRUTS_I18N_ENCODING)) { - encoding = Configuration.getString(StrutsConstants.STRUTS_I18N_ENCODING); + if (Settings.isSet(StrutsConstants.STRUTS_I18N_ENCODING)) { + encoding = Settings.get(StrutsConstants.STRUTS_I18N_ENCODING); } else { encoding = "UTF-8"; } diff --git a/core/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityServlet.java b/core/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityServlet.java index 938a1fed9..3e41d8d31 100644 --- a/core/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityServlet.java +++ b/core/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityServlet.java @@ -20,7 +20,7 @@ package org.apache.struts2.views.velocity; import org.apache.struts2.RequestUtils; import org.apache.struts2.ServletActionContext; import org.apache.struts2.StrutsConstants; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.views.util.ContextUtil; import com.opensymphony.xwork2.ActionContext; import org.apache.velocity.Template; @@ -124,7 +124,7 @@ public class StrutsVelocityServlet extends VelocityServlet { private String getEncoding() { // todo look into converting this to using XWork/Struts encoding rules try { - return Configuration.getString(StrutsConstants.STRUTS_I18N_ENCODING); + return Settings.get(StrutsConstants.STRUTS_I18N_ENCODING); } catch (IllegalArgumentException e) { return RuntimeSingleton.getString(RuntimeSingleton.OUTPUT_ENCODING, DEFAULT_OUTPUT_ENCODING); } diff --git a/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java b/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java index d40e8710e..b79ba8c2e 100644 --- a/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java +++ b/core/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java @@ -20,7 +20,7 @@ package org.apache.struts2.views.velocity; import org.apache.struts2.ServletActionContext; import org.apache.struts2.StrutsConstants; import org.apache.struts2.StrutsException; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.util.VelocityStrutsUtil; import org.apache.struts2.views.jsp.ui.OgnlTool; import org.apache.struts2.views.util.ContextUtil; @@ -94,8 +94,8 @@ public class VelocityManager { if (instance == null) { String classname = VelocityManager.class.getName(); - if (Configuration.isSet(StrutsConstants.STRUTS_VELOCITY_MANAGER_CLASSNAME)) { - classname = Configuration.getString(StrutsConstants.STRUTS_VELOCITY_MANAGER_CLASSNAME).trim(); + if (Settings.isSet(StrutsConstants.STRUTS_VELOCITY_MANAGER_CLASSNAME)) { + classname = Settings.get(StrutsConstants.STRUTS_VELOCITY_MANAGER_CLASSNAME).trim(); } if (!classname.equals(VelocityManager.class.getName())) { @@ -249,8 +249,8 @@ public class VelocityManager { */ String configfile; - if (Configuration.isSet(StrutsConstants.STRUTS_VELOCITY_CONFIGFILE)) { - configfile = Configuration.getString(StrutsConstants.STRUTS_VELOCITY_CONFIGFILE); + if (Settings.isSet(StrutsConstants.STRUTS_VELOCITY_CONFIGFILE)) { + configfile = Settings.get(StrutsConstants.STRUTS_VELOCITY_CONFIGFILE); } else { configfile = "velocity.properties"; } @@ -356,8 +356,8 @@ public class VelocityManager { initChainedContexts(); - if (Configuration.isSet(StrutsConstants.STRUTS_VELOCITY_TOOLBOXLOCATION)) { - toolBoxLocation = Configuration.get(StrutsConstants.STRUTS_VELOCITY_TOOLBOXLOCATION).toString(); + if (Settings.isSet(StrutsConstants.STRUTS_VELOCITY_TOOLBOXLOCATION)) { + toolBoxLocation = Settings.get(StrutsConstants.STRUTS_VELOCITY_TOOLBOXLOCATION).toString(); } } @@ -385,9 +385,9 @@ public class VelocityManager { */ protected void initChainedContexts() { - if (Configuration.isSet(StrutsConstants.STRUTS_VELOCITY_CONTEXTS)) { + if (Settings.isSet(StrutsConstants.STRUTS_VELOCITY_CONTEXTS)) { // we expect contexts to be a comma separated list of classnames - String contexts = Configuration.get(StrutsConstants.STRUTS_VELOCITY_CONTEXTS).toString(); + String contexts = Settings.get(StrutsConstants.STRUTS_VELOCITY_CONTEXTS).toString(); StringTokenizer st = new StringTokenizer(contexts, ","); List contextList = new ArrayList(); diff --git a/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java b/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java index 0055af86a..134c8e6b7 100644 --- a/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java +++ b/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java @@ -18,7 +18,7 @@ package org.apache.struts2.views.xslt; import org.apache.struts2.ServletActionContext; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.Result; @@ -190,7 +190,7 @@ public class XSLTResult implements Result { public XSLTResult() { templatesCache = new HashMap(); - noCache = Configuration.getString("struts.xslt.nocache").trim().equalsIgnoreCase("true"); + noCache = Settings.get("struts.xslt.nocache").trim().equalsIgnoreCase("true"); } /** diff --git a/core/src/test/java/org/apache/struts2/config/ConfigurationTest.java b/core/src/test/java/org/apache/struts2/config/SettingsTest.java similarity index 66% rename from core/src/test/java/org/apache/struts2/config/ConfigurationTest.java rename to core/src/test/java/org/apache/struts2/config/SettingsTest.java index 1155d4794..6860dfaf4 100644 --- a/core/src/test/java/org/apache/struts2/config/ConfigurationTest.java +++ b/core/src/test/java/org/apache/struts2/config/SettingsTest.java @@ -26,20 +26,20 @@ import java.util.Locale; /** - * Unit test for {@link ConfigurationTest}. + * Unit test for {@link SettingsTest}. * */ -public class ConfigurationTest extends StrutsTestCase { +public class SettingsTest extends StrutsTestCase { - public void testConfiguration() { - assertEquals("12345", Configuration.getString(StrutsConstants.STRUTS_MULTIPART_MAXSIZE)); - assertEquals("\temp", Configuration.getString(StrutsConstants.STRUTS_MULTIPART_SAVEDIR)); + public void testSettings() { + assertEquals("12345", Settings.get(StrutsConstants.STRUTS_MULTIPART_MAXSIZE)); + assertEquals("\temp", Settings.get(StrutsConstants.STRUTS_MULTIPART_SAVEDIR)); - assertEquals("test,org/apache/struts2/othertest", Configuration.getString( StrutsConstants.STRUTS_CUSTOM_PROPERTIES)); - assertEquals("testvalue", Configuration.getString("testkey")); - assertEquals("othertestvalue", Configuration.getString("othertestkey")); + assertEquals("test,org/apache/struts2/othertest", Settings.get( StrutsConstants.STRUTS_CUSTOM_PROPERTIES)); + assertEquals("testvalue", Settings.get("testkey")); + assertEquals("othertestvalue", Settings.get("othertestkey")); - Locale locale = Configuration.getLocale(); + Locale locale = Settings.getLocale(); assertEquals("de", locale.getLanguage()); int count = getKeyCount(); @@ -47,7 +47,7 @@ public class ConfigurationTest extends StrutsTestCase { } public void testDefaultResourceBundlesLoaded() { - assertEquals("testmessages,testmessages2", Configuration.getString(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES)); + assertEquals("testmessages,testmessages2", Settings.get(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES)); assertEquals("This is a test message", LocalizedTextUtil.findDefaultText("default.testmessage", Locale.getDefault())); assertEquals("This is another test message", LocalizedTextUtil.findDefaultText("default.testmessage2", Locale.getDefault())); } @@ -58,23 +58,23 @@ public class ConfigurationTest extends StrutsTestCase { LocalizedTextUtil.clearDefaultResourceBundles(); LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/struts-messages"); assertEquals("The form has already been processed or no token was supplied, please try again.", LocalizedTextUtil.findDefaultText("struts.messages.invalid.token", Locale.getDefault())); - Configuration.reset(); + Settings.reset(); - assertEquals("testmessages,testmessages2", Configuration.getString(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES)); + assertEquals("testmessages,testmessages2", Settings.get(StrutsConstants.STRUTS_CUSTOM_I18N_RESOURCES)); assertEquals("Replaced message for token tag", LocalizedTextUtil.findDefaultText("struts.messages.invalid.token", Locale.getDefault())); } - public void testSetConfiguration() { - Configuration.setConfiguration(new TestConfiguration()); + public void testSetSettings() { + Settings.setInstance(new TestSettings()); String keyName = "a.long.property.key.name"; - assertEquals(keyName, Configuration.getString(keyName)); + assertEquals(keyName, Settings.get(keyName)); assertEquals(2, getKeyCount()); } private int getKeyCount() { int count = 0; - Iterator keyNames = Configuration.list(); + Iterator keyNames = Settings.list(); while (keyNames.hasNext()) { keyNames.next(); diff --git a/core/src/test/java/org/apache/struts2/config/TestConfiguration.java b/core/src/test/java/org/apache/struts2/config/TestSettings.java similarity index 81% rename from core/src/test/java/org/apache/struts2/config/TestConfiguration.java rename to core/src/test/java/org/apache/struts2/config/TestSettings.java index 89f98de3c..fc971774e 100644 --- a/core/src/test/java/org/apache/struts2/config/TestConfiguration.java +++ b/core/src/test/java/org/apache/struts2/config/TestSettings.java @@ -23,17 +23,17 @@ import java.util.List; /** - * TestConfiguration + * TestSettings * */ -public class TestConfiguration extends Configuration { +public class TestSettings extends Settings { /** * Get a named setting. * - * @throws IllegalArgumentException if there is no configuration parameter with the given name. + * @throws IllegalArgumentException if there is no settings parameter with the given name. */ - public Object getImpl(String aName) throws IllegalArgumentException { + public String getImpl(String aName) throws IllegalArgumentException { return aName; } diff --git a/core/src/test/java/org/apache/struts2/dispatcher/FilterDispatcherTest.java b/core/src/test/java/org/apache/struts2/dispatcher/FilterDispatcherTest.java index aa4a4dc9f..c7c4e9d72 100644 --- a/core/src/test/java/org/apache/struts2/dispatcher/FilterDispatcherTest.java +++ b/core/src/test/java/org/apache/struts2/dispatcher/FilterDispatcherTest.java @@ -20,7 +20,7 @@ package org.apache.struts2.dispatcher; import com.opensymphony.xwork2.ObjectFactory; import org.apache.struts2.StrutsConstants; import org.apache.struts2.StrutsTestCase; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.util.ObjectFactoryDestroyable; import org.apache.struts2.util.ObjectFactoryInitializable; import org.apache.struts2.util.ObjectFactoryLifecycle; @@ -81,7 +81,7 @@ public class FilterDispatcherTest extends StrutsTestCase { Map configMap = new HashMap(); configMap.put(StrutsConstants.STRUTS_OBJECTFACTORY, "org.apache.struts2.dispatcher.FilterDispatcherTest$InnerInitializableObjectFactory"); configMap.put(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "false"); - Configuration.setConfiguration(new InnerConfiguration(configMap)); + Settings.setInstance(new InnerConfiguration(configMap)); MockServletContext servletContext = new MockServletContext(); MockFilterConfig filterConfig = new MockFilterConfig(servletContext); @@ -99,7 +99,7 @@ public class FilterDispatcherTest extends StrutsTestCase { Map configMap = new HashMap(); configMap.put(StrutsConstants.STRUTS_OBJECTFACTORY, "org.apache.struts2.dispatcher.FilterDispatcherTest$InnerInitailizableDestroyableObjectFactory"); configMap.put(StrutsConstants.STRUTS_CONFIGURATION_XML_RELOAD, "false"); - Configuration.setConfiguration(new InnerConfiguration(configMap)); + Settings.setInstance(new InnerConfiguration(configMap)); MockServletContext servletContext = new MockServletContext(); MockFilterConfig filterConfig = new MockFilterConfig(servletContext); @@ -118,8 +118,8 @@ public class FilterDispatcherTest extends StrutsTestCase { // === inner class ======== - public static class InnerConfiguration extends Configuration { - Map m; + public static class InnerConfiguration extends Settings { + Map m; public InnerConfiguration(Map configMap) { m = configMap; @@ -132,7 +132,7 @@ public class FilterDispatcherTest extends StrutsTestCase { return true; } - public Object getImpl(String aName) throws IllegalArgumentException { + public String getImpl(String aName) throws IllegalArgumentException { if (!m.containsKey(aName)) return super.getImpl(aName); else diff --git a/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java b/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java index c34cf9d6e..31901df66 100644 --- a/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java +++ b/core/src/test/java/org/apache/struts2/dispatcher/mapper/DefaultActionMapperTest.java @@ -138,8 +138,8 @@ public class DefaultActionMapperTest extends StrutsTestCase { } public void testGetMappingWithNoExtension() throws Exception { - Object old = org.apache.struts2.config.Configuration.get(StrutsConstants.STRUTS_ACTION_EXTENSION); - org.apache.struts2.config.Configuration.set(StrutsConstants.STRUTS_ACTION_EXTENSION, ""); + String old = org.apache.struts2.config.Settings.get(StrutsConstants.STRUTS_ACTION_EXTENSION); + org.apache.struts2.config.Settings.set(StrutsConstants.STRUTS_ACTION_EXTENSION, ""); try { req.setupGetParameterMap(new HashMap()); req.setupGetRequestURI("/my/namespace/actionName"); @@ -155,7 +155,7 @@ public class DefaultActionMapperTest extends StrutsTestCase { assertNull(mapping.getMethod()); } finally { - org.apache.struts2.config.Configuration.set(StrutsConstants.STRUTS_ACTION_EXTENSION, old); + org.apache.struts2.config.Settings.set(StrutsConstants.STRUTS_ACTION_EXTENSION, old); } } @@ -378,8 +378,8 @@ public class DefaultActionMapperTest extends StrutsTestCase { } public void testGetUriFromActionMapper12() throws Exception { - Object old = org.apache.struts2.config.Configuration.get(StrutsConstants.STRUTS_COMPATIBILITY_MODE); - org.apache.struts2.config.Configuration.set(StrutsConstants.STRUTS_COMPATIBILITY_MODE, "true"); + String old = org.apache.struts2.config.Settings.get(StrutsConstants.STRUTS_COMPATIBILITY_MODE); + org.apache.struts2.config.Settings.set(StrutsConstants.STRUTS_COMPATIBILITY_MODE, "true"); try { DefaultActionMapper mapper = new DefaultActionMapper(); ActionMapping actionMapping = new ActionMapping(); @@ -390,7 +390,7 @@ public class DefaultActionMapperTest extends StrutsTestCase { assertEquals("/myActionName.action", uri); } finally { - org.apache.struts2.config.Configuration.set(StrutsConstants.STRUTS_COMPATIBILITY_MODE, old); + org.apache.struts2.config.Settings.set(StrutsConstants.STRUTS_COMPATIBILITY_MODE, old); } } diff --git a/core/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java b/core/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java index 3bd2fb74e..1e0c1ac7e 100644 --- a/core/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java +++ b/core/src/test/java/org/apache/struts2/spring/StrutsSpringObjectFactoryTest.java @@ -19,7 +19,7 @@ package org.apache.struts2.spring; import org.apache.struts2.StrutsConstants; import org.apache.struts2.StrutsTestCase; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import junit.framework.TestCase; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.mock.web.MockServletContext; @@ -48,7 +48,7 @@ public class StrutsSpringObjectFactoryTest extends StrutsTestCase { StrutsSpringObjectFactory fac = new StrutsSpringObjectFactory(); // autowire by constructure, we try a non default setting in this unit test - Configuration.set(StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE, "constructor"); + Settings.set(StrutsConstants.STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE, "constructor"); ConfigurableWebApplicationContext ac = new XmlWebApplicationContext(); ServletContext msc = (ServletContext) new MockServletContext(); diff --git a/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java b/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java index 45da69255..4fa406e0c 100644 --- a/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java +++ b/core/src/test/java/org/apache/struts2/views/TemplateEngineManagerTest.java @@ -18,7 +18,7 @@ package org.apache.struts2.views; import org.apache.struts2.components.template.*; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import junit.framework.TestCase; /** @@ -27,12 +27,12 @@ import junit.framework.TestCase; */ public class TemplateEngineManagerTest extends TestCase { public void testTemplateTypeFromTemplateNameAndDefaults() { - Configuration.setConfiguration(new Configuration() { + Settings.setInstance(new Settings() { public boolean isSetImpl(String name) { return name.equals(TemplateEngineManager.DEFAULT_TEMPLATE_TYPE_CONFIG_KEY); } - public Object getImpl(String aName) throws IllegalArgumentException { + public String getImpl(String aName) throws IllegalArgumentException { if (aName.equals(TemplateEngineManager.DEFAULT_TEMPLATE_TYPE_CONFIG_KEY)) { return "jsp"; } @@ -63,6 +63,6 @@ public class TemplateEngineManagerTest extends TestCase { protected void tearDown() throws Exception { super.tearDown(); - Configuration.setConfiguration(null); + Settings.setInstance(null); } } diff --git a/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java b/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java index 379c9977a..b9ed84e19 100644 --- a/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java +++ b/core/src/test/java/org/apache/struts2/views/freemarker/FreemarkerManagerTest.java @@ -19,7 +19,7 @@ package org.apache.struts2.views.freemarker; import org.apache.struts2.StrutsConstants; import org.apache.struts2.StrutsTestCase; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.views.jsp.StrutsMockServletContext; /** @@ -29,7 +29,7 @@ import org.apache.struts2.views.jsp.StrutsMockServletContext; public class FreemarkerManagerTest extends StrutsTestCase { public void testIfStrutsEncodingIsSetProperty() throws Exception { - Configuration.set(StrutsConstants.STRUTS_I18N_ENCODING, "UTF-8"); + Settings.set(StrutsConstants.STRUTS_I18N_ENCODING, "UTF-8"); StrutsMockServletContext servletContext = new StrutsMockServletContext(); servletContext.setAttribute(FreemarkerManager.CONFIG_SERVLET_CONTEXT_KEY, null); freemarker.template.Configuration conf = FreemarkerManager.getInstance().getConfiguration(servletContext); diff --git a/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java index 205cb5826..e9d9dd568 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java @@ -20,7 +20,7 @@ package org.apache.struts2.views.jsp; import org.apache.struts2.ServletActionContext; import org.apache.struts2.TestAction; import org.apache.struts2.StrutsTestCase; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.dispatcher.ApplicationMap; import org.apache.struts2.dispatcher.Dispatcher; import org.apache.struts2.dispatcher.RequestMap; @@ -118,7 +118,7 @@ public abstract class AbstractTagTest extends StrutsTestCase { ActionContext.setContext(new ActionContext(context)); - Configuration.setConfiguration(null); + Settings.setInstance(null); } protected void tearDown() throws Exception { diff --git a/core/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java index da24c2c1d..4b21ccf9a 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java @@ -49,7 +49,7 @@ import org.apache.struts2.views.jsp.ParamTag; import org.apache.struts2.dispatcher.Dispatcher; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.util.OgnlValueStack; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; /** */ @@ -80,7 +80,7 @@ public class PortletUrlTagTest extends MockObjectTestCase { public void setUp() throws Exception { super.setUp(); - Configuration.reset(); + Settings.reset(); Dispatcher.setInstance(new Dispatcher(null)); mockPortletApiAvailable(); diff --git a/core/src/test/java/org/apache/struts2/views/jsp/PropertyTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/PropertyTagTest.java index 09a16ef40..b46108ca3 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/PropertyTagTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/PropertyTagTest.java @@ -22,7 +22,7 @@ import com.mockobjects.servlet.MockPageContext; import org.apache.struts2.ServletActionContext; import org.apache.struts2.StrutsTestCase; import org.apache.struts2.StrutsConstants; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.util.OgnlValueStack; @@ -160,8 +160,8 @@ public class PropertyTagTest extends StrutsTestCase { public void testWithAltSyntax1() throws Exception { // setups - Configuration.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "true"); - assertEquals(Configuration.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "true"); + Settings.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "true"); + assertEquals(Settings.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "true"); Foo foo = new Foo(); foo.setTitle("tm_jee"); @@ -189,8 +189,8 @@ public class PropertyTagTest extends StrutsTestCase { public void testWithAltSyntax2() throws Exception { // setups - Configuration.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "true"); - assertEquals(Configuration.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "true"); + Settings.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "true"); + assertEquals(Settings.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "true"); Foo foo = new Foo(); foo.setTitle("tm_jee"); @@ -218,8 +218,8 @@ public class PropertyTagTest extends StrutsTestCase { public void testWithoutAltSyntax1() throws Exception { // setups - Configuration.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "false"); - assertEquals(Configuration.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "false"); + Settings.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "false"); + assertEquals(Settings.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "false"); Foo foo = new Foo(); foo.setTitle("tm_jee"); @@ -248,8 +248,8 @@ public class PropertyTagTest extends StrutsTestCase { public void testWithoutAltSyntax2() throws Exception { // setups - Configuration.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "false"); - assertEquals(Configuration.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "false"); + Settings.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "false"); + assertEquals(Settings.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "false"); Foo foo = new Foo(); foo.setTitle("tm_jee"); diff --git a/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java b/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java index f6516020f..ea34774cd 100644 --- a/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java +++ b/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java @@ -27,7 +27,7 @@ import com.opensymphony.xwork2.validator.ValidationInterceptor; import org.apache.struts2.StrutsConstants; import org.apache.struts2.TestAction; import org.apache.struts2.TestConfigurationProvider; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.dispatcher.mapper.DefaultActionMapper; import org.apache.struts2.views.jsp.AbstractUITagTest; import org.apache.struts2.views.jsp.ActionTag; @@ -308,8 +308,8 @@ public class FormTagTest extends AbstractUITagTest { */ public void testFormTagWithDifferentActionExtension() throws Exception { request.setupGetServletPath("/testNamespace/testNamespaceAction"); - String oldConfiguration = (String) Configuration.get(StrutsConstants.STRUTS_ACTION_EXTENSION); - Configuration.set(StrutsConstants.STRUTS_ACTION_EXTENSION, "jspa"); + String oldConfiguration = (String) Settings.get(StrutsConstants.STRUTS_ACTION_EXTENSION); + Settings.set(StrutsConstants.STRUTS_ACTION_EXTENSION, "jspa"); FormTag tag = new FormTag(); tag.setPageContext(pageContext); @@ -321,12 +321,12 @@ public class FormTagTest extends AbstractUITagTest { tag.doStartTag(); tag.doEndTag(); - Configuration.set(StrutsConstants.STRUTS_ACTION_EXTENSION, oldConfiguration); + Settings.set(StrutsConstants.STRUTS_ACTION_EXTENSION, oldConfiguration); verify(FormTag.class.getResource("Formtag-5.txt")); // set it back to the default - Configuration.set(StrutsConstants.STRUTS_ACTION_EXTENSION, "action"); + Settings.set(StrutsConstants.STRUTS_ACTION_EXTENSION, "action"); } /** @@ -519,8 +519,8 @@ public class FormTagTest extends AbstractUITagTest { public void testFormWithActionAndExtension() throws Exception { request.setupGetServletPath("/BLA"); - String oldConfiguration = (String) Configuration.get(StrutsConstants.STRUTS_ACTION_EXTENSION); - Configuration.set(StrutsConstants.STRUTS_ACTION_EXTENSION, "jspa"); + String oldConfiguration = (String) Settings.get(StrutsConstants.STRUTS_ACTION_EXTENSION); + Settings.set(StrutsConstants.STRUTS_ACTION_EXTENSION, "jspa"); FormTag tag = new FormTag(); tag.setPageContext(pageContext); @@ -530,12 +530,12 @@ public class FormTagTest extends AbstractUITagTest { tag.doStartTag(); tag.doEndTag(); - Configuration.set(StrutsConstants.STRUTS_ACTION_EXTENSION, oldConfiguration); + Settings.set(StrutsConstants.STRUTS_ACTION_EXTENSION, oldConfiguration); verify(FormTag.class.getResource("Formtag-8.txt")); // set it back to the default - Configuration.set(StrutsConstants.STRUTS_ACTION_EXTENSION, "action"); + Settings.set(StrutsConstants.STRUTS_ACTION_EXTENSION, "action"); } diff --git a/core/src/test/java/org/apache/struts2/views/util/ContextUtilTest.java b/core/src/test/java/org/apache/struts2/views/util/ContextUtilTest.java index f2e42f8e0..b3060c5a3 100755 --- a/core/src/test/java/org/apache/struts2/views/util/ContextUtilTest.java +++ b/core/src/test/java/org/apache/struts2/views/util/ContextUtilTest.java @@ -17,7 +17,7 @@ */ package org.apache.struts2.views.util; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.StrutsConstants; import com.opensymphony.xwork2.util.OgnlValueStack; import junit.framework.TestCase; @@ -32,10 +32,10 @@ public class ContextUtilTest extends TestCase { OgnlValueStack stack = new OgnlValueStack(); stack.getContext().put("useAltSyntax", "true"); - Configuration.reset(); - Configuration.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "true"); + Settings.reset(); + Settings.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "true"); - assertEquals(Configuration.getString(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "true"); + assertEquals(Settings.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "true"); assertTrue(ContextUtil.isUseAltSyntax(stack.getContext())); } @@ -43,10 +43,10 @@ public class ContextUtilTest extends TestCase { OgnlValueStack stack = new OgnlValueStack(); stack.getContext().put("useAltSyntax", "false"); - Configuration.reset(); - Configuration.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "true"); + Settings.reset(); + Settings.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "true"); - assertEquals(Configuration.getString(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "true"); + assertEquals(Settings.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "true"); assertTrue(ContextUtil.isUseAltSyntax(stack.getContext())); } @@ -54,10 +54,10 @@ public class ContextUtilTest extends TestCase { OgnlValueStack stack = new OgnlValueStack(); stack.getContext().put("useAltSyntax", "true"); - Configuration.reset(); - Configuration.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "false"); + Settings.reset(); + Settings.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "false"); - assertEquals(Configuration.getString(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "false"); + assertEquals(Settings.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "false"); assertTrue(ContextUtil.isUseAltSyntax(stack.getContext())); } @@ -65,10 +65,10 @@ public class ContextUtilTest extends TestCase { OgnlValueStack stack = new OgnlValueStack(); stack.getContext().put("useAltSyntax", "false"); - Configuration.reset(); - Configuration.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "false"); + Settings.reset(); + Settings.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "false"); - assertEquals(Configuration.getString(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "false"); + assertEquals(Settings.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "false"); assertFalse(ContextUtil.isUseAltSyntax(stack.getContext())); } @@ -78,40 +78,40 @@ public class ContextUtilTest extends TestCase { OgnlValueStack stack = new OgnlValueStack(); stack.getContext().put("useAltSyntax", Boolean.TRUE); - Configuration.reset(); - Configuration.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "true"); + Settings.reset(); + Settings.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "true"); - assertEquals(Configuration.getString(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "true"); + assertEquals(Settings.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "true"); assertTrue(ContextUtil.isUseAltSyntax(stack.getContext())); } public void testAltSyntaxMethod6() throws Exception { OgnlValueStack stack = new OgnlValueStack(); stack.getContext().put("useAltSyntax", Boolean.FALSE); - Configuration.reset(); - Configuration.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "true"); + Settings.reset(); + Settings.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "true"); - assertEquals(Configuration.getString(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "true"); + assertEquals(Settings.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "true"); assertTrue(ContextUtil.isUseAltSyntax(stack.getContext())); } public void testAltSyntaxMethod7() throws Exception { OgnlValueStack stack = new OgnlValueStack(); stack.getContext().put("useAltSyntax", Boolean.TRUE); - Configuration.reset(); - Configuration.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "false"); + Settings.reset(); + Settings.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "false"); - assertEquals(Configuration.getString(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "false"); + assertEquals(Settings.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "false"); assertTrue(ContextUtil.isUseAltSyntax(stack.getContext())); } public void testAltSyntaxMethod8() throws Exception { OgnlValueStack stack = new OgnlValueStack(); stack.getContext().put("useAltSyntax", Boolean.FALSE); - Configuration.reset(); - Configuration.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "false"); + Settings.reset(); + Settings.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "false"); - assertEquals(Configuration.getString(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "false"); + assertEquals(Settings.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "false"); assertFalse(ContextUtil.isUseAltSyntax(stack.getContext())); } @@ -120,10 +120,10 @@ public class ContextUtilTest extends TestCase { OgnlValueStack stack = new OgnlValueStack(); stack.getContext().put("useAltSyntax", null); - Configuration.reset(); - Configuration.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, Boolean.TRUE); + Settings.reset(); + Settings.set(StrutsConstants.STRUTS_TAG_ALTSYNTAX, "true"); - assertEquals(Configuration.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), Boolean.TRUE); + assertEquals(Settings.get(StrutsConstants.STRUTS_TAG_ALTSYNTAX), "true"); assertTrue(ContextUtil.isUseAltSyntax(stack.getContext())); } } diff --git a/core/src/test/java/org/apache/struts2/views/util/UrlHelperTest.java b/core/src/test/java/org/apache/struts2/views/util/UrlHelperTest.java index 08d2ed1cc..261cb0ebf 100644 --- a/core/src/test/java/org/apache/struts2/views/util/UrlHelperTest.java +++ b/core/src/test/java/org/apache/struts2/views/util/UrlHelperTest.java @@ -20,7 +20,7 @@ package org.apache.struts2.views.util; import com.mockobjects.dynamic.Mock; import org.apache.struts2.StrutsTestCase; import org.apache.struts2.StrutsConstants; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -197,8 +197,8 @@ public class UrlHelperTest extends StrutsTestCase { String expectedString = "https://www.mydomain.com:7002/mywebapp/MyAction.action?foo=bar&hello=earth&hello=mars"; - Configuration.set(StrutsConstants.STRUTS_URL_HTTP_PORT, "7001"); - Configuration.set(StrutsConstants.STRUTS_URL_HTTPS_PORT, "7002"); + Settings.set(StrutsConstants.STRUTS_URL_HTTP_PORT, "7001"); + Settings.set(StrutsConstants.STRUTS_URL_HTTPS_PORT, "7002"); Mock mockHttpServletRequest = new Mock(HttpServletRequest.class); mockHttpServletRequest.expectAndReturn("getServerName", "www.mydomain.com"); @@ -226,8 +226,8 @@ public class UrlHelperTest extends StrutsTestCase { String expectedString = "http://www.mydomain.com:7001/mywebapp/MyAction.action?foo=bar&hello=earth&hello=mars"; - Configuration.set(StrutsConstants.STRUTS_URL_HTTP_PORT, "7001"); - Configuration.set(StrutsConstants.STRUTS_URL_HTTPS_PORT, "7002"); + Settings.set(StrutsConstants.STRUTS_URL_HTTP_PORT, "7001"); + Settings.set(StrutsConstants.STRUTS_URL_HTTPS_PORT, "7002"); Mock mockHttpServletRequest = new Mock(HttpServletRequest.class); mockHttpServletRequest.expectAndReturn("getServerName", "www.mydomain.com"); @@ -282,30 +282,30 @@ public class UrlHelperTest extends StrutsTestCase { } public void testTranslateAndEncode() throws Exception { - Object defaultI18nEncoding = Configuration.get(StrutsConstants.STRUTS_I18N_ENCODING); + String defaultI18nEncoding = Settings.get(StrutsConstants.STRUTS_I18N_ENCODING); try { - Configuration.set(StrutsConstants.STRUTS_I18N_ENCODING, "UTF-8"); + Settings.set(StrutsConstants.STRUTS_I18N_ENCODING, "UTF-8"); String result = UrlHelper.translateAndEncode("\u65b0\u805e"); String expectedResult = "%E6%96%B0%E8%81%9E"; assertEquals(result, expectedResult); } finally { - Configuration.set(StrutsConstants.STRUTS_I18N_ENCODING, defaultI18nEncoding); + Settings.set(StrutsConstants.STRUTS_I18N_ENCODING, defaultI18nEncoding); } } public void testTranslateAndDecode() throws Exception { - Object defaultI18nEncoding = Configuration.get(StrutsConstants.STRUTS_I18N_ENCODING); + String defaultI18nEncoding = Settings.get(StrutsConstants.STRUTS_I18N_ENCODING); try { - Configuration.set(StrutsConstants.STRUTS_I18N_ENCODING, "UTF-8"); + Settings.set(StrutsConstants.STRUTS_I18N_ENCODING, "UTF-8"); String result = UrlHelper.translateAndDecode("%E6%96%B0%E8%81%9E"); String expectedResult = "\u65b0\u805e"; assertEquals(result, expectedResult); } finally { - Configuration.set(StrutsConstants.STRUTS_I18N_ENCODING, defaultI18nEncoding); + Settings.set(StrutsConstants.STRUTS_I18N_ENCODING, defaultI18nEncoding); } } } diff --git a/extras/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java b/extras/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java index 6c8abd311..fb2ff135c 100644 --- a/extras/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java +++ b/extras/src/main/java/org/apache/struts2/dispatcher/multipart/PellMultiPartRequest.java @@ -17,7 +17,7 @@ */ package org.apache.struts2.dispatcher.multipart; -import org.apache.struts2.config.Configuration; +import org.apache.struts2.config.Settings; import org.apache.struts2.StrutsConstants; import http.utils.multipartrequest.ServletMultipartRequest; @@ -121,7 +121,7 @@ public class PellMultiPartRequest extends MultiPartRequest { String encoding = null; try { - encoding = Configuration.getString(StrutsConstants.STRUTS_I18N_ENCODING); + encoding = Settings.get(StrutsConstants.STRUTS_I18N_ENCODING); if (encoding != null) { //NB: This should never be called at the same time as the constructor for