Commits

Anonymous committed 894fc6a
  • Participants
  • Parent commits 1c24dff

Comments (0)

Files changed (441)

src/etc/README.txt

+Thanks for trying out XWork: the foundation for WebWork, Java's most 
+cutting edge web development platform. WebWork is brought to you by
+the OpenSymphony team. You can find out more about WebWork and
+OpenSymphony at http://www.opensymphony.com.
+
+=== Documentation ===
+The documentation can be found in HTML and PDF format in the docs
+directory:
+
+ * HTML format: docs/Documentation.html
+ * PDF format: docs/docs.pdf
+ * Javadocs: docs/api/index.html
+
+This documentation has been generated from the XWork wiki at the time
+of this release. If you are looking for the absolute latest
+documentation, please visit the wiki at:
+
+http://wiki.opensymphony.com/display/XW/Documentation
+
+Note that these docs could include information about features not
+included in this release, so take care when referencing the wiki.
+
+=== Building ===
+If you'd like to build your own version of XWork, we've included
+everything you need in this distribution. The ant script, build.xml,
+contains a "jar" task that you can launch to create your own xwork
+jar. The only thing you must do before hand is set up the proper jars
+in the ANT_HOME/lib directory. These jars are:
+
+ * lib/bootstrap/clover-license.jar
+ * lib/build/clover.jar
+ * lib/build/junit.jar
+
+Once you've copied these three jars in to the ANT_HOME/lib directory,
+simply run "ant jar" to create your own version of XWork.

src/java/com/opensymphony/xwork/Action.java

+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork;
+
+/**
+ * All actions may implement this interface, which exposes
+ * the execute() method. However, as of XWork 1.1, this is
+ * not required and is only here to assist users. You are
+ * free to create POJOs that honor the same contract
+ * defined by this interface without actually implementing
+ * the interface.
+ */
+public interface Action {
+    /**
+     * The action execution was successful. Show result
+     * view to the end user.
+     */
+    public static final String SUCCESS = "success";
+
+    /**
+     * The action execution was successful but do not
+     * show a view. This is useful for actions that are
+     * handling the view in another fashion like redirect.
+     */
+    public static final String NONE = "none";
+
+    /**
+     * The action execution was a failure.
+     * Show an error view, possibly asking the
+     * user to retry entering data.
+     */
+    public static final String ERROR = "error";
+
+    /**
+     * The action execution require more input
+     * in order to succeed.
+     * This result is typically used if a form
+     * handling action has been executed so as
+     * to provide defaults for a form. The
+     * form associated with the handler should be
+     * shown to the end user.
+     * <p/>
+     * This result is also used if the given input
+     * params are invalid, meaning the user
+     * should try providing input again.
+     */
+    public static final String INPUT = "input";
+
+    /**
+     * The action could not execute, since the
+     * user most was not logged in. The login view
+     * should be shown.
+     */
+    public static final String LOGIN = "login";
+
+
+    /**
+     * Where the logic of the action is executed.
+     *
+     * @return a string representing the logical result of the execution.
+     *         See constants in this interface for a list of standard result values.
+     * @throws Exception thrown if a system level exception occurs.
+     *                   Application level exceptions should be handled by returning
+     *                   an error value, such as Action.ERROR.
+     */
+    public String execute() throws Exception;
+}

src/java/com/opensymphony/xwork/ActionChainResult.java

