You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Michael Jouravlev (JIRA)" <ji...@apache.org> on 2006/08/28 21:20:31 UTC

[jira] Commented: (STR-2365) DispatchAction method invocation refactoring

    [ http://issues.apache.org/struts/browse/STR-2365?page=comments#action_38051 ] 
            
Michael Jouravlev commented on STR-2365:
----------------------------------------

Struts 1.2.7+ has ActionDispatcher that allows to use dispatch functionality while extending an action from a custom action class. I suggest closing this bug with "Won't Fix".

> DispatchAction method invocation refactoring
> --------------------------------------------
>
>                 Key: STR-2365
>                 URL: http://issues.apache.org/struts/browse/STR-2365
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Extras
>    Affects Versions: Nightly Build
>         Environment: Operating System: Windows XP
> Platform: PC
>            Reporter: Jason Menard
>            Priority: Minor
>         Attachments: DispatchAction.java, DispatchAction.java, DispatchActionInvokeMethod.txt
>
>
> A common pattern in Struts is to apply the template method design pattern to
> create a base action for one's application, as discussed in
> StrutsCatalogBaseAction in the Struts wiki
> (http://wiki.apache.org/struts/StrutsCatalogBaseAction).  Occasionally,
> developers may wish to use an alternate method signature.  While this is no
> problem with Action, it is more problematic with DispatchAction and its
> subclasses.  I would like to propose a minor refactoring of DispatchAction in
> order to facilitate this.
> The refactoring consists of extracting two lines from dispatchMethod() into a
> new method protected call invokeMethod().
> The original code from dispatchMethod():
> Object args[] = {mapping, form, request, response};
> forward = (ActionForward) method.invoke(this, args);
> Refactored dispatchMethod():
> forward = invokeMethod(mapping, form, request, response, method);
> And the new method:
> protected ActionForward invokeMethod(ActionMapping mapping,
>                                      ActionForm form,
>                                      HttpServletRequest request,
>                                      HttpServletResponse response,
>                                      Method method)
>         throws Exception {
>     Object args[] = {mapping, form, request, response};
>     ActionForward forward = (ActionForward) method.invoke(this, args);
>     return forward;
> }
> Applying this refactoring will allow the developer to more easily extend
> DispatchAction in order to allow for alternate method signatures.
> I will attach a patch.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira