mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
Renaming Configuration to Settings to minimize confusion with XWork's Configuration classes,
changing Settings to only deal with Strings WW-493 git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@425615 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+3
-3
@@ -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);
|
||||
}
|
||||
|
||||
+21
-21
@@ -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<Configuration> list = new ArrayList<Configuration>();
|
||||
ArrayList<Settings> list = new ArrayList<Settings>();
|
||||
|
||||
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);
|
||||
}
|
||||
+12
-12
@@ -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++) {
|
||||
+9
-9
@@ -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 <tt>new PropertiesConfiguration("foo")</tt> is called
|
||||
* the ".properties" file extension. So when <tt>new PropertiesSettings("foo")</tt> is called
|
||||
* this class will look in the classpath for the <tt>foo.properties</tt> 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);
|
||||
+37
-51
@@ -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. <p>
|
||||
* <p/>
|
||||
* Key methods: <ul>
|
||||
* <p/>
|
||||
* <li>{@link #getLocale()}</li>
|
||||
* <li>{@link #getString(String)}</li>
|
||||
* <li>{@link #set(String, Object)}</li>
|
||||
* <li>{@link #get(String)}</li>
|
||||
* <li>{@link #set(String, String)}</li>
|
||||
* <li>{@link #list()}</li></ul>
|
||||
* <p/>
|
||||
* Key methods for subclassers: <ul>
|
||||
* <p/>
|
||||
* <li>{@link #getImpl(String)}</li>
|
||||
* <li>{@link #setImpl(String, Object)}</li>
|
||||
* <li>{@link #setImpl(String, String)}</li>
|
||||
* <li>{@link #listImpl()}</li>
|
||||
* <li>{@link #isSetImpl(String)}</li></ul>
|
||||
*/
|
||||
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 <tt>true</tt> if the property exists and has a value, <tt>false</tt> otherwise.
|
||||
*/
|
||||
public static boolean isSet(String name) {
|
||||
return getConfiguration().isSetImpl(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a property as a String. This will throw an <tt>IllegalArgumentException</tt> 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;
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
-2
@@ -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("")) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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('!')) + ")";
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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<String, Templates>();
|
||||
noCache = Configuration.getString("struts.xslt.nocache").trim().equalsIgnoreCase("true");
|
||||
noCache = Settings.get("struts.xslt.nocache").trim().equalsIgnoreCase("true");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+16
-16
@@ -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();
|
||||
+4
-4
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<String,String> 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
|
||||
|
||||
+6
-6
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user