[ 
http://www.stripesframework.org/jira/browse/STS-696?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11786#action_11786
 ] 

Paul White commented on STS-696:
--------------------------------

Hi Freddy,

I don't think there's a absolute need to subclass Resolution on return types 
but covariance is a principle that I think provides some tidy design options in 
Java 1.5

I like the idea of being able to override a default handler and change the 
return type to a RedirectResolution, forcing subsequent subclasses to redirect 
on the same action. 

Also, it seems reasonable to need to use handlers directly in applications. It 
might be useful to know you are getting a specific Resolution subclass as some 
of them offer different methods to others. Covariance avoids the need for 
casting and helps guaruntee type safety at compile time.

In summary, these issues can be worked around. However, anyone using covariant 
return types on Resolution methods will get the above error which doesn't offer 
much help in diagnosing the root of the problem. It took a fair amount of 
debugging for me to track it down.

-Paul

> StripesRuntimeException thrown in AnnotatedClassActionResolver when 
> overriding handler but returning a subclass of the original method
> --------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: STS-696
>                 URL: http://www.stripesframework.org/jira/browse/STS-696
>             Project: Stripes
>          Issue Type: Bug
>          Components: ActionBean Dispatching
>    Affects Versions: Release 1.5, Release 1.5.1
>         Environment: Java 1.5.0_19
>            Reporter: Paul White
>            Assignee: Frederic Daoud
>         Attachments: AnnotatedClassActionResolverTest.java
>
>
> A net.sourceforge.stripes.exception.StripesRuntimeException is thrown in 
> error at:
> net.sourceforge.stripes.controller.AnnotatedClassActionResolver.processMethods(AnnotatedClassActionResolver.java:226)
> The exception message is "The ActionBean class <classname? declares multiple 
> event handlers for event '<eventname>'"
> This occurs when processing methods for an actionBean that overrides a super 
> class handler with a method returning a subclass of the original method (eg 
> RedirectResolution overriding Resolution). The reason for the error is that 
> AnnotatedClassActionResolver.processMethods is not expecting 
> class.getDeclaredMethods() to include bridge methods. I will attach a test 
> case that displays the problem.
> Workaround is to refactor subclasses to return Resolution rather than 
> ForwardResolution, RedirectResolution etc but it's valid in Java to override 
> methods this way so it should be supported ideally.
> The solution is to change AnnotatedClassActionResolver.java, line 220 as 
> follows:
> if ( Modifier.isPublic(method.getModifiers()) && !method.isBridge() ) {

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

        

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to