+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork;
+
+import com.opensymphony.xwork.interceptor.component.ComponentInterceptor;
+import com.opensymphony.xwork.util.OgnlValueStack;
+import com.opensymphony.xwork.util.TextParseUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+
+/**
+ * <!-- START SNIPPET: description -->
+ *
+ * This result invokes an entire other action, complete with it's own interceptor stack and result.
+ *
+ * <!-- END SNIPPET: description -->
+ *
+ * <b>This result type takes the following parameters:</b>
+ *
+ * <!-- START SNIPPET: params -->
+ *
+ * <ul>
+ *
+ * <li><b>actionName (default)</b> - the name of the action that will be chained to</li>
+ *
+ * <li><b>namespace</b> - used to determine which namespace the Action is in that we're chaining. If namespace is null,
+ * this defaults to the current namespace</li>
+ *
+ * <li><b>method</b> - used to specify another method on target action to be invoked. 
+ * If null, this defaults to execute method</li>
+ * 
+ * </ul>
+ *
+ * <!-- END SNIPPET: params -->
+ *
+ * <b>Example:</b>
+ *
+ * <pre><!-- START SNIPPET: example -->
+ * &lt;package name="public" extends="webwork-default"&gt;
+ *     &lt;!-- Chain creatAccount to login, using the default parameter --&gt;
+ *     &lt;action name="createAccount" class="..."&gt;
+ *         &lt;result type="chain"&gt;login&lt;/result&gt;
+ *     &lt;/action&gt;
+ *
+ *     &lt;action name="login" class="..."&gt;
+ *         &lt;!-- Chain to another namespace --&gt;
+ *         &lt;result type="chain"&gt;
+ *             &lt;param name="actionName"&gt;dashboard&lt;/param&gt;
+ *             &lt;param name="namespace"&gt;/secure&lt;/param&gt;
+ *         &lt;/result&gt;
+ *     &lt;/action&gt;
+ * &lt;/package&gt;
+ *
+ * &lt;package name="secure" extends="webwork-default" namespace="/secure"&gt;
+ *     &lt;action name="dashboard" class="..."&gt;
+ *         &lt;result&gt;dashboard.jsp&lt;/result&gt;
+ *     &lt;/action&gt;
+ * &lt;/package&gt;
+ * <!-- END SNIPPET: example --></pre>
+ * 
+ * @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
+ */
+public class ActionChainResult implements Result {
+
+    private static final Log log = LogFactory.getLog(ActionChainResult.class);
+    public static final String DEFAULT_PARAM = "actionName";
+    private static final String CHAIN_HISTORY = "CHAIN_HISTORY";
+
+
+    private ActionProxy proxy;
+    private String actionName;
+
+    private String namespace;
+    
+    private String methodName;
+
+
+    public void setActionName(String actionName) {
+        this.actionName = actionName;
+    }
+
+    public void setNamespace(String namespace) {
+        this.namespace = namespace;
+    }
+
+    public void setMethod(String method) {
+        this.methodName = method;
+    }
+    
+    public ActionProxy getProxy() {
+        return proxy;
+    }
+
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+
+        if (!(o instanceof ActionChainResult)) {
+            return false;
+        }
+
+        final ActionChainResult actionChainResult = (ActionChainResult) o;
+
+        if ((actionName != null) ? (!actionName.equals(actionChainResult.actionName)) : (actionChainResult.actionName != null))
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * @param invocation the DefaultActionInvocation calling the action call stack
+     */
+    public void execute(ActionInvocation invocation) throws Exception {
+        // if the finalNamespace wasn't explicitly defined, assume the current one
+        if (this.namespace == null) {
+            this.namespace = invocation.getProxy().getNamespace();
+        }
+
+        OgnlValueStack stack = ActionContext.getContext().getValueStack();
+        String finalNamespace = TextParseUtil.translateVariables(namespace, stack);
+        String finalActionName = TextParseUtil.translateVariables(actionName, stack);
+        String finalMethodName = this.methodName != null 
+                ? TextParseUtil.translateVariables(this.methodName, stack)
+                : null;
+
+        if (isInChainHistory(finalNamespace, finalActionName, finalMethodName)) {
+            throw new XworkException("infinite recursion detected");
+        }
+
+        addToHistory(finalNamespace, finalActionName, finalMethodName);
+
+        HashMap extraContext = new HashMap();
+        extraContext.put(ActionContext.VALUE_STACK, ActionContext.getContext().getValueStack());
+        extraContext.put(ActionContext.PARAMETERS, ActionContext.getContext().getParameters());
+        extraContext.put(ComponentInterceptor.COMPONENT_MANAGER, ActionContext.getContext().get(ComponentInterceptor.COMPONENT_MANAGER));
+        extraContext.put(CHAIN_HISTORY, ActionContext.getContext().get(CHAIN_HISTORY));
+
+        if (log.isDebugEnabled()) {
+            log.debug("Chaining to action " + finalActionName);
+        }
+
+        proxy = ActionProxyFactory.getFactory().createActionProxy(finalNamespace, finalActionName, extraContext);
+        if (null != finalMethodName) {
+            proxy.setMethod(finalMethodName);
+        }
+        proxy.execute();
+    }
+
+    public int hashCode() {
+        return ((actionName != null) ? actionName.hashCode() : 0);
+    }
+
+    private boolean isInChainHistory(String namespace, String actionName, String methodName) {
+        Set chainHistory = (Set) ActionContext.getContext().get(CHAIN_HISTORY);
+
+        if (chainHistory == null) {
+            return false;
+        } else {
+            return chainHistory.contains(makeKey(namespace, actionName, methodName));
+        }
+    }
+
+    private void addToHistory(String namespace, String actionName, String methodName) {
+        Set chainHistory = (Set) ActionContext.getContext().get(CHAIN_HISTORY);
+
+        if (chainHistory == null) {
+            chainHistory = new HashSet();
+        }
+
+        ActionContext.getContext().put(CHAIN_HISTORY, chainHistory);
+
+        chainHistory.add(makeKey(namespace, actionName, methodName));
+    }
+
+    private String makeKey(String namespace, String actionName, String methodName) {
+        if (null == methodName) {
+            return namespace + "/" + actionName;
+        }
+        
+        return namespace + "/" + actionName + "!" + methodName;
+    }
+}

src/java/com/opensymphony/xwork/ActionContext.java

