You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by mr...@apache.org on 2006/07/14 01:48:51 UTC
svn commit: r421742 [1/2] - in /struts/struts2/trunk/core/src:
main/java/org/apache/struts2/ main/java/org/apache/struts2/components/
main/java/org/apache/struts2/config/
main/java/org/apache/struts2/config_browser/
main/java/org/apache/struts2/dispatc...
Author: mrdon
Date: Thu Jul 13 16:48:46 2006
New Revision: 421742
URL: http://svn.apache.org/viewvc?rev=421742&view=rev
Log:
General cleanup - Javadoc updates, fixed spellings, removed unused methods,
renamed DispatcherUtils to Dispatcher to reflect its new role, changed
access controls on variables and methods, improved quickstart
WW-1349
Added:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java
- copied, changed from r421711, struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DispatcherUtils.java
struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherTest.java
- copied, changed from r421711, struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherUtilsTest.java
Removed:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DispatcherUtils.java
struts/struts2/trunk/core/src/test/java/org/apache/struts2/dispatcher/DispatcherUtilsTest.java
Modified:
struts/struts2/trunk/core/src/main/java/org/apache/struts2/Main.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/ServletActionContext.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsException.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsStatics.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsTestCase.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/URL.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/DefaultConfiguration.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/DelegatingConfiguration.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ServletContextSingleton.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/StrutsXMLConfigurationProvider.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/config_browser/ConfigurationHelper.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ApplicationMap.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DefaultActionSupport.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DispatcherListener.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcherCompatWeblogic61.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/HttpHeaderResult.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StrutsRequestWrapper.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/sitegraph/StrutsConfigRetriever.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/sitemesh/TemplatePageFilter.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/spring/lifecycle/SpringExternalReferenceResolverSetupListener.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/ObjectFactoryDestroyable.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/ResolverSetupServletContextListener.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/validators/DWRValidator.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/TagUtils.java
struts/struts2/trunk/core/src/test/java/org/apache/struts2/portlet/dispatcher/Jsr168DispatcherTest.java
struts/struts2/trunk/core/src/test/java/org/apache/struts2/sitegraph/SiteGraphTest.java
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/AbstractTagTest.java
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/PortletUrlTagTest.java
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/Main.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/Main.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/Main.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/Main.java Thu Jul 13 16:48:46 2006
@@ -30,9 +30,9 @@
/**
* <!-- START SNIPPET: javadoc -->
*
- * Struts comes with various related tools included in the struts-action-2.0 jar file. You can access these
- * tools by simply unpacking the Struts distribution and running <b>java -jar struts.jar</b>.
- * Struts will automatically include all jars in the same directory as the struts.jar file as well as all
+ * Struts comes with various related tools included in the struts-core-VERSION.jar file. You can access these
+ * tools by simply unpacking the Struts distribution and running <b>java -jar struts-core-VERSION.jar</b>.
+ * Struts will automatically include all jars in the same directory as the struts-core-VERSION.jar file as well as all
* jars in the <i>lib</i> directory. This means you can invoke these tools either from within the standard directory
* structure found in the Struts distribution, or from within your WEB-INF/lib directory.
*
@@ -65,7 +65,7 @@
boolean jdk15 = version.indexOf("1.5") != -1;
String javaHome = System.getProperty("java.home");
- ArrayList urls = new ArrayList();
+ ArrayList<URL> urls = new ArrayList<URL>();
try {
findJars(new File("lib"), urls);
@@ -132,7 +132,8 @@
String name = checkWebAppArgs(args);
programArgs = new String[]{"/" + name,
"apps/" + name + "/src/main/webapp",
- "apps/" + name + "/src/main/java"};
+ "apps/" + name + "/src/main/java",
+ "apps/" + name + "/src/main/resources"};
}
if ("quickstart".equals(command)) {
@@ -174,16 +175,16 @@
System.out.println(" to deploy. The webapp name must be the");
System.out.println(" name of the directory found in apps/.");
System.out.println("");
- System.out.println("Example: java -jar struts.jar quickstart:sandbox");
+ System.out.println("Example: java -jar struts-core-VERSION.jar quickstart:sandbox");
System.exit(1);
}
return name;
}
- private static void launch(String program, String[] programArgs, List urls) {
+ private static void launch(String program, String[] programArgs, List<URL> urls) {
Collections.reverse(urls);
- URL[] urlArray = (URL[]) urls.toArray(new URL[urls.size()]);
+ URL[] urlArray = urls.toArray(new URL[urls.size()]);
URLClassLoader cl = new MainClassLoader(urlArray);
Thread.currentThread().setContextClassLoader(cl);
try {
@@ -195,7 +196,7 @@
}
}
- private static void findJars(File file, ArrayList urls) throws MalformedURLException {
+ private static void findJars(File file, ArrayList<URL> urls) throws MalformedURLException {
File[] files = file.listFiles();
if (files == null) {
return;
@@ -220,14 +221,14 @@
/**
* Reverses the typical order of classloading to defer only to the parent if the current class loader can't be
* found. This is required to allow for the launcher to be embedded within struts.jar (otherwise the dependencies
- * wouldn't be found by the system ClassLoader when invoking using "java -jar struts.jar ...").
+ * wouldn't be found by the system ClassLoader when invoking using "java -jar struts-core-VERSION.jar ...").
*/
public static class MainClassLoader extends URLClassLoader {
public MainClassLoader(URL[] urls) {
super(urls);
}
- public Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
+ public Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
if (name.startsWith("org.xml.") || name.startsWith("org.w3c.")
|| name.startsWith("java.") || name.startsWith("javax.")
|| name.startsWith("sun.") || name.startsWith("com.sun.")) {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/ServletActionContext.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/ServletActionContext.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/ServletActionContext.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/ServletActionContext.java Thu Jul 13 16:48:46 2006
@@ -42,7 +42,12 @@
super(context);
}
-
+ /**
+ * Gets the current action context
+ *
+ * @param req The request
+ * @return The current action context
+ */
public static ActionContext getActionContext(HttpServletRequest req) {
OgnlValueStack vs = getValueStack(req);
if (vs != null) {
@@ -52,6 +57,12 @@
}
}
+ /**
+ * Gets the current value stack for this request
+ *
+ * @param req The request
+ * @return The value stack
+ */
public static OgnlValueStack getValueStack(HttpServletRequest req) {
return (OgnlValueStack) req.getAttribute(STRUTS_VALUESTACK_KEY);
}
@@ -110,6 +121,11 @@
return (ServletContext) ActionContext.getContext().get(SERVLET_CONTEXT);
}
+ /**
+ * Sets the current servlet context object
+ *
+ * @param servletContext The servlet context to use
+ */
public static void setServletContext(ServletContext servletContext) {
ActionContext.getContext().put(SERVLET_CONTEXT, servletContext);
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsConstants.java Thu Jul 13 16:48:46 2006
@@ -18,61 +18,107 @@
package org.apache.struts2;
/**
- * This class provides a central location for framework constants related to
- * Struts configurations.
+ * This class provides a central location for framework configuration keys
+ * used to retrieve and store Struts configuration settings.
*/
public final class StrutsConstants {
+ /** Whether Struts is in development mode or not */
public static final String STRUTS_DEVMODE = "struts.devMode";
+ /** Whether the localization messages should automatically be reloaded */
public static final String STRUTS_I18N_RELOAD = "struts.i18n.reload";
+
+ /** The encoding to use for localization messages */
public static final String STRUTS_I18N_ENCODING = "struts.i18n.encoding";
+ /** Whether to reload the XML configuration or not */
public static final String STRUTS_CONFIGURATION_XML_RELOAD = "struts.configuration.xml.reload";
+ /** The URL extension to use to determine if the request is meant for a Struts action */
public static final String STRUTS_ACTION_EXTENSION = "struts.action.extension";
+ /** Whether to use the alterative syntax for the tags or not */
public static final String STRUTS_TAG_ALTSYNTAX = "struts.tag.altSyntax";
+ /** The HTTP port used by Struts URLs */
public static final String STRUTS_URL_HTTP_PORT = "struts.url.http.port";
+
+ /** The HTTPS port used by Struts URLs */
public static final String STRUTS_URL_HTTPS_PORT = "struts.url.https.port";
+ /** The com.opensymphony.xwork.ObjectFactory implementation class */
public static final String STRUTS_OBJECTFACTORY = "struts.objectFactory";
+
+ /** The com.opensymphony.xwork.util.ObjectTypeDeterminer implementation class */
public static final String STRUTS_OBJECTTYPEDETERMINER = "struts.objectTypeDeterminer";
+ /** The package containing actions that use Rife continuations */
public static final String STRUTS_CONTINUATIONS_PACKAGE = "struts.continuations.package";
+ /** The org.apache.struts2.config.Configuration implementation class */
public static final String STRUTS_CONFIGURATION = "struts.configuration";
+ /** The default locale for the Struts application */
public static final String STRUTS_LOCALE = "struts.locale";
+ /** Whether to use a Servlet request parameter workaround necessary for some versions of WebLogic */
public static final String STRUTS_DISPATCHER_PARAMETERSWORKAROUND = "struts.dispatcher.parametersWorkaround";
+ /** The org.apache.struts2.views.freemarker.FreemarkerManager implementation class */
public static final String STRUTS_FREEMARKER_MANAGER_CLASSNAME = "struts.freemarker.manager.classname";
+ /** org.apache.struts2.views.velocity.VelocityManager implementation class */
public static final String STRUTS_VELOCITY_MANAGER_CLASSNAME = "struts.velocity.manager.classname";
+
+ /** The Velocity configuration file path */
public static final String STRUTS_VELOCITY_CONFIGFILE = "struts.velocity.configfile";
+
+ /** The location of the Velocity toolbox */
public static final String STRUTS_VELOCITY_TOOLBOXLOCATION = "struts.velocity.toolboxlocation";
+
+ /** List of Velocity context names */
public static final String STRUTS_VELOCITY_CONTEXTS = "struts.velocity.contexts";
+ /** The directory containing UI templates */
public static final String STRUTS_UI_TEMPLATEDIR = "struts.ui.templateDir";
+
+ /** The default UI template theme */
public static final String STRUTS_UI_THEME = "struts.ui.theme";
+ /** The maximize size of a multipart request (file upload) */
public static final String STRUTS_MULTIPART_MAXSIZE = "struts.multipart.maxSize";
+
+ /** The directory to use for storing uploaded files */
public static final String STRUTS_MULTIPART_SAVEDIR = "struts.multipart.saveDir";
+
+ /**
+ * The org.apache.struts2.dispatcher.multipart.MultiPartRequest parser implementation
+ * for a multipart request (file upload)
+ */
public static final String STRUTS_MULTIPART_PARSER = "struts.multipart.parser";
+ /** Whether Spring should autoWire or not */
public static final String STRUTS_OBJECTFACTORY_SPRING_AUTOWIRE = "struts.objectFactory.spring.autoWire";
+
+ /** Whether Spring should use its class cache or not */
public static final String STRUTS_OBJECTFACTORY_SPRING_USE_CLASS_CACHE = "struts.objectFactory.spring.useClassCache";
+ /** Whether or not XSLT templates should not be cached */
public static final String STRUTS_XSLT_NOCACHE = "struts.xslt.nocache";
+ /** Location of additional configuration properties files to load */
public static final String STRUTS_CUSTOM_PROPERTIES = "struts.custom.properties";
+
+ /** Location of additional localization properties files to load */
public static final String STRUTS_CUSTOM_I18N_RESOURCES = "struts.custom.i18n.resources";
+
+ /** The org.apache.struts2.dispatcher.mapper.ActionMapper implementation class */
public static final String STRUTS_MAPPER_CLASS = "struts.mapper.class";
- public static final String STRUTS_PORTLET_CONTEXT = "struts.portlet.context";
-
+ /** Whether the Struts filter should serve static content or not */
public static final String STRUTS_SERVE_STATIC_CONTENT = "struts.serve.static";
+
+ /** If static content served by the Struts filter should set browser caching header properties or not */
public static final String STRUTS_SERVE_STATIC_BROWSER_CACHE = "struts.serve.static.browserCache";
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsException.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsException.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsException.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsException.java Thu Jul 13 16:48:46 2006
@@ -19,16 +19,12 @@
import com.opensymphony.xwork2.XWorkException;
import com.opensymphony.xwork2.util.location.Locatable;
-import com.opensymphony.xwork2.util.location.Location;
/**
* A generic runtime exception that optionally contains Location information
*/
public class StrutsException extends XWorkException implements Locatable {
-
- private Location location;
-
/**
* Constructs a <code>StrutsException</code> with no detail message.
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsStatics.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsStatics.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsStatics.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsStatics.java Thu Jul 13 16:48:46 2006
@@ -19,9 +19,8 @@
/**
- * Constants used by Struts. The constants
- * can be used to get or set objects out of the action context
- * or other collections.
+ * Constants used by Struts. The constants can be used to get or set objects
+ * out of the action context or other collections.
*
* <p/>
*
@@ -60,4 +59,7 @@
* Constant for the JSP {@link javax.servlet.jsp.PageContext page context}.
*/
public static final String PAGE_CONTEXT = "com.opensymphony.xwork2.dispatcher.PageContext";
+
+ /** Constant for the PortletContext object */
+ public static final String STRUTS_PORTLET_CONTEXT = "struts.portlet.context";
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsTestCase.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsTestCase.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsTestCase.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/StrutsTestCase.java Thu Jul 13 16:48:46 2006
@@ -17,10 +17,8 @@
*/
package org.apache.struts2;
-import javax.servlet.ServletContext;
-
import org.apache.struts2.config.Configuration;
-import org.apache.struts2.dispatcher.DispatcherUtils;
+import org.apache.struts2.dispatcher.Dispatcher;
import org.springframework.mock.web.MockServletContext;
import com.opensymphony.xwork2.XWorkTestCase;
@@ -31,14 +29,17 @@
*/
public abstract class StrutsTestCase extends XWorkTestCase {
-
-
+
+ /**
+ * Sets up the configuration settings, XWork configuration, and
+ * message resources
+ */
protected void setUp() throws Exception {
super.setUp();
Configuration.reset();
LocalizedTextUtil.clearDefaultResourceBundles();
- DispatcherUtils du = new DispatcherUtils(new MockServletContext());
- du.setInstance(du);
+ Dispatcher du = new Dispatcher(new MockServletContext());
+ Dispatcher.setInstance(du);
du.setConfigurationManager(configurationManager);
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ActionComponent.java Thu Jul 13 16:48:46 2006
@@ -19,7 +19,7 @@
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.StrutsException;
-import org.apache.struts2.dispatcher.DispatcherUtils;
+import org.apache.struts2.dispatcher.Dispatcher;
import org.apache.struts2.dispatcher.RequestMap;
import org.apache.struts2.views.jsp.TagUtils;
import com.opensymphony.xwork2.ActionContext;
@@ -153,7 +153,7 @@
Map session = ctx.getSession();
Map application = ctx.getApplication();
- DispatcherUtils du = DispatcherUtils.getInstance();
+ Dispatcher du = Dispatcher.getInstance();
Map extraContext = du.createContextMap(new RequestMap(req),
newParams,
session,
@@ -215,7 +215,7 @@
OgnlValueStack stack = getStack();
// execute at this point, after params have been set
try {
- Configuration config = DispatcherUtils.getInstance().getConfigurationManager().getConfiguration();
+ Configuration config = Dispatcher.getInstance().getConfigurationManager().getConfiguration();
proxy = ActionProxyFactory.getFactory().createActionProxy(config, namespace, actionName, createExtraContext(), executeResult, true);
if (null != methodName) {
proxy.setMethod(methodName);
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java Thu Jul 13 16:48:46 2006
@@ -31,7 +31,7 @@
import com.opensymphony.xwork2.validator.ValidationInterceptor;
import com.opensymphony.xwork2.validator.Validator;
import org.apache.commons.lang.StringUtils;
-import org.apache.struts2.dispatcher.DispatcherUtils;
+import org.apache.struts2.dispatcher.Dispatcher;
import org.apache.struts2.dispatcher.mapper.ActionMapperFactory;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
import org.apache.struts2.portlet.context.PortletActionContext;
@@ -136,7 +136,7 @@
action = findString(this.action);
}
- if (DispatcherUtils.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest()) {
+ if (Dispatcher.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest()) {
evaluateExtraParamsPortletRequest(namespace, action);
} else {
String namespace = determineNamespace(this.namespace, getStack(),
@@ -198,7 +198,7 @@
action = action.substring(0, endIdx);
}
- Configuration config = DispatcherUtils.getInstance().getConfigurationManager().getConfiguration();
+ Configuration config = Dispatcher.getInstance().getConfigurationManager().getConfiguration();
final ActionConfig actionConfig = config.getRuntimeConfiguration().getActionConfig(namespace, action);
String actionName = action;
if (actionConfig != null) {
@@ -271,7 +271,7 @@
addParameter("performValidation", Boolean.FALSE);
- RuntimeConfiguration runtimeConfiguration = DispatcherUtils.getInstance().getConfigurationManager().getConfiguration().getRuntimeConfiguration();
+ RuntimeConfiguration runtimeConfiguration = Dispatcher.getInstance().getConfigurationManager().getConfiguration().getRuntimeConfiguration();
ActionConfig actionConfig = runtimeConfiguration.getActionConfig(namespace, actionName);
if (actionConfig != null) {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/URL.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/URL.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/URL.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/URL.java Thu Jul 13 16:48:46 2006
@@ -21,7 +21,7 @@
import org.apache.struts2.portlet.context.PortletActionContext;
import org.apache.struts2.portlet.util.PortletUrlHelper;
import org.apache.struts2.views.util.UrlHelper;
-import org.apache.struts2.dispatcher.DispatcherUtils;
+import org.apache.struts2.dispatcher.Dispatcher;
import com.opensymphony.xwork2.util.OgnlValueStack;
import com.opensymphony.xwork2.util.XWorkContinuationConfig;
import com.opensymphony.xwork2.ActionContext;
@@ -177,7 +177,7 @@
}
private void includeGetParameters() {
- if(!(DispatcherUtils.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest())) {
+ if(!(Dispatcher.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest())) {
String query = extractQueryString();
if (query != null) {
//mergeRequestParameters(parameters, HttpUtils.parseQueryString(query));
@@ -210,14 +210,14 @@
String result;
if (value == null && action != null) {
- if(DispatcherUtils.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest()) {
+ if(Dispatcher.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest()) {
result = PortletUrlHelper.buildUrl(action, namespace, parameters, portletUrlType, portletMode, windowState);
}
else {
result = determineActionURL(action, namespace, method, req, res, parameters, scheme, includeContext, encode);
}
} else {
- if(DispatcherUtils.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest()) {
+ if(Dispatcher.getInstance().isPortletSupportActive() && PortletActionContext.isPortletRequest()) {
result = PortletUrlHelper.buildResourceUrl(value, parameters);
}
else {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/DefaultConfiguration.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/DefaultConfiguration.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/DefaultConfiguration.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/DefaultConfiguration.java Thu Jul 13 16:48:46 2006
@@ -45,7 +45,7 @@
public DefaultConfiguration() {
// Create default implementations
// Use default properties and struts.properties
- ArrayList list = new ArrayList();
+ ArrayList<Configuration> list = new ArrayList<Configuration>();
try {
list.add(new PropertiesConfiguration("struts"));
@@ -84,7 +84,7 @@
// out
}
- // Add addtional list of i18n global resource bundles
+ // Add additional list of i18n global resource bundles
try {
LocalizedTextUtil.addDefaultResourceBundle("org/apache/struts2/struts-messages");
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/DelegatingConfiguration.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/DelegatingConfiguration.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/DelegatingConfiguration.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/DelegatingConfiguration.java Thu Jul 13 16:48:46 2006
@@ -122,7 +122,7 @@
public Iterator listImpl() {
boolean workedAtAll = false;
- Set settingList = new HashSet();
+ Set<Object> settingList = new HashSet<Object>();
UnsupportedOperationException e = null;
for (int i = 0; i < configList.length; i++) {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ServletContextSingleton.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ServletContextSingleton.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ServletContextSingleton.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/ServletContextSingleton.java Thu Jul 13 16:48:46 2006
@@ -53,12 +53,12 @@
}
/**
- * answers the singleton.
+ * Answers the singleton.
* <p/>
* At some point, the caller must populate the web servlet
* context.
*
- * @return answers the singleton instance of this class
+ * @return Answers the singleton instance of this class
*/
public static ServletContextSingleton getInstance() {
if (singleton == null) {
@@ -68,14 +68,18 @@
}
/**
- * @return the web servlet context
+ * Gets the servlet context
+ *
+ * @return The web servlet context
*/
public ServletContext getServletContext() {
return servletContext;
}
/**
- * @param context the web servlet context
+ * Sets the servlet context
+ *
+ * @param context The web servlet context
*/
public void setServletContext(ServletContext context) {
servletContext = context;
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/StrutsXMLConfigurationProvider.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/StrutsXMLConfigurationProvider.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/StrutsXMLConfigurationProvider.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config/StrutsXMLConfigurationProvider.java Thu Jul 13 16:48:46 2006
@@ -3,12 +3,6 @@
*/
package org.apache.struts2.config;
-import com.opensymphony.util.FileManager;
-import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.struts2.StrutsException;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -16,18 +10,35 @@
import java.util.HashMap;
import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts2.StrutsException;
+
+import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
+
/**
- * Override Xwork class so we cn use an arbitrary config file
+ * Override Xwork class so we can use an arbitrary config file
*/
public class StrutsXMLConfigurationProvider extends XmlConfigurationProvider {
private static final Log LOG = LogFactory.getLog(StrutsXMLConfigurationProvider.class);
private File baseDir = null;
+ /**
+ * Constructs the configuration provider
+ *
+ * @param errorIfMissing If we should throw an exception if the file can't be found
+ */
public StrutsXMLConfigurationProvider(boolean errorIfMissing) {
this("struts.xml", errorIfMissing);
}
+ /**
+ * Constructs the configuration provider
+ *
+ * @param filename The filename to look for
+ * @param errorIfMissing If we should throw an exception if the file can't be found
+ */
public StrutsXMLConfigurationProvider(String filename, boolean errorIfMissing) {
super(filename, errorIfMissing);
@@ -41,8 +52,9 @@
}
/**
- * Override Xwork method so we cn use an arbitrary config file
+ * Look for the configuration file on the classpath and in the file system
*
+ * @param fileName The file name to retrieve
* @see com.opensymphony.xwork2.config.providers.XmlConfigurationProvider#getInputStream(java.lang.String)
*/
protected InputStream getInputStream(String fileName) {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/config_browser/ConfigurationHelper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/config_browser/ConfigurationHelper.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/config_browser/ConfigurationHelper.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/config_browser/ConfigurationHelper.java Thu Jul 13 16:48:46 2006
@@ -23,7 +23,7 @@
import java.util.Map;
import java.util.Set;
-import org.apache.struts2.dispatcher.DispatcherUtils;
+import org.apache.struts2.dispatcher.Dispatcher;
/**
* ConfigurationHelper
@@ -32,7 +32,7 @@
public static Set getNamespaces() {
Set namespaces = Collections.EMPTY_SET;
- Map allActionConfigs = DispatcherUtils.getInstance().getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfigs();
+ Map allActionConfigs = Dispatcher.getInstance().getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfigs();
if (allActionConfigs != null) {
namespaces = allActionConfigs.keySet();
}
@@ -41,7 +41,7 @@
public static Set getActionNames(String namespace) {
Set actionNames = Collections.EMPTY_SET;
- Map allActionConfigs = DispatcherUtils.getInstance().getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfigs();
+ Map allActionConfigs = Dispatcher.getInstance().getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfigs();
if (allActionConfigs != null) {
Map actionMappings = (Map) allActionConfigs.get(namespace);
if (actionMappings != null) {
@@ -53,7 +53,7 @@
public static ActionConfig getActionConfig(String namespace, String actionName) {
ActionConfig config = null;
- Map allActionConfigs = DispatcherUtils.getInstance().getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfigs();
+ Map allActionConfigs = Dispatcher.getInstance().getConfigurationManager().getConfiguration().getRuntimeConfiguration().getActionConfigs();
if (allActionConfigs != null) {
Map actionMappings = (Map) allActionConfigs.get(namespace);
if (actionMappings != null) {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ActionContextCleanUp.java Thu Jul 13 16:48:46 2006
@@ -57,17 +57,22 @@
private static final String COUNTER = "__cleanup_recursion_counter";
protected FilterConfig filterConfig;
- protected DispatcherUtils dispatcher;
-
- public FilterConfig getFilterConfig() {
- return filterConfig;
- }
+ protected Dispatcher dispatcher;
+ /**
+ * Initializes the filter
+ *
+ * @param filterConfig The filter configuration
+ */
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
- dispatcher = new DispatcherUtils(filterConfig.getServletContext());
+ dispatcher = new Dispatcher(filterConfig.getServletContext());
}
+
+ /* (non-Javadoc)
+ * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
+ */
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
@@ -75,7 +80,7 @@
// prepare the request no matter what - this ensures that the proper character encoding
// is used before invoking the mapper (see WW-9127)
- DispatcherUtils.setInstance(dispatcher);
+ Dispatcher.setInstance(dispatcher);
dispatcher.prepare(request, response);
ServletContext servletContext = filterConfig.getServletContext();
@@ -105,6 +110,11 @@
}
}
+ /**
+ * Clean up the request of threadlocals if this is the last execution
+ *
+ * @param req The servlet request
+ */
protected static void cleanUp(ServletRequest req) {
// should we clean up yet?
if (req.getAttribute(COUNTER) != null &&
@@ -115,9 +125,13 @@
// always dontClean up the thread request, even if an action hasn't been executed
ActionContext.setContext(null);
- DispatcherUtils.setInstance(null);
+ Dispatcher.setInstance(null);
}
+
+ /* (non-Javadoc)
+ * @see javax.servlet.Filter#destroy()
+ */
public void destroy() {
}
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ApplicationMap.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ApplicationMap.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ApplicationMap.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ApplicationMap.java Thu Jul 13 16:48:46 2006
@@ -33,8 +33,8 @@
private static final long serialVersionUID = 9136809763083228202L;
- ServletContext context;
- Set entries;
+ private ServletContext context;
+ private Set<Object> entries;
/**
@@ -67,7 +67,7 @@
*/
public Set entrySet() {
if (entries == null) {
- entries = new HashSet();
+ entries = new HashSet<Object>();
// Add servlet context attributes
Enumeration enumeration = context.getAttributeNames();
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DefaultActionSupport.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DefaultActionSupport.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DefaultActionSupport.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DefaultActionSupport.java Thu Jul 13 16:48:46 2006
@@ -25,15 +25,17 @@
/**
* A simple action support class that sets properties to be able to serve
- *
*/
public class DefaultActionSupport extends ActionSupport {
private static final long serialVersionUID = -2426166391283746095L;
- String successResultValue;
+ private String successResultValue;
+ /**
+ * Constructor
+ */
public DefaultActionSupport() {
super();
}
Copied: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java (from r421711, struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DispatcherUtils.java)
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java?p2=struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java&p1=struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DispatcherUtils.java&r1=421711&r2=421742&rev=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DispatcherUtils.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/Dispatcher.java Thu Jul 13 16:48:46 2006
@@ -17,11 +17,24 @@
*/
package org.apache.struts2.dispatcher;
-import com.opensymphony.util.ClassLoaderUtil;
-import com.opensymphony.util.FileManager;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;
-import org.apache.struts2.StrutsStatics;
import org.apache.struts2.StrutsConstants;
+import org.apache.struts2.StrutsStatics;
import org.apache.struts2.config.Configuration;
import org.apache.struts2.config.StrutsXMLConfigurationProvider;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
@@ -30,78 +43,99 @@
import org.apache.struts2.util.AttributeMap;
import org.apache.struts2.util.ObjectFactoryDestroyable;
import org.apache.struts2.util.ObjectFactoryInitializable;
-import com.opensymphony.xwork2.*;
+import org.apache.struts2.views.freemarker.FreemarkerManager;
+
+import com.opensymphony.util.ClassLoaderUtil;
+import com.opensymphony.util.FileManager;
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.ActionProxy;
+import com.opensymphony.xwork2.ActionProxyFactory;
+import com.opensymphony.xwork2.ObjectFactory;
+import com.opensymphony.xwork2.Result;
import com.opensymphony.xwork2.config.ConfigurationException;
import com.opensymphony.xwork2.config.ConfigurationManager;
-import com.opensymphony.xwork2.config.ConfigurationProvider;
import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
-import com.opensymphony.xwork2.util.*;
+import com.opensymphony.xwork2.util.LocalizedTextUtil;
+import com.opensymphony.xwork2.util.ObjectTypeDeterminer;
+import com.opensymphony.xwork2.util.ObjectTypeDeterminerFactory;
+import com.opensymphony.xwork2.util.OgnlValueStack;
+import com.opensymphony.xwork2.util.XWorkContinuationConfig;
import com.opensymphony.xwork2.util.location.Location;
import com.opensymphony.xwork2.util.location.LocationUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import freemarker.template.Template;
-import org.apache.struts2.views.freemarker.FreemarkerManager;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.HashMap;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
/**
- * A utility class whereby FilterDispatcher delegate most of its tasks to. A static
- * singleton that gets initlialized upon the call to it's
- * <code>initalize(ServletContext)</code>
- * method
+ * A utility class the actual dispatcher delegates most of its tasks to. Each instance
+ * of the primary dispatcher holds an instance of this dispatcher to be shared for
+ * all requests.
*
* @see org.apache.struts2.dispatcher.FilterDispatcher
+ * @see org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher
*/
-public class DispatcherUtils {
- private static final Log LOG = LogFactory.getLog(DispatcherUtils.class);
+public class Dispatcher {
+ private static final Log LOG = LogFactory.getLog(Dispatcher.class);
- private static ThreadLocal instance = new ThreadLocal<DispatcherUtils>();
+ private static ThreadLocal<Dispatcher> instance = new ThreadLocal<Dispatcher>();
private static List<DispatcherListener> dispatcherListeners =
new ArrayList<DispatcherListener>();
+
private ConfigurationManager configurationManager;
-
private boolean portletSupportActive;
+ private boolean devMode = false;
+
+ // used to get WebLogic to play nice
+ private boolean paramsWorkaroundEnabled = false;
- public static DispatcherUtils getInstance() {
- return (DispatcherUtils) instance.get();
+ /**
+ * Gets the current instance for this thread
+ *
+ * @return The dispatcher instance
+ */
+ public static Dispatcher getInstance() {
+ return (Dispatcher) instance.get();
}
- public static void setInstance(DispatcherUtils instance) {
- DispatcherUtils.instance.set(instance);
+ /**
+ * Sets the dispatcher instance for this thread
+ *
+ * @param instance The instance
+ */
+ public static void setInstance(Dispatcher instance) {
+ Dispatcher.instance.set(instance);
}
+ /**
+ * Adds a dispatcher lifecycle listener
+ *
+ * @param l The listener
+ */
public static synchronized void addDispatcherListener(DispatcherListener l) {
dispatcherListeners.add(l);
}
+ /**
+ * Removes a dispatcher lifecycle listener
+ *
+ * @param l The listener
+ */
public static synchronized void removeDispatcherListener(DispatcherListener l) {
dispatcherListeners.remove(l);
}
-
- protected boolean devMode = false;
- // used to get WebLogic to play nice
- protected boolean paramsWorkaroundEnabled = false;
-
- public DispatcherUtils(ServletContext servletContext) {
+ /**
+ * The constructor with its servlet context instance (optional)
+ *
+ * @param servletContext The servlet context
+ */
+ public Dispatcher(ServletContext servletContext) {
init(servletContext);
}
- protected void cleanup() {
+ /**
+ * Cleans up thread local variables
+ */
+ public void cleanup() {
ObjectFactory objectFactory = ObjectFactory.getObjectFactory();
if (objectFactory == null) {
LOG.warn("Object Factory is null, something is seriously wrong, no clean up will be performed");
@@ -116,7 +150,7 @@
}
}
instance.set(null);
- synchronized(DispatcherUtils.class) {
+ synchronized(Dispatcher.class) {
if (dispatcherListeners.size() > 0) {
for (DispatcherListener l : dispatcherListeners) {
l.dispatcherDestroyed(this);
@@ -125,7 +159,12 @@
}
}
- protected void init(ServletContext servletContext) {
+ /**
+ * Initializes the instance
+ *
+ * @param servletContext The servlet context
+ */
+ private void init(ServletContext servletContext) {
boolean reloadi18n = Boolean.valueOf((String) Configuration.get(StrutsConstants.STRUTS_I18N_RELOAD)).booleanValue();
LocalizedTextUtil.setReloadBundles(reloadi18n);
@@ -142,7 +181,7 @@
}
try {
- Class clazz = ClassLoaderUtil.loadClass(className, DispatcherUtils.class);
+ Class clazz = ClassLoaderUtil.loadClass(className, Dispatcher.class);
ObjectFactory objectFactory = (ObjectFactory) clazz.newInstance();
if (servletContext != null) {
if (objectFactory instanceof ObjectFactoryInitializable) {
@@ -167,7 +206,7 @@
}
try {
- Class clazz = ClassLoaderUtil.loadClass(className, DispatcherUtils.class);
+ Class clazz = ClassLoaderUtil.loadClass(className, Dispatcher.class);
ObjectTypeDeterminer objectTypeDeterminer = (ObjectTypeDeterminer) clazz.newInstance();
ObjectTypeDeterminerFactory.setInstance(objectTypeDeterminer);
} catch (Exception e) {
@@ -204,7 +243,7 @@
// Check wether portlet support is active or not by trying to get "javax.portlet.PortletRequest"
try {
- Class clazz = ClassLoaderUtil.loadClass("javax.portlet.PortletRequest", DispatcherUtils.class);
+ ClassLoaderUtil.loadClass("javax.portlet.PortletRequest", Dispatcher.class);
portletSupportActive = true;
if (LOG.isInfoEnabled()) {
LOG.info("Found portlet-api. Activating Struts's portlet support");
@@ -221,7 +260,7 @@
// Load Struts config files
configurationManager.addConfigurationProvider(new StrutsXMLConfigurationProvider(false));
- synchronized(DispatcherUtils.class) {
+ synchronized(Dispatcher.class) {
if (dispatcherListeners.size() > 0) {
for (DispatcherListener l : dispatcherListeners) {
l.dispatcherInitialized(this);
@@ -234,7 +273,7 @@
* Loads the action and executes it. This method first creates the action context from the given
* parameters then loads an <tt>ActionProxy</tt> from the given action name and namespace. After that,
* the action is executed and output channels throught the response object. Actions not found are
- * sent back to the user via the {@link DispatcherUtils#sendError} method, using the 404 return code.
+ * sent back to the user via the {@link Dispatcher#sendError} method, using the 404 return code.
* All other errors are reported by throwing a ServletException.
*
* @param request the HttpServletRequest object
@@ -244,7 +283,7 @@
* would end up as a 5xx by the servlet container)
*/
public void serviceAction(HttpServletRequest request, HttpServletResponse response, ServletContext context, ActionMapping mapping) throws ServletException {
- Map extraContext = createContextMap(request, response, mapping, context);
+ Map<String, Object> extraContext = createContextMap(request, response, mapping, context);
// If there was a previous value stack, then create a new copy and pass it in to be used by the new Action
OgnlValueStack stack = (OgnlValueStack) request.getAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY);
@@ -294,7 +333,17 @@
}
}
- public Map createContextMap(HttpServletRequest request, HttpServletResponse response, ActionMapping mapping, ServletContext context) {
+ /**
+ * Creates a context map containing all the wrapped request objects
+ *
+ * @param request The servlet request
+ * @param response The servlet response
+ * @param mapping The action mapping
+ * @param context The servlet context
+ * @return A map of context objects
+ */
+ public Map<String,Object> createContextMap(HttpServletRequest request, HttpServletResponse response,
+ ActionMapping mapping, ServletContext context) {
// request map wrapping the http request objects
Map requestMap = new RequestMap(request);
@@ -332,14 +381,14 @@
* @param servletContext the ServletContext object.
* @return a HashMap representing the <tt>Action</tt> context.
*/
- public HashMap createContextMap(Map requestMap,
+ public HashMap<String,Object> createContextMap(Map requestMap,
Map parameterMap,
Map sessionMap,
Map applicationMap,
HttpServletRequest request,
HttpServletResponse response,
ServletContext servletContext) {
- HashMap extraContext = new HashMap();
+ HashMap<String,Object> extraContext = new HashMap<String,Object>();
extraContext.put(ActionContext.PARAMETERS, new HashMap(parameterMap));
extraContext.put(ActionContext.SESSION, sessionMap);
extraContext.put(ActionContext.APPLICATION, applicationMap);
@@ -375,7 +424,7 @@
*
* @return the maximum upload size allowed for multipart requests
*/
- public static int getMaxSize() {
+ private static int getMaxSize() {
Integer maxSize = new Integer(Integer.MAX_VALUE);
try {
String maxSizeStr = Configuration.getString(StrutsConstants.STRUTS_MULTIPART_MAXSIZE);
@@ -405,7 +454,7 @@
*
* @return the path to save uploaded files to
*/
- public String getSaveDir(ServletContext servletContext) {
+ private String getSaveDir(ServletContext servletContext) {
String saveDir = Configuration.getString(StrutsConstants.STRUTS_MULTIPART_SAVEDIR).trim();
if (saveDir.equals("")) {
@@ -430,6 +479,12 @@
return saveDir;
}
+ /**
+ * Prepares a request, including setting the encoding and locale
+ *
+ * @param request The request
+ * @param response The response
+ */
public void prepare(HttpServletRequest request, HttpServletResponse response) {
String encoding = null;
if (Configuration.isSet(StrutsConstants.STRUTS_I18N_ENCODING)) {
@@ -491,7 +546,7 @@
* @param code the HttpServletResponse error code (see {@link javax.servlet.http.HttpServletResponse} for possible error codes).
* @param e the Exception that is reported.
*/
- public void sendError(HttpServletRequest request, HttpServletResponse response,
+ private void sendError(HttpServletRequest request, HttpServletResponse response,
ServletContext ctx, int code, Exception e) {
if (devMode) {
response.setContentType("text/html");
@@ -500,14 +555,14 @@
freemarker.template.Configuration config = FreemarkerManager.getInstance().getConfiguration(ctx);
Template template = config.getTemplate("/org/apache/struts2/dispatcher/error.ftl");
- List chain = new ArrayList();
+ List<Throwable> chain = new ArrayList<Throwable>();
Throwable cur = e;
chain.add(cur);
while ((cur = cur.getCause()) != null) {
chain.add(cur);
}
- HashMap data = new HashMap();
+ HashMap<String,Object> data = new HashMap<String,Object>();
data.put("exception", e);
data.put("unknown", Location.UNKNOWN);
data.put("chain", chain);
@@ -554,10 +609,20 @@
}
}
+ /**
+ * Gets the current configuration manager instance
+ *
+ * @return The instance
+ */
public ConfigurationManager getConfigurationManager() {
return configurationManager;
}
-
+
+ /**
+ * Sets the current configuration manager instance
+ *
+ * @param mgr The configuration manager
+ */
public void setConfigurationManager(ConfigurationManager mgr) {
this.configurationManager = mgr;
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DispatcherListener.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DispatcherListener.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DispatcherListener.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/DispatcherListener.java Thu Jul 13 16:48:46 2006
@@ -23,7 +23,17 @@
*/
public interface DispatcherListener {
- public void dispatcherInitialized(DispatcherUtils du);
+ /**
+ * Called when the dispatcher is initialized
+ *
+ * @param du The dispatcher instance
+ */
+ public void dispatcherInitialized(Dispatcher du);
- public void dispatcherDestroyed(DispatcherUtils du);
+ /**
+ * Called when the dispatcher is destroyed
+ *
+ * @param du The dispatcher instance
+ */
+ public void dispatcherDestroyed(Dispatcher du);
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcher.java Thu Jul 13 16:48:46 2006
@@ -17,7 +17,30 @@
*/
package org.apache.struts2.dispatcher;
-import com.opensymphony.util.ClassLoaderUtil;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URLDecoder;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.TimeZone;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.struts2.RequestUtils;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.StrutsStatics;
@@ -25,21 +48,9 @@
import org.apache.struts2.dispatcher.mapper.ActionMapper;
import org.apache.struts2.dispatcher.mapper.ActionMapperFactory;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
-import com.opensymphony.xwork2.ActionContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import javax.servlet.*;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-import java.net.URLDecoder;
-import java.util.*;
-import java.text.SimpleDateFormat;
+import com.opensymphony.util.ClassLoaderUtil;
+import com.opensymphony.xwork2.ActionContext;
/**
* Master filter for Struts that handles four distinct
@@ -53,7 +64,7 @@
*
* <li>Serving static content</li>
*
- * <li>Kicking off XWork's IoC for the request lifecycle</li>
+ * <li>Kicking off XWork's interceptor chain for the request lifecycle</li>
*
* </ul>
*
@@ -104,18 +115,26 @@
public class FilterDispatcher implements Filter, StrutsStatics {
private static final Log LOG = LogFactory.getLog(FilterDispatcher.class);
- protected FilterConfig filterConfig;
- protected String[] pathPrefixes;
- protected DispatcherUtils dispatcher;
+ private FilterConfig filterConfig;
+ private String[] pathPrefixes;
+ private Dispatcher dispatcher;
private SimpleDateFormat df = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss");
private final Calendar lastModifiedCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
private final String lastModified = df.format(lastModifiedCal.getTime());
- public FilterConfig getFilterConfig() {
+ /**
+ * Gets this filter's configuration
+ *
+ * @return The filter config
+ */
+ protected FilterConfig getFilterConfig() {
return filterConfig;
}
+ /**
+ * Cleans up the dispatcher
+ */
public void destroy() {
if (dispatcher == null) {
LOG.warn("something is seriously wrong, DispatcherUtil is not initialized (null) ");
@@ -124,6 +143,9 @@
}
}
+ /**
+ * Initializes the dispatcher and filter
+ */
public void init(FilterConfig filterConfig) throws ServletException {
this.filterConfig = filterConfig;
String param = filterConfig.getInitParameter("packages");
@@ -132,14 +154,20 @@
packages = param + " " + packages;
}
this.pathPrefixes = parse(packages);
- dispatcher = new DispatcherUtils(filterConfig.getServletContext());
+ dispatcher = new Dispatcher(filterConfig.getServletContext());
}
+ /**
+ * Parses the list of packages
+ *
+ * @param packages A comma-delimited String
+ * @return A string array of packages
+ */
protected String[] parse(String packages) {
if (packages == null) {
return null;
}
- List pathPrefixes = new ArrayList();
+ List<String> pathPrefixes = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(packages, ", \n\t");
while (st.hasMoreTokens()) {
@@ -154,12 +182,15 @@
}
+ /* (non-Javadoc)
+ * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
+ */
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
ServletContext servletContext = filterConfig.getServletContext();
- DispatcherUtils du = DispatcherUtils.getInstance();
+ Dispatcher du = Dispatcher.getInstance();
// Prepare and wrap the request if the cleanup filter hasn't already
if (du == null) {
@@ -177,7 +208,7 @@
LOG.error(message, e);
throw new ServletException(message, e);
}
- DispatcherUtils.setInstance(du);
+ Dispatcher.setInstance(du);
}
ActionMapper mapper = ActionMapperFactory.getMapper();
@@ -204,27 +235,13 @@
}
- Object o = null;
try {
-
- o = beforeActionInvocation(request, servletContext);
-
dispatcher.serviceAction(request, response, servletContext, mapping);
} finally {
- afterActionInvocation(request, servletContext, o);
ActionContextCleanUp.cleanUp(req);
}
}
- protected void afterActionInvocation(HttpServletRequest request, Object o, Object o1) {
- // nothing by default, but a good hook for scoped ioc integration
- }
-
- protected Object beforeActionInvocation(HttpServletRequest request, ServletContext servletContext) {
- // nothing by default, but a good hook for scoped ioc integration
- return null;
- }
-
/**
* Servlet 2.3 specifies that the servlet context can be retrieved from the session. Unfortunately, some versions of
* WebLogic can only retrieve the servlet context from the filter config. Hence, this method enables subclasses to
@@ -237,6 +254,13 @@
return filterConfig.getServletContext();
}
+ /**
+ * Fins a static resource
+ *
+ * @param name The resource name
+ * @param response The request
+ * @throws IOException If anything goes wrong
+ */
protected void findStaticResource(String name, HttpServletResponse response) throws IOException {
if (!name.endsWith(".class")) {
for (int i = 0; i < pathPrefixes.length; i++) {
@@ -277,7 +301,13 @@
response.sendError(HttpServletResponse.SC_NOT_FOUND);
}
- private String getContentType(String name) {
+ /**
+ * Determines the content type for the resource name
+ *
+ * @param name The resource name
+ * @return The mime type
+ */
+ protected String getContentType(String name) {
// NOT using the code provided activation.jar to avoid adding yet another dependency
// this is generally OK, since these are the main files we server up
if (name.endsWith(".js")) {
@@ -299,6 +329,13 @@
}
}
+ /**
+ * Copies the from the input stream to the output stream
+ *
+ * @param input The input stream
+ * @param output The output stream
+ * @throws IOException If anything goes wrong
+ */
protected void copy(InputStream input, OutputStream output) throws IOException {
final byte[] buffer = new byte[4096];
int n;
@@ -307,6 +344,14 @@
}
}
+ /**
+ * Looks for a static resource in the classpath
+ *
+ * @param name The resource name
+ * @param packagePrefix The package prefix to use to locate the resource
+ * @return The inputstream of the resource
+ * @throws IOException If there is a problem locating the resource
+ */
protected InputStream findInputStream(String name, String packagePrefix) throws IOException {
String resourcePath;
if (packagePrefix.endsWith("/") && name.startsWith("/")) {
@@ -319,24 +364,5 @@
resourcePath = URLDecoder.decode(resourcePath, enc);
return ClassLoaderUtil.getResourceAsStream(resourcePath, getClass());
- }
-
- /**
- * handle .. chars here and other URL hacks
- */
- protected boolean checkUrl(URL url, String rawResourcePath) {
-
- // ignore folder resources - they provide streams too ! dunno why :)
- if (url.getPath().endsWith("/")) {
- return false;
- }
-
- // check for parent path access
- // NOTE : most servlet containers shoudl resolve .. chars in the request url anyway
- if (url.toExternalForm().indexOf(rawResourcePath) == -1) {
- return false;
- }
-
- return true;
}
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcherCompatWeblogic61.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcherCompatWeblogic61.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcherCompatWeblogic61.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/FilterDispatcherCompatWeblogic61.java Thu Jul 13 16:48:46 2006
@@ -46,9 +46,7 @@
public class FilterDispatcherCompatWeblogic61
extends FilterDispatcher
implements Filter {
- /**
- * the standard logger
- */
+
private static Log log =
LogFactory.getLog(FilterDispatcherCompatWeblogic61.class);
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/HttpHeaderResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/HttpHeaderResult.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/HttpHeaderResult.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/HttpHeaderResult.java Thu Jul 13 16:48:46 2006
@@ -68,10 +68,11 @@
private static final long serialVersionUID = 195648957144219214L;
+ /** The default parameter */
public static final String DEFAULT_PARAM = "status";
- protected boolean parse = true;
+ private boolean parse = true;
private Map headers;
private int status = -1;
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/PlainTextResult.java Thu Jul 13 16:48:46 2006
@@ -70,25 +70,37 @@
*
*/
public class PlainTextResult extends StrutsResultSupport {
-
+
+ public static final int BUFFER_SIZE = 1024;
+
private static final Log _log = LogFactory.getLog(PlainTextResult.class);
private static final long serialVersionUID = 3633371605905583950L;
- public static final int BUFFER_SIZE = 1024;
-
private String charSet;
+ /**
+ * Set the character set
+ *
+ * @return The character set
+ */
public String getCharSet() {
return charSet;
}
+
+ /**
+ * Set the character set
+ *
+ * @param charSet The character set
+ */
public void setCharSet(String charSet) {
this.charSet = charSet;
}
-
-
+ /* (non-Javadoc)
+ * @see org.apache.struts2.dispatcher.StrutsResultSupport#doExecute(java.lang.String, com.opensymphony.xwork2.ActionInvocation)
+ */
protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
// verify charset
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/RequestMap.java Thu Jul 13 16:48:46 2006
@@ -32,7 +32,7 @@
private static final long serialVersionUID = -7675640869293787926L;
- Set entries;
+ private Set<Object> entries;
private HttpServletRequest request;
@@ -66,7 +66,7 @@
*/
public Set entrySet() {
if (entries == null) {
- entries = new HashSet();
+ entries = new HashSet<Object>();
Enumeration enumeration = request.getAttributeNames();
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ServletActionRedirectResult.java Thu Jul 13 16:48:46 2006
@@ -17,12 +17,9 @@
*/
package org.apache.struts2.dispatcher;
-import java.util.Map;
-
import org.apache.struts2.dispatcher.mapper.ActionMapper;
import org.apache.struts2.dispatcher.mapper.ActionMapperFactory;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
-import org.apache.struts2.views.util.UrlHelper;
import com.opensymphony.xwork2.ActionInvocation;
@@ -85,12 +82,16 @@
private static final long serialVersionUID = -9042425229314584066L;
+ /** The default parameter */
public static final String DEFAULT_PARAM = "actionName";
protected String actionName;
protected String namespace;
protected String method;
+ /* (non-Javadoc)
+ * @see com.opensymphony.xwork2.Result#execute(com.opensymphony.xwork2.ActionInvocation)
+ */
public void execute(ActionInvocation invocation) throws Exception {
actionName = conditionalParse(actionName, invocation);
if (namespace == null) {
@@ -111,14 +112,29 @@
super.execute(invocation);
}
+ /**
+ * Sets the action name
+ *
+ * @param actionName The name
+ */
public void setActionName(String actionName) {
this.actionName = actionName;
}
+ /**
+ * Sets the namespace
+ *
+ * @param namespace The namespace
+ */
public void setNamespace(String namespace) {
this.namespace = namespace;
}
+ /**
+ * Sets the method
+ *
+ * @param method The method
+ */
public void setMethod(String method) {
this.method = method;
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/SessionMap.java Thu Jul 13 16:48:46 2006
@@ -34,7 +34,7 @@
private static final long serialVersionUID = 4678843241638046854L;
protected HttpSession session;
- protected Set entries;
+ protected Set<Object> entries;
protected HttpServletRequest request;
@@ -84,7 +84,7 @@
synchronized (session) {
if (entries == null) {
- entries = new HashSet();
+ entries = new HashSet<Object>();
Enumeration enumeration = session.getAttributeNames();
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StreamResult.java Thu Jul 13 16:48:46 2006
@@ -154,6 +154,9 @@
this.inputName = inputName;
}
+ /* (non-Javadoc)
+ * @see org.apache.struts2.dispatcher.StrutsResultSupport#doExecute(java.lang.String, com.opensymphony.xwork2.ActionInvocation)
+ */
protected void doExecute(String finalLocation, ActionInvocation invocation) throws Exception {
InputStream oInput = null;
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StrutsRequestWrapper.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StrutsRequestWrapper.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StrutsRequestWrapper.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StrutsRequestWrapper.java Thu Jul 13 16:48:46 2006
@@ -36,10 +36,20 @@
*
*/
public class StrutsRequestWrapper extends HttpServletRequestWrapper {
+
+ /**
+ * The constructor
+ * @param req The request
+ */
public StrutsRequestWrapper(HttpServletRequest req) {
super(req);
}
+ /**
+ * Gets the object, looking in the value stack if not found
+ *
+ * @param s The attribute key
+ */
public Object getAttribute(String s) {
if (s != null && s.startsWith("javax.servlet")) {
// don't bother with the standard javax.servlet attributes, we can short-circuit this
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/StrutsResultSupport.java Thu Jul 13 16:48:46 2006
@@ -100,6 +100,7 @@
private static final Log _log = LogFactory.getLog(StrutsResultSupport.class);
+ /** The default parameter */
public static final String DEFAULT_PARAM = "location";
protected boolean parse = true;
@@ -149,7 +150,14 @@
public void execute(ActionInvocation invocation) throws Exception {
doExecute(conditionalParse(location, invocation), invocation);
}
-
+
+ /**
+ * Parses the parameter for OGNL expressions against the valuestack
+ *
+ * @param param The parameter value
+ * @param invocation The action invocation instance
+ * @return The resulting string
+ */
protected String conditionalParse(String param, ActionInvocation invocation) {
if (parse && param != null && invocation != null) {
return TextParseUtil.translateVariables(param, invocation.getStack(),
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/portlet/dispatcher/Jsr168Dispatcher.java Thu Jul 13 16:48:46 2006
@@ -40,7 +40,7 @@
import org.apache.struts2.StrutsStatics;
import org.apache.struts2.config.Configuration;
import org.apache.struts2.dispatcher.ApplicationMap;
-import org.apache.struts2.dispatcher.DispatcherUtils;
+import org.apache.struts2.dispatcher.Dispatcher;
import org.apache.struts2.dispatcher.RequestMap;
import org.apache.struts2.dispatcher.SessionMap;
import org.apache.struts2.dispatcher.mapper.ActionMapping;
@@ -167,7 +167,7 @@
private String portletNamespace = null;
- private DispatcherUtils dispatcherUtils;
+ private Dispatcher dispatcherUtils;
/**
* Initialize the portlet with the init parameters from <tt>portlet.xml</tt>
@@ -239,7 +239,7 @@
}
}
- dispatcherUtils = new DispatcherUtils(null);
+ dispatcherUtils = new Dispatcher(null);
}
/**
@@ -287,7 +287,7 @@
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {
LOG.debug("Entering processAction");
- DispatcherUtils.setInstance(dispatcherUtils);
+ Dispatcher.setInstance(dispatcherUtils);
resetActionContext();
try {
serviceAction(request, response, getActionMapping(request),
@@ -365,7 +365,7 @@
}
extraContext.put(ActionContext.LOCALE, locale);
- extraContext.put(StrutsConstants.STRUTS_PORTLET_CONTEXT, getPortletContext());
+ extraContext.put(StrutsStatics.STRUTS_PORTLET_CONTEXT, getPortletContext());
extraContext.put(REQUEST, request);
extraContext.put(RESPONSE, response);
extraContext.put(PORTLET_CONFIG, portletConfig);
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/sitegraph/StrutsConfigRetriever.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/sitegraph/StrutsConfigRetriever.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/sitegraph/StrutsConfigRetriever.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/sitegraph/StrutsConfigRetriever.java Thu Jul 13 16:48:46 2006
@@ -10,7 +10,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.config.StrutsXMLConfigurationProvider;
-import org.apache.struts2.dispatcher.DispatcherUtils;
+import org.apache.struts2.dispatcher.Dispatcher;
import org.apache.struts2.sitegraph.entities.FreeMarkerView;
import org.apache.struts2.sitegraph.entities.JspView;
import org.apache.struts2.sitegraph.entities.VelocityView;
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/sitemesh/TemplatePageFilter.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/sitemesh/TemplatePageFilter.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/sitemesh/TemplatePageFilter.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/sitemesh/TemplatePageFilter.java Thu Jul 13 16:48:46 2006
@@ -21,7 +21,7 @@
import com.opensymphony.module.sitemesh.Page;
import com.opensymphony.module.sitemesh.filter.PageFilter;
import org.apache.struts2.ServletActionContext;
-import org.apache.struts2.dispatcher.DispatcherUtils;
+import org.apache.struts2.dispatcher.Dispatcher;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.config.Configuration;
@@ -83,7 +83,7 @@
if (ctx == null) {
// ok, one isn't associated with the request, so let's get a ThreadLocal one (which will create one if needed)
OgnlValueStack vs = new OgnlValueStack();
- vs.getContext().putAll(DispatcherUtils.getInstance().createContextMap(req, res, null, servletContext));
+ vs.getContext().putAll(Dispatcher.getInstance().createContextMap(req, res, null, servletContext));
ctx = new ActionContext(vs.getContext());
if (ctx.getActionInvocation() == null) {
// put in a dummy ActionSupport so basic functionality still works
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/spring/lifecycle/SpringExternalReferenceResolverSetupListener.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/spring/lifecycle/SpringExternalReferenceResolverSetupListener.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/spring/lifecycle/SpringExternalReferenceResolverSetupListener.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/spring/lifecycle/SpringExternalReferenceResolverSetupListener.java Thu Jul 13 16:48:46 2006
@@ -22,7 +22,7 @@
import com.opensymphony.xwork2.config.entities.PackageConfig;
import org.apache.struts2.dispatcher.DispatcherListener;
-import org.apache.struts2.dispatcher.DispatcherUtils;
+import org.apache.struts2.dispatcher.Dispatcher;
import org.apache.struts2.util.ServletContextAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
@@ -50,13 +50,13 @@
public synchronized void contextDestroyed(ServletContextEvent event) {
Listener l = listeners.get(event.getServletContext());
- DispatcherUtils.removeDispatcherListener(l);
+ Dispatcher.removeDispatcherListener(l);
listeners.remove(event.getServletContext());
}
public synchronized void contextInitialized(ServletContextEvent event) {
Listener l = new Listener(event.getServletContext());
- DispatcherUtils.addDispatcherListener(l);
+ Dispatcher.addDispatcherListener(l);
listeners.put(event.getServletContext(), l);
}
@@ -68,7 +68,7 @@
this.servletContext = ctx;
}
- public void dispatcherInitialized(DispatcherUtils du) {
+ public void dispatcherInitialized(Dispatcher du) {
ApplicationContext appContext = WebApplicationContextUtils
.getWebApplicationContext(servletContext);
@@ -87,7 +87,7 @@
}
- public void dispatcherDestroyed(DispatcherUtils du) {
+ public void dispatcherDestroyed(Dispatcher du) {
}
}
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/ObjectFactoryDestroyable.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/ObjectFactoryDestroyable.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/ObjectFactoryDestroyable.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/ObjectFactoryDestroyable.java Thu Jul 13 16:48:46 2006
@@ -23,7 +23,7 @@
* destroyed.
*
* @see org.apache.struts2.dispatcher.FilterDispatcher
- * @see org.apache.struts2.dispatcher.DispatcherUtils
+ * @see org.apache.struts2.dispatcher.Dispatcher
*/
public interface ObjectFactoryDestroyable {
void destroy();
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/ResolverSetupServletContextListener.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/ResolverSetupServletContextListener.java?rev=421742&r1=421741&r2=421742&view=diff
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/ResolverSetupServletContextListener.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/util/ResolverSetupServletContextListener.java Thu Jul 13 16:48:46 2006
@@ -24,7 +24,7 @@
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
-import org.apache.struts2.dispatcher.DispatcherUtils;
+import org.apache.struts2.dispatcher.Dispatcher;
import org.apache.struts2.dispatcher.DispatcherListener;
import java.util.HashMap;
@@ -46,13 +46,13 @@
public synchronized void contextDestroyed(ServletContextEvent event) {
Listener l = listeners.get(event.getServletContext());
- DispatcherUtils.removeDispatcherListener(l);
+ Dispatcher.removeDispatcherListener(l);
listeners.remove(event.getServletContext());
}
public synchronized void contextInitialized(ServletContextEvent event) {
Listener l = new Listener(event.getServletContext());
- DispatcherUtils.addDispatcherListener(l);
+ Dispatcher.addDispatcherListener(l);
listeners.put(event.getServletContext(), l);
}
@@ -64,7 +64,7 @@
this.servletContext = ctx;
}
- public void dispatcherInitialized(DispatcherUtils du) {
+ public void dispatcherInitialized(Dispatcher du) {
Configuration config = du.getConfigurationManager().getConfiguration();
String key;
PackageConfig packageConfig;
@@ -81,7 +81,7 @@
}
- public void dispatcherDestroyed(DispatcherUtils du) {
+ public void dispatcherDestroyed(Dispatcher du) {
}
}
}