Author: germuska Date: Tue Mar 15 18:57:04 2005 New Revision: 157634 URL: http://svn.apache.org/viewcvs?view=rev&rev=157634 Log: Introduce ActionCommand interface and ActionCommandBase class, and adapt all relevant command implementations to extend ActionCommandBase.
Added: struts/core/trunk/src/share/org/apache/struts/chain/commands/ActionCommand.java struts/core/trunk/src/share/org/apache/struts/chain/commands/ActionCommandBase.java Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractAuthorizeAction.java struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractCreateAction.java struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractCreateActionForm.java struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractExceptionHandler.java struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractExecuteAction.java struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractPerformForward.java struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractPerformInclude.java struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractPopulateActionForm.java struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractRequestNoCache.java struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectAction.java struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectForward.java struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectInput.java struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectLocale.java struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectModule.java struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSetContentType.java struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractValidateActionForm.java struts/core/trunk/src/share/org/apache/struts/chain/commands/ExceptionCatcher.java struts/core/trunk/src/share/org/apache/struts/chain/commands/ExecuteCommand.java struts/core/trunk/src/share/org/apache/struts/chain/commands/SelectInclude.java Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractAuthorizeAction.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractAuthorizeAction.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractAuthorizeAction.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractAuthorizeAction.java Tue Mar 15 18:57:04 2005 @@ -17,8 +17,6 @@ package org.apache.struts.chain.commands; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.chain.contexts.ActionContext; @@ -34,7 +32,7 @@ * @version $Rev$ $Date$ */ -public abstract class AbstractAuthorizeAction implements Command { +public abstract class AbstractAuthorizeAction extends ActionCommandBase { // ------------------------------------------------------ Instance Variables @@ -55,9 +53,7 @@ * @return <code>false</code> if the user is authorized for the selected * action, else <code>true</code> to abort processing. */ - public boolean execute(Context context) throws Exception { - - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { // Retrieve ActionConfig ActionConfig actionConfig = actionCtx.getActionConfig(); Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractCreateAction.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractCreateAction.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractCreateAction.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractCreateAction.java Tue Mar 15 18:57:04 2005 @@ -17,8 +17,6 @@ package org.apache.struts.chain.commands; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.action.Action; @@ -34,7 +32,7 @@ * @version $Rev$ $Date$ */ -public abstract class AbstractCreateAction implements Command { +public abstract class AbstractCreateAction extends ActionCommandBase { // ------------------------------------------------------ Instance Variables @@ -51,8 +49,7 @@ * * @return <code>false</code> so that processing continues */ - public boolean execute(Context context) throws Exception { - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { // Skip processing if the current request is not valid Boolean valid = actionCtx.getFormValid(); Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractCreateActionForm.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractCreateActionForm.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractCreateActionForm.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractCreateActionForm.java Tue Mar 15 18:57:04 2005 @@ -18,8 +18,6 @@ import org.apache.commons.beanutils.DynaBean; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.action.ActionForm; @@ -36,7 +34,7 @@ * @version $Id$ */ -public abstract class AbstractCreateActionForm implements Command { +public abstract class AbstractCreateActionForm extends ActionCommandBase { // ------------------------------------------------------ Instance Variables @@ -55,9 +53,7 @@ * * @return <code>false</code> so that processing continues */ - public boolean execute(Context context) throws Exception { - - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { // Is there a form bean associated with this ActionConfig? ActionConfig actionConfig = actionCtx.getActionConfig(); Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractExceptionHandler.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractExceptionHandler.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractExceptionHandler.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractExceptionHandler.java Tue Mar 15 18:57:04 2005 @@ -17,8 +17,6 @@ package org.apache.struts.chain.commands; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.chain.contexts.ActionContext; @@ -36,7 +34,7 @@ * @version $Rev$ $Date$ */ -public abstract class AbstractExceptionHandler implements Command { +public abstract class AbstractExceptionHandler extends ActionCommandBase { // ------------------------------------------------------ Instance Variables @@ -62,8 +60,8 @@ * @return <code>false</code> if a <code>ForwardConfig</code> is returned, * else <code>true</code> to complete processing */ - public boolean execute(Context context) throws Exception { - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { + // Look up the exception that was thrown Exception exception = actionCtx.getException(); if (exception == null) { Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractExecuteAction.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractExecuteAction.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractExecuteAction.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractExecuteAction.java Tue Mar 15 18:57:04 2005 @@ -17,8 +17,6 @@ package org.apache.struts.chain.commands; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.chain.contexts.ActionContext; @@ -34,7 +32,7 @@ * @version $Rev$ $Date$ */ -public abstract class AbstractExecuteAction implements Command { +public abstract class AbstractExecuteAction extends ActionCommandBase { // ---------------------------------------------------------- Public Methods @@ -51,9 +49,7 @@ * * @return <code>false</code> so that processing continues */ - public boolean execute(Context context) throws Exception { - - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { // Skip processing if the current request is not valid Boolean valid = actionCtx.getFormValid(); Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractPerformForward.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractPerformForward.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractPerformForward.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractPerformForward.java Tue Mar 15 18:57:04 2005 @@ -17,8 +17,6 @@ package org.apache.struts.chain.commands; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.struts.chain.contexts.ActionContext; import org.apache.struts.config.ForwardConfig; @@ -31,7 +29,7 @@ * @version $Rev$ $Date$ */ -public abstract class AbstractPerformForward implements Command { +public abstract class AbstractPerformForward extends ActionCommandBase { @@ -47,8 +45,7 @@ * * @return <code>true</code> so that processing completes */ - public boolean execute(Context context) throws Exception { - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { // Is there a ForwardConfig to be performed? ForwardConfig forwardConfig = actionCtx.getForwardConfig(); if (forwardConfig == null) { Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractPerformInclude.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractPerformInclude.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractPerformInclude.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractPerformInclude.java Tue Mar 15 18:57:04 2005 @@ -17,8 +17,6 @@ package org.apache.struts.chain.commands; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.struts.chain.contexts.ActionContext; import org.apache.struts.config.ModuleConfig; @@ -31,7 +29,7 @@ * @version $Rev$ $Date$ */ -public abstract class AbstractPerformInclude implements Command { +public abstract class AbstractPerformInclude extends ActionCommandBase { // ---------------------------------------------------------- Public Methods @@ -44,10 +42,8 @@ * * @return <code>true</code> so that processing completes */ - public boolean execute(Context context) throws Exception { + public boolean execute(ActionContext actionCtx) throws Exception { - // Retrieve module config instance - ActionContext actionCtx = (ActionContext) context; ModuleConfig moduleConfig = actionCtx.getModuleConfig(); // Is there an include to be performed? Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractPopulateActionForm.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractPopulateActionForm.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractPopulateActionForm.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractPopulateActionForm.java Tue Mar 15 18:57:04 2005 @@ -19,8 +19,6 @@ import java.util.Map; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.struts.Globals; import org.apache.struts.action.ActionForm; import org.apache.struts.chain.contexts.ActionContext; @@ -34,7 +32,7 @@ * @version $Rev$ $Date$ */ -public abstract class AbstractPopulateActionForm implements Command { +public abstract class AbstractPopulateActionForm extends ActionCommandBase { // ---------------------------------------------------------- Public Methods @@ -47,9 +45,7 @@ * * @return <code>false</code> so that processing continues */ - public boolean execute(Context context) throws Exception { - - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { // Is there a form bean for this request? ActionForm actionForm = actionCtx.getActionForm(); Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractRequestNoCache.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractRequestNoCache.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractRequestNoCache.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractRequestNoCache.java Tue Mar 15 18:57:04 2005 @@ -17,8 +17,6 @@ package org.apache.struts.chain.commands; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.struts.chain.contexts.ActionContext; import org.apache.struts.config.ModuleConfig; @@ -31,7 +29,7 @@ * @version $Rev$ $Date$ */ -public abstract class AbstractRequestNoCache implements Command { +public abstract class AbstractRequestNoCache extends ActionCommandBase { // ---------------------------------------------------------- Public Methods @@ -45,10 +43,9 @@ * * @return <code>false</code> so that processing continues */ - public boolean execute(Context context) throws Exception { + public boolean execute(ActionContext actionCtx) throws Exception { // Retrieve the ModuleConfig instance - ActionContext actionCtx = (ActionContext) context; ModuleConfig moduleConfig = actionCtx.getModuleConfig(); // If the module is configured for no caching, request no caching Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectAction.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectAction.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectAction.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectAction.java Tue Mar 15 18:57:04 2005 @@ -17,8 +17,6 @@ package org.apache.struts.chain.commands; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.struts.chain.contexts.ActionContext; import org.apache.struts.config.ActionConfig; import org.apache.struts.config.ModuleConfig; @@ -32,7 +30,7 @@ * @version $Rev$ $Date$ */ -public abstract class AbstractSelectAction implements Command { +public abstract class AbstractSelectAction extends ActionCommandBase { @@ -51,8 +49,7 @@ * * @return <code>false</code> so that processing continues */ - public boolean execute(Context context) throws Exception { - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { // Identify the matching path for this request String path = getPath(actionCtx); Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectForward.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectForward.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectForward.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectForward.java Tue Mar 15 18:57:04 2005 @@ -17,8 +17,6 @@ package org.apache.struts.chain.commands; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.chain.contexts.ActionContext; @@ -35,7 +33,7 @@ * @version $Rev$ $Date$ */ -public abstract class AbstractSelectForward implements Command { +public abstract class AbstractSelectForward extends ActionCommandBase { // ------------------------------------------------------ Instance Variables @@ -54,8 +52,7 @@ * * @return <code>false</code> so that processing continues */ - public boolean execute(Context context) throws Exception { - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { // Skip processing if the current request is not valid Boolean valid = actionCtx.getFormValid(); Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectInput.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectInput.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectInput.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectInput.java Tue Mar 15 18:57:04 2005 @@ -17,8 +17,6 @@ package org.apache.struts.chain.commands; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.chain.contexts.ActionContext; @@ -35,7 +33,7 @@ * @version $Rev$ $Date$ */ -public abstract class AbstractSelectInput implements Command { +public abstract class AbstractSelectInput extends ActionCommandBase { // ------------------------------------------------------ Instance Variables @@ -54,9 +52,7 @@ * * @return <code>false</code> so that processing continues */ - public boolean execute(Context context) throws Exception { - - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { // Skip processing if the current request is valid Boolean valid = actionCtx.getFormValid(); Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectLocale.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectLocale.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectLocale.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectLocale.java Tue Mar 15 18:57:04 2005 @@ -19,8 +19,6 @@ import java.util.Locale; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.chain.contexts.ActionContext; @@ -34,7 +32,7 @@ * @version $Rev$ $Date$ */ -public abstract class AbstractSelectLocale implements Command { +public abstract class AbstractSelectLocale extends ActionCommandBase { private static final Log log = LogFactory.getLog(AbstractSelectLocale.class); @@ -48,9 +46,7 @@ * * @return <code>false</code> so that processing continues */ - public boolean execute(Context context) throws Exception { - log.trace("execute(" + context + ")"); - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { // Are we configured to select Locale automatically? log.trace("retrieve config..."); Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectModule.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectModule.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectModule.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSelectModule.java Tue Mar 15 18:57:04 2005 @@ -17,8 +17,6 @@ package org.apache.struts.chain.commands; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.struts.Globals; import org.apache.struts.chain.Constants; import org.apache.struts.chain.contexts.ActionContext; @@ -35,7 +33,7 @@ * @version $Rev$ $Date$ */ -public abstract class AbstractSelectModule implements Command { +public abstract class AbstractSelectModule extends ActionCommandBase { // ------------------------------------------------------ Instance Variables @@ -61,10 +59,7 @@ * * @return <code>false</code> so that processing continues */ - public boolean execute(Context context) throws Exception { - - // Identify the module prefix for the current module - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { String prefix = getPrefix(actionCtx); // Cache the corresponding ModuleConfig and MessageResources instances Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSetContentType.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSetContentType.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSetContentType.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractSetContentType.java Tue Mar 15 18:57:04 2005 @@ -17,8 +17,6 @@ package org.apache.struts.chain.commands; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.struts.chain.contexts.ActionContext; import org.apache.struts.config.ModuleConfig; @@ -31,7 +29,7 @@ * @version $Rev$ $Date$ */ -public abstract class AbstractSetContentType implements Command { +public abstract class AbstractSetContentType extends ActionCommandBase { // ---------------------------------------------------------- Public Methods @@ -45,8 +43,7 @@ * * @return <code>false</code> so that processing continues */ - public boolean execute(Context context) throws Exception { - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { // Retrieve the ModuleConfig instance ModuleConfig moduleConfig = actionCtx.getModuleConfig(); Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractValidateActionForm.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractValidateActionForm.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractValidateActionForm.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/AbstractValidateActionForm.java Tue Mar 15 18:57:04 2005 @@ -17,8 +17,6 @@ package org.apache.struts.chain.commands; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.action.ActionErrors; @@ -36,7 +34,7 @@ * @version $Rev$ $Date$ */ -public abstract class AbstractValidateActionForm implements Command { +public abstract class AbstractValidateActionForm extends ActionCommandBase { // ------------------------------------------------------ Instance Variables @@ -56,8 +54,7 @@ * @return <code>false</code> so that processing continues, if there are * no validation errors; otherwise <code>true</code> */ - public boolean execute(Context context) throws Exception { - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { // Is there a form bean for this request? ActionForm actionForm = actionCtx.getActionForm(); Added: struts/core/trunk/src/share/org/apache/struts/chain/commands/ActionCommand.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/ActionCommand.java?view=auto&rev=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/ActionCommand.java (added) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/ActionCommand.java Tue Mar 15 18:57:04 2005 @@ -0,0 +1,32 @@ +/* + * $Id$ + * + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.struts.chain.commands; + +import org.apache.commons.chain.Command; +import org.apache.struts.chain.contexts.ActionContext; + +/** + * <p>Marks a commons-chain <code>Command</code> which expects to operate + * upon a Struts <code>ActionContext</code>.</p> + */ +public interface ActionCommand extends Command { + boolean execute(ActionContext actionContext) throws Exception; +} + + Added: struts/core/trunk/src/share/org/apache/struts/chain/commands/ActionCommandBase.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/ActionCommandBase.java?view=auto&rev=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/ActionCommandBase.java (added) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/ActionCommandBase.java Tue Mar 15 18:57:04 2005 @@ -0,0 +1,42 @@ +/* + * $Id$ + * + * Copyright 2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.struts.chain.commands; + +import org.apache.commons.chain.Context; +import org.apache.struts.chain.contexts.ActionContext; + +/** + * <p>Simple abstract class which avoids frequent casting to <code>ActionContext</code> + * in commands explicitly intended for use with that class.</code>.</p> + */ +public abstract class ActionCommandBase implements ActionCommand { + + public abstract boolean execute(ActionContext actionContext) throws Exception; + + /** + * <p>Simply cast the <code>Context</code> to <code>ActionContext</code> + * and call <code>execute(ActionContext)</code>.</p> + */ + public boolean execute(Context context) throws Exception { + return execute((ActionContext) context); + } + +} + + Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/ExceptionCatcher.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/ExceptionCatcher.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/ExceptionCatcher.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/ExceptionCatcher.java Tue Mar 15 18:57:04 2005 @@ -38,7 +38,7 @@ * @version $Rev$ $Date$ */ -public class ExceptionCatcher implements Filter { +public class ExceptionCatcher extends ActionCommandBase implements Filter { // ------------------------------------------------------ Instance Variables @@ -114,8 +114,7 @@ * * @return <code>false</code> so that processing continues */ - public boolean execute(Context context) throws Exception { - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { actionCtx.setException(null); return (false); Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/ExecuteCommand.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/ExecuteCommand.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/ExecuteCommand.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/ExecuteCommand.java Tue Mar 15 18:57:04 2005 @@ -18,7 +18,6 @@ import org.apache.commons.chain.Catalog; import org.apache.commons.chain.CatalogFactory; import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.chain.contexts.ActionContext; @@ -35,7 +34,7 @@ * into the context, unless it has already dealt with the response.</p> * @version $Id$ */ -public class ExecuteCommand implements Command { +public class ExecuteCommand extends ActionCommandBase { // ------------------------------------------------------ Instance Variables @@ -55,15 +54,13 @@ * @return the result of the lookup command's <code>execute</code> method, if executed, * or <code>false</code> if it was not executed. */ - public boolean execute(Context context) throws Exception { - - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { if (shouldProcess(actionCtx)) { Command command = getCommand(actionCtx); if (command != null) { - return (command.execute(context)); + return (command.execute(actionCtx)); } } Modified: struts/core/trunk/src/share/org/apache/struts/chain/commands/SelectInclude.java URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/chain/commands/SelectInclude.java?view=diff&r1=157633&r2=157634 ============================================================================== --- struts/core/trunk/src/share/org/apache/struts/chain/commands/SelectInclude.java (original) +++ struts/core/trunk/src/share/org/apache/struts/chain/commands/SelectInclude.java Tue Mar 15 18:57:04 2005 @@ -17,8 +17,6 @@ package org.apache.struts.chain.commands; -import org.apache.commons.chain.Command; -import org.apache.commons.chain.Context; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.struts.chain.contexts.ActionContext; @@ -33,7 +31,7 @@ * @version $Rev$ $Date$ */ -public class SelectInclude implements Command { +public class SelectInclude extends ActionCommandBase { // ------------------------------------------------------ Instance Variables @@ -53,9 +51,7 @@ * * @return <code>false</code> so that processing continues */ - public boolean execute(Context context) throws Exception { - - ActionContext actionCtx = (ActionContext) context; + public boolean execute(ActionContext actionCtx) throws Exception { // Acquire configuration objects that we need ActionConfig actionConfig = actionCtx.getActionConfig(); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]