+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork;
+
+import com.opensymphony.xwork.util.OgnlValueStack;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+
+/**
+ * The ActionContext is the context in which an {@link Action} is executed. Each context is basically a
+ * container of objects an action needs for execution like the session, parameters, locale, etc. <p>
+ * <p/>
+ * The ActionContext is thread local which means that values stored in the ActionContext are
+ * unique per thread. See the {@link ThreadLocal} class for more information. The benefit of
+ * this is you don't need to worry about a user specific action context, you just get it:
+ * <p/>
+ * <ul><code>ActionContext context = ActionContext.getContext();</code></ul>
+ * <p/>
+ * Finally, because of the thread local usage you don't need to worry about making your actions thread safe.
+ *
+ * @author Patrick Lightbody
+ * @author Bill Lynch (docs)
+ */
+public class ActionContext implements Serializable {
+	
+	private static final long serialVersionUID = -2764764616805176907L;
+
+	static ThreadLocal actionContext = new ActionContextThreadLocal();
+
+    /**
+     * Constant that indicates the action is running under a "development mode".
+     * This mode provides more feedback that is useful for developers but probably
+     * too verbose/error prone for production.
+     */
+    public static final String DEV_MODE = "__devMode";
+
+    /**
+     * Constant for the name of the action being executed.
+     */
+    public static final String ACTION_NAME = "com.opensymphony.xwork.ActionContext.name";
+
+    /**
+     * Constant for the {@link com.opensymphony.xwork.util.OgnlValueStack OGNL value stack}.
+     */
+    public static final String VALUE_STACK = OgnlValueStack.VALUE_STACK;
+
+    /**
+     * Constant for the action's session.
+     */
+    public static final String SESSION = "com.opensymphony.xwork.ActionContext.session";
+
+    /**
+     * Constant for the action's application context.
+     */
+    public static final String APPLICATION = "com.opensymphony.xwork.ActionContext.application";
+
+    /**
+     * Constant for the action's parameters.
+     */
+    public static final String PARAMETERS = "com.opensymphony.xwork.ActionContext.parameters";
+
+    /**
+     * Constant for the action's locale.
+     */
+    public static final String LOCALE = "com.opensymphony.xwork.ActionContext.locale";
+
+    /**
+     * Constant for the action's type converter.
+     */
+    public static final String TYPE_CONVERTER = "com.opensymphony.xwork.ActionContext.typeConverter";
+
+    /**
+     * Constant for the action's {@link com.opensymphony.xwork.ActionInvocation invocation} context.
+     */
+    public static final String ACTION_INVOCATION = "com.opensymphony.xwork.ActionContext.actionInvocation";
+
+    /**
+     * Constant for the map of type conversion errors.
+     */
+    public static final String CONVERSION_ERRORS = "com.opensymphony.xwork.ActionContext.conversionErrors";
+
+
+    Map context;
+
+
+    /**
+     * Creates a new ActionContext initialized with another context.
+     *
+     * @param context a context map.
+     */
+    public ActionContext(Map context) {
+        this.context = context;
+    }
+
+
+    /**
+     * Sets the action invocation (the execution state).
+     *
+     * @param actionInvocation the action execution state.
+     */
+    public void setActionInvocation(ActionInvocation actionInvocation) {
+        put(ACTION_INVOCATION, actionInvocation);
+    }
+
+    /**
+     * Gets the action invocation (the execution state).
+     *
+     * @return the action invocation (the execution state).
+     */
+    public ActionInvocation getActionInvocation() {
+        return (ActionInvocation) get(ACTION_INVOCATION);
+    }
+
+    /**
+     * Sets the action's application context.
+     *
+     * @param application the action's application context.
+     */
+    public void setApplication(Map application) {
+        put(APPLICATION, application);
+    }
+
+    /**
+     * Returns a Map of the ServletContext when in a servlet environment or a generic application level Map otherwise.
+     *
+     * @return a Map of ServletContext or generic application level Map
+     */
+    public Map getApplication() {
+        return (Map) get(APPLICATION);
+    }
+
+    /**
+     * Sets the action context for the current thread.
+     *
+     * @param context the action context.
+     */
+    public static void setContext(ActionContext context) {
+        actionContext.set(context);
+    }
+
+    /**
+     * Returns the ActionContext specific to the current thread.
+     *
+     * @return the ActionContext for the current thread, is never <tt>null</tt>.
+     */
+    public static ActionContext getContext() {
+        ActionContext context = (ActionContext) actionContext.get();
+
+        if (context == null) {
+            OgnlValueStack vs = new OgnlValueStack();
+            context = new ActionContext(vs.getContext());
+            setContext(context);
+        }
+
+        return context;
+    }
+
+    /**
+     * Sets the action's context map.
+     *
+     * @param contextMap the context map.
+     */
+    public void setContextMap(Map contextMap) {
+        getContext().context = contextMap;
+    }
+
+    /**
+     * Gets the context map.
+     *
+     * @return the context map.
+     */
+    public Map getContextMap() {
+        return context;
+    }
+
+    /**
+     * Sets conversion errors which occurred when executing the action.
+     *
+     * @param conversionErrors a Map of errors which occurred when executing the action.
+     */
+    public void setConversionErrors(Map conversionErrors) {
+        put(CONVERSION_ERRORS, conversionErrors);
+    }
+
+    /**
+     * Gets the map of conversion errors which occurred when executing the action.
+     *
+     * @return the map of conversion errors which occurred when executing the action or an empty map if
+     *         there were no errors.
+     */
+    public Map getConversionErrors() {
+        Map errors = (Map) get(CONVERSION_ERRORS);
+
+        if (errors == null) {
+            errors = new HashMap();
+            setConversionErrors(errors);
+        }
+
+        return errors;
+    }
+
+    /**
+     * Sets the Locale for the current action.
+     *
+     * @param locale the Locale for the current action.
+     */
+    public void setLocale(Locale locale) {
+        put(LOCALE, locale);
+    }
+
+    /**
+     * Gets the Locale of the current action. If no locale was ever specified the platform's
+     * {@link java.util.Locale#getDefault() default locale} is used.
+     *
+     * @return the Locale of the current action.
+     */
+    public Locale getLocale() {
+        Locale locale = (Locale) get(LOCALE);
+
+        if (locale == null) {
+            locale = Locale.getDefault();
+            setLocale(locale);
+        }
+
+        return locale;
+    }
+
+    /**
+     * Sets the name of the current Action in the ActionContext.
+     *
+     * @param name the name of the current action.
+     */
+    public void setName(String name) {
+        put(ACTION_NAME, name);
+    }
+
+    /**
+     * Gets the name of the current Action.
+     *
+     * @return the name of the current action.
+     */
+    public String getName() {
+        return (String) get(ACTION_NAME);
+    }
+
+    /**
+     * Sets the action parameters.
+     *
+     * @param parameters the parameters for the current action.
+     */
+    public void setParameters(Map parameters) {
+        put(PARAMETERS, parameters);
+    }
+
+    /**
+     * Returns a Map of the HttpServletRequest parameters when in a servlet environment or a generic Map of
+     * parameters otherwise.
+     *
+     * @return a Map of HttpServletRequest parameters or a multipart map when in a servlet environment, or a
+     *         generic Map of parameters otherwise.
+     */
+    public Map getParameters() {
+        return (Map) get(PARAMETERS);
+    }
+
+    /**
+     * Sets a map of action session values.
+     *
+     * @param session  the session values.
+     */
+    public void setSession(Map session) {
+        put(SESSION, session);
+    }
+
+    /**
+     * Gets the Map of HttpSession values when in a servlet environment or a generic session map otherwise.
+     *
+     * @return the Map of HttpSession values when in a servlet environment or a generic session map otherwise.
+     */
+    public Map getSession() {
+        return (Map) get(SESSION);
+    }
+
+    /**
+     * Sets the OGNL value stack.
+     *
+     * @param stack the OGNL value stack.
+     */
+    public void setValueStack(OgnlValueStack stack) {
+        put(VALUE_STACK, stack);
+    }
+
+    /**
+     * Gets the OGNL value stack.
+     *
+     * @return the OGNL value stack.
+     */
+    public OgnlValueStack getValueStack() {
+        return (OgnlValueStack) get(VALUE_STACK);
+    }
+
+    /**
+     * Returns a value that is stored in the current ActionContext by doing a lookup using the value's key.
+     *
+     * @param key the key used to find the value.
+     * @return the value that was found using the key or <tt>null</tt> if the key was not found.
+     */
+    public Object get(Object key) {
+        return context.get(key);
+    }
+
+    /**
+     * Stores a value in the current ActionContext. The value can be looked up using the key.
+     *
+     * @param key   the key of the value.
+     * @param value the value to be stored.
+     */
+    public void put(Object key, Object value) {
+        context.put(key, value);
+    }
+
+
+    private static class ActionContextThreadLocal extends ThreadLocal {
+        protected Object initialValue() {
+            OgnlValueStack vs = new OgnlValueStack();
+
+            return new ActionContext(vs.getContext());
+        }
+    }
+}

src/java/com/opensymphony/xwork/ActionInvocation.java

+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork;
+
+import com.opensymphony.xwork.interceptor.PreResultListener;
+import com.opensymphony.xwork.util.OgnlValueStack;
+
+import java.io.Serializable;
+
+
+/**
+ * An ActionInvocation represents the execution state of an Action. It holds the Interceptors and the Action instance.
+ * By repeated re-entrant execution of the invoke() method, initially by the ActionProxy, then by the Interceptors, the
+ * Interceptors are all executed, and then the Action and the Result.
+ *
+ * @author Jason Carreira
+ * @see com.opensymphony.xwork.ActionProxy
+ */
+public interface ActionInvocation extends Serializable {
+
+    /**
+     * Get the Action associated with this ActionInvocation
+     */
+    Object getAction();
+
+    /**
+     * @return whether this ActionInvocation has executed before. This will be set after the Action and the Result have
+     *         executed.
+     */
+    boolean isExecuted();
+
+    /**
+     * Gets the ActionContext associated with this ActionInvocation. The ActionProxy is
+     * responsible for setting this ActionContext onto the ThreadLocal before invoking
+     * the ActionInvocation and resetting the old ActionContext afterwards.
+     */
+    ActionContext getInvocationContext();
+
+    /**
+     * Get the ActionProxy holding this ActionInvocation
+     */
+    ActionProxy getProxy();
+
+    /**
+     * If the ActionInvocation has been executed before and the Result is an instance of ActionChainResult, this method
+     * will walk down the chain of ActionChainResults until it finds a non-chain result, which will be returned. If the
+     * ActionInvocation's result has not been executed before, the Result instance will be created and populated with
+     * the result params.
+     *
+     * @return a Result instance
+     */
+    Result getResult() throws Exception;
+
+    /**
+     * Gets the result code returned from this ActionInvocation
+     */
+    String getResultCode();
+
+    /**
+     * Sets the result code, possibly overriding the one returned by the
+     * action.
+     * <p/>
+     * <p/>
+     * The "intended" purpose of this method is to allow PreResultListeners to
+     * override the result code returned by the Action.
+     * </p>
+     * <p/>
+     * <p/>
+     * If this method is used before the Action executes, the Action's returned
+     * result code will override what was set.  However the Action could (if
+     * specifically coded to do so) inspect the ActionInvocation to see that
+     * someone "upstream" (e.g. an Interceptor) had suggested a value as the
+     * result, and it could therefore return the same value itself.
+     * </p>
+     * <p/>
+     * <p/>
+     * If this method is called between the Action execution and the Result
+     * execution, then the value set here will override the result code the
+     * action had returned.   Creating an Interceptor that implements
+     * PreResultListener will give you this oportunity.
+     * </p>
+     * <p/>
+     * <p/>
+     * If this method is called after the Result has been executed, it will
+     * have the effect of raising an exception.
+     * </p>
+     *
+     * @throws IllegalStateException if called after the Result has been
+     *                               executed.
+     * @see #isExecuted()
+     */
+    void setResultCode(String resultCode);
+
+    /**
+     * @return the ValueStack associated with this ActionInvocation
+     */
+    OgnlValueStack getStack();
+
+    /**
+     * Register a com.opensymphony.xwork.interceptor.PreResultListener to be notified after the Action is executed and
+     * before the Result is executed. The ActionInvocation implementation must guarantee that listeners will be called in
+     * the order in which they are registered. Listener registration and execution does not need to be thread-safe.
+     */
+    void addPreResultListener(PreResultListener listener);
+
+    /**
+     * Invokes the next step in processing this ActionInvocation. If there are more Interceptors, this will call the next
+     * one. If Interceptors choose not to short-circuit ActionInvocation processing and return their own return code,
+     * they will call invoke() to allow the next Interceptor to execute. If there are no more Interceptors to be applied,
+     * the Action is executed. If the ActionProxy getExecuteResult() method returns true, the Result is also executed.
+     */
+    String invoke() throws Exception;
+
+    /**
+     * Invokes only the action (not interceptors or results). This is useful in rare situations where advanced usage
+     * with the interceptor/action/result workflow is being manipulated for certain functionality. Specifically,
+     * WebWork's execAndWait interceptor takes advantage of this method.
+     */
+    String invokeActionOnly() throws Exception;
+}

src/java/com/opensymphony/xwork/ActionProxy.java

+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork;
+
+import com.opensymphony.xwork.config.entities.ActionConfig;
+
+
+/**
+ * ActionProxy is an extra layer between XWork and the action so that different proxies are possible.
+ * <p/>
+ * An example of this would be a remote proxy, where the layer between XWork and the action might be RMI or SOAP.
+ *
+ * @author Jason Carreira
+ *         Created Jun 9, 2003 11:27:55 AM
+ */
+public interface ActionProxy {
+
+    /**
+     * @return the Action instance for this Proxy
+     */
+    Object getAction();
+
+    /**
+     * @return the alias name this ActionProxy is mapped to
+     */
+    String getActionName();
+
+    /**
+     * @return the ActionConfig this ActionProxy is built from
+     */
+    ActionConfig getConfig();
+
+    /**
+     * Sets whether this ActionProxy should also execute the Result after executing the Action
+     *
+     * @param executeResult
+     */
+    void setExecuteResult(boolean executeResult);
+
+    /**
+     * @return the status of whether the ActionProxy is set to execute the Result after the Action is executed
+     */
+    boolean getExecuteResult();
+
+    /**
+     * @return the ActionInvocation associated with this ActionProxy
+     */
+    ActionInvocation getInvocation();
+
+    /**
+     * @return the namespace the ActionConfig for this ActionProxy is mapped to
+     */
+    String getNamespace();
+
+    /**
+     * Execute this ActionProxy. This will set the ActionContext from the ActionInvocation into the ActionContext
+     * ThreadLocal before invoking the ActionInvocation, then set the old ActionContext back into the ThreadLocal.
+     *
+     * @return the result code returned from executing the ActionInvocation
+     * @throws Exception
+     * @see ActionInvocation
+     */
+    String execute() throws Exception;
+
+    /**
+     * Sets the method to execute for the action invocation. If no method is specified, the method provided by
+     * in the action's configuration will be used.
+     *
+     * @param method the string name of the method to invoke
+     */
+    void setMethod(String method);
+
+    /**
+     * Returns the method to execute, or null if no method has been specified (meaning "execute" will be invoked)
+     */
+    String getMethod();
+}

src/java/com/opensymphony/xwork/ActionProxyFactory.java

+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork;
+
+import java.util.Map;
+
+
+/**
+ * The ActionProxyFactory is used to create ActionProxies to be executed. It is the entry point to XWork that is used
+ * by a dispatcher to create an ActionProxy to execute for a particular namespace and action name.
+ *
+ * @author Jason Carreira
+ *         Created Jun 15, 2003 5:18:30 PM
+ * @see DefaultActionProxyFactory
+ */
+public abstract class ActionProxyFactory {
+
+    static ActionProxyFactory factory = new DefaultActionProxyFactory();
+
+
+    /**
+     * Set the ActionProxyFactory implementation to use. If no instance is set, a new DefaultActionProxyFactory is used.
+     *
+     * @param factory
+     */
+    public static void setFactory(ActionProxyFactory factory) {
+        ActionProxyFactory.factory = factory;
+    }
+
+    public static ActionProxyFactory getFactory() {
+        return factory;
+    }
+
+    /**
+     * Used by an ActionProxy or ActionProxyFactory to create an ActionInvocation to associate with an ActionProxy
+     * as part of creating an ActionProxy. Client code should not need to call the createActionInvocation methods.
+     *
+     * @param actionProxy
+     * @param extraContext
+     * @return ActionInvocation
+     * @throws Exception
+     */
+    public abstract ActionInvocation createActionInvocation(ActionProxy actionProxy, Map extraContext) throws Exception;
+
+    /**
+     * Used by an ActionProxy or ActionProxyFactory to create an ActionInvocation to associate with an ActionProxy
+     * as part of creating an ActionProxy. Client code should not need to call the createActionInvocation methods.
+     *
+     * @param actionProxy
+     * @return ActionInvocation
+     * @throws Exception
+     */
+    public abstract ActionInvocation createActionInvocation(ActionProxy actionProxy) throws Exception;
+
+    /**
+     * Used by an ActionProxy or ActionProxyFactory to create an ActionInvocation to associate with an ActionProxy
+     * as part of creating an ActionProxy. Client code should not need to call the createActionInvocation methods.
+     *
+     * @param actionProxy
+     * @param extraContext
+     * @param pushAction   tells whether the Action should be pushed onto the ValueStack
+     * @return ActionInvocation
+     * @throws Exception
+     */
+    public abstract ActionInvocation createActionInvocation(ActionProxy actionProxy, Map extraContext, boolean pushAction) throws Exception;
+
+    /**
+     * Creates an ActionProxy for the given namespace and action name by looking up the configuration. The ActionProxy
+     * should be fully initialized when it is returned, including having an ActionInvocation instance associated.
+     *
+     * @param namespace    the namespace of the action
+     * @param actionName
+     * @param extraContext a Map of extra parameters to be provided to the ActionProxy
+     * @return ActionProxy
+     * @throws Exception
+     */
+    public abstract ActionProxy createActionProxy(String namespace, String actionName, Map extraContext) throws Exception;
+
+    /**
+     * Creates an ActionProxy for the given namespace and action name by looking up the configuration. The ActionProxy
+     * should be fully initialized when it is returned, including having an ActionInvocation instance associated.
+     *
+     * @param namespace     the namespace of the action
+     * @param actionName
+     * @param extraContext  a Map of extra parameters to be provided to the ActionProxy
+     * @param executeResult flag which tells whether the result should be executed after the action
+     * @param cleanupContext
+     * @return ActionProxy
+     * @throws Exception
+     */
+    public abstract ActionProxy createActionProxy(String namespace, String actionName, Map extraContext, boolean executeResult, boolean cleanupContext) throws Exception;
+}

src/java/com/opensymphony/xwork/ActionSupport.java

+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork;
+
+import com.opensymphony.xwork.util.OgnlValueStack;
+import com.uwyn.rife.continuations.ContinuableObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.Serializable;
+import java.util.*;
+
+
+/**
+ * Provides a default implementation for the most common actions.
+ * See the documentation for all the interfaces this class implements for more detailed information.
+ */
+public class ActionSupport implements Action, Validateable, ValidationAware, TextProvider, LocaleProvider, Serializable, ContinuableObject {
+
+    protected transient static final Log LOG = LogFactory.getLog(ActionSupport.class);
+
+    private transient final TextProvider textProvider = new TextProviderSupport(getClass(), this);
+    private final ValidationAwareSupport validationAware = new ValidationAwareSupport();
+
+
+    public void setActionErrors(Collection errorMessages) {
+        validationAware.setActionErrors(errorMessages);
+    }
+
+    public Collection getActionErrors() {
+        return validationAware.getActionErrors();
+    }
+
+    public void setActionMessages(Collection messages) {
+        validationAware.setActionMessages(messages);
+    }
+
+    public Collection getActionMessages() {
+        return validationAware.getActionMessages();
+    }
+
+    /**
+     * @deprecated Use {@link #getActionErrors()}.
+     */
+    public Collection getErrorMessages() {
+        return getActionErrors();
+    }
+
+    /**
+     * @deprecated Use {@link #getFieldErrors()}.
+     */
+    public Map getErrors() {
+        return getFieldErrors();
+    }
+
+    public void setFieldErrors(Map errorMap) {
+        validationAware.setFieldErrors(errorMap);
+    }
+
+    public Map getFieldErrors() {
+        return validationAware.getFieldErrors();
+    }
+
+    public Locale getLocale() {
+        return ActionContext.getContext().getLocale();
+    }
+
+    public boolean hasKey(String key) {
+    	return textProvider.hasKey(key);
+    }
+    
+    public String getText(String aTextName) {
+        return textProvider.getText(aTextName);
+    }
+
+    public String getText(String aTextName, String defaultValue) {
+        return textProvider.getText(aTextName, defaultValue);
+    }
+
+    public String getText(String aTextName, String defaultValue, String obj) {
+        return textProvider.getText(aTextName, defaultValue, obj);
+    }
+
+    public String getText(String aTextName, List args) {
+        return textProvider.getText(aTextName, args);
+    }
+
+    public String getText(String key, String[] args) {
+        return textProvider.getText(key, args);
+    }
+
+    public String getText(String aTextName, String defaultValue, List args) {
+        return textProvider.getText(aTextName, defaultValue, args);
+    }
+
+    public String getText(String key, String defaultValue, String[] args) {
+        return textProvider.getText(key, defaultValue, args);
+    }
+
+    public String getText(String key, String defaultValue, List args, OgnlValueStack stack) {
+        return textProvider.getText(key, defaultValue, args, stack);
+    }
+
+    public String getText(String key, String defaultValue, String[] args, OgnlValueStack stack) {
+        return textProvider.getText(key, defaultValue, args, stack);
+    }
+
+    public ResourceBundle getTexts() {
+        return textProvider.getTexts();
+    }
+
+    public ResourceBundle getTexts(String aBundleName) {
+        return textProvider.getTexts(aBundleName);
+    }
+
+    public void addActionError(String anErrorMessage) {
+        validationAware.addActionError(anErrorMessage);
+    }
+
+    public void addActionMessage(String aMessage) {
+        validationAware.addActionMessage(aMessage);
+    }
+
+    public void addFieldError(String fieldName, String errorMessage) {
+        validationAware.addFieldError(fieldName, errorMessage);
+    }
+
+    public String doInput() throws Exception {
+        return INPUT;
+    }
+
+    public String doDefault() throws Exception {
+        return SUCCESS;
+    }
+
+    /**
+     * A default implementation that does nothing an returns "success".
+     * <p/>
+     * Subclasses should override this method to provide their business logic.
+     * <p/>
+     * See also {@link com.opensymphony.xwork.Action#execute()}.
+     *
+     * @return returns {@link #SUCCESS}
+     * @throws Exception  can be thrown by subclasses.
+     */
+    public String execute() throws Exception {
+        return SUCCESS;
+    }
+
+    public boolean hasActionErrors() {
+        return validationAware.hasActionErrors();
+    }
+
+    public boolean hasActionMessages() {
+        return validationAware.hasActionMessages();
+    }
+
+    public boolean hasErrors() {
+        return validationAware.hasErrors();
+    }
+
+    public boolean hasFieldErrors() {
+        return validationAware.hasFieldErrors();
+    }
+
+    /**
+     * Clears all errors and messages. Useful for Continuations and other situations
+     * where you might want to clear parts of the state on the same action.
+     */
+    public void clearErrorsAndMessages() {
+        validationAware.clearErrorsAndMessages();
+    }
+
+    /**
+     * A default implementation that validates nothing.
+     * Subclasses should override this method to provide validations.
+     */
+    public void validate() {
+    }
+
+    public Object clone() throws CloneNotSupportedException {
+        return super.clone();
+    }
+
+    /**
+     * <!-- START SNIPPET: pause-method -->
+     * Stops the action invocation immediately (by throwing a PauseException) and causes the action invocation to return
+     * the specified result, such as {@link #SUCCESS}, {@link #INPUT}, etc.
+     * <p/>
+     *
+     * The next time this action is invoked (and using the same continuation ID), the method will resume immediately
+     * after where this method was called, with the entire call stack in the execute method restored.
+     * <p/>
+     *
+     * Note: this method can <b>only</b> be called within the {@link #execute()} method.
+     * <!-- END SNIPPET: pause-method -->
+     *
+     * @param result the result to return - the same type of return value in the {@link #execute()} method.
+     */
+    public void pause(String result) {
+    }
+
+}

src/java/com/opensymphony/xwork/DefaultActionInvocation.java

+/*
+ * Copyright (c) 2002-2006 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.xwork;
+
+import com.opensymphony.xwork.config.entities.ActionConfig;
+import com.opensymphony.xwork.config.entities.ResultConfig;
+import com.opensymphony.xwork.config.entities.InterceptorMapping;
+import com.opensymphony.xwork.interceptor.PreResultListener;
+import com.opensymphony.xwork.util.OgnlValueStack;
+import com.opensymphony.xwork.util.XWorkContinuationConfig;
+import com.uwyn.rife.continuations.ContinuableObject;
+import com.uwyn.rife.continuations.ContinuationConfig;
+import com.uwyn.rife.continuations.ContinuationContext;
+import com.uwyn.rife.continuations.ContinuationManager;
+import com.uwyn.rife.continuations.exceptions.PauseException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.*;
+
+
+/**
+ * The Default ActionInvocation implementation
+ *
+ * @author Rainer Hermanns
+ * @version $Revision$
+ * @see com.opensymphony.xwork.DefaultActionProxy
+ */
+public class DefaultActionInvocation implements ActionInvocation {
+	
+	private static final long serialVersionUID = 3857082261177147501L;
+
+	public static ContinuationManager m;
+
+    static {
+        if (ContinuationConfig.getInstance() != null) {
+            m = new ContinuationManager();
+        }
+    }
+
+    private static final Log LOG = LogFactory.getLog(DefaultActionInvocation.class);
+
+    protected Object action;
+    protected ActionProxy proxy;
+    protected List preResultListeners;
+    protected Map extraContext;
+    protected ActionContext invocationContext;
+    protected Iterator interceptors;
+    protected OgnlValueStack stack;
+    protected Result result;
+    protected String resultCode;
+    protected boolean executed = false;
+    protected boolean pushAction = true;
+
+    protected DefaultActionInvocation(ActionProxy proxy) throws Exception {
+        this(proxy, null);
+    }
+
+    protected DefaultActionInvocation(ActionProxy proxy, Map extraContext) throws Exception {
+        this(proxy, extraContext, true);
+    }
+
+    protected DefaultActionInvocation(ActionProxy proxy, Map extraContext, boolean pushAction) throws Exception {
+        this.proxy = proxy;
+        this.extraContext = extraContext;
+        this.pushAction = pushAction;
+        init();
+    }
+
+    public Object getAction() {
+        return action;
+    }
+
+    public boolean isExecuted() {
+        return executed;
+    }
+
+    public ActionContext getInvocationContext() {
+        return invocationContext;
+    }
+
+    public ActionProxy getProxy() {
+        return proxy;
+    }
+
+    /**
+     * If the DefaultActionInvocation has been executed before and the Result is an instance of ActionChainResult, this method
+     * will walk down the chain of ActionChainResults until it finds a non-chain result, which will be returned. If the
+     * DefaultActionInvocation's result has not been executed before, the Result instance will be created and populated with
+     * the result params.
+     *
+     * @return a Result instance
+     * @throws Exception
+     */
+    public Result getResult() throws Exception {
+        Result returnResult = result;
+
+        // If we've chained to other Actions, we need to find the last result
+        while (returnResult instanceof ActionChainResult) {
+            ActionProxy aProxy = ((ActionChainResult) returnResult).getProxy();
+
+            if (aProxy != null) {
+                Result proxyResult = aProxy.getInvocation().getResult();
+
+                if ((proxyResult != null) && (aProxy.getExecuteResult())) {
+                    returnResult = proxyResult;
+                } else {
+                    break;
+                }
+            } else {
+                break;
+            }
+        }
+
+        return returnResult;
+    }
+
+    public String getResultCode() {
+        return resultCode;
+    }
+
+    public void setResultCode(String resultCode) {
+        if (isExecuted())
+            throw new IllegalStateException("Result has already been executed.");
+
+        this.resultCode = resultCode;
+    }
+
+
+    public OgnlValueStack getStack() {
+        return stack;
+    }
+
+    /**
+     * Register a com.opensymphony.xwork.interceptor.PreResultListener to be notified after the Action is executed and before the
+     * Result is executed. The ActionInvocation implementation must guarantee that listeners will be called in the order
+     * in which they are registered. Listener registration and execution does not need to be thread-safe.
+     *
+     * @param listener
+     */