Issue Details (XML | Word | Printable)

Key: SPR-4015
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Juergen Hoeller
Reporter: Scott Murphy
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Spring Framework

@Interceptor Annotation for Annotation-based Controllers

Created: 28/Oct/07 05:08 PM   Updated: 30/Jun/08 08:57 AM
Component/s: SpringWEB
Affects Version/s: 2.5 RC1
Fix Version/s: 3.0 M2

Time Tracking:
Not Specified

Issue Links:
Related
 


 Description  « Hide
Annotation-based controller configuration is by far the best controller configuration I have seen to date. However, my current Spring 2.0 configuration is dependent on interceptors. However, the lack of interceptors has made it unusable to me. Is there any way we can PLEASE get some type on interceptor support in the 2.5 release?

@Interceptor("interceptorName")

I will work full time for FREE until the release if you need someone to write it if you can point me in the right direction.

 All   Comments   Work Log   Change History   FishEye   Builds      Sort Order: Ascending order - Click to sort in descending order
Scott Murphy added a comment - 28/Oct/07 05:15 PM
Ignore the 2nd "however". I lost my wireless internet connection during a post and accidentally resubmitted it before editing.
:)

I meant to say this:

Annotation-based controller configuration is by far the best controller configuration I have seen to date. However, my current Spring 2.0 configuration is dependent on interceptors. Is there any way we can PLEASE get some type on interceptor support in the 2.5 release?

@Interceptor("interceptorName")

I will work full time for FREE until the release if you need someone to write it if you can point me in the right direction.

Juergen Hoeller added a comment - 29/Oct/07 12:03 PM
Interceptors can be configured through an explicit "org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" bean definition, using the same "interceptors" property that is available on BeanNameUrlHandlerMapping and SimpleUrlHandlerMapping as well. Such a custom DefaultAnnotationHandlerMapping bean will simply override the default DefaultAnnotationHandlerMapping (which defines no interceptors), following the same approach that DispatcherServlet uses for all of its strategies.

I'm not fond of an @Interceptor annotation simply because interceptors should remain a separate configuration concern. Since interceptors are usually shared across many controllers, a custom HandlerMapping bean still seems to be the right level for defining interceptors.

Juergen

Scott Murphy added a comment - 30/Oct/07 02:10 AM
What happens if you have 2 annotation controllers that each need different interceptors? I am under impression that you can only have one DefaultAnnotationHandlerMapping.

Can we create a RestrictedAnnotationHandlerMapping where you specify the urls (or controllers) that are part of that mapping?

I tried to extend the DefaultAnnotationHandlerMapping and have a second one with a different order, but it appears that you can not do this. I guess the controller initialization is done in this mapper? (I could not view the source to org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping. It was not included in the distribution and is also not in the CVS respository using the web browse function from SourceForge)

Here would be an example of what I am trying to do:

accountInterceptor
displayAccounts.do
displayAccountDetails.do

bankingInterceptor
depositMoney.do
withdrawMoney.do

If I set up an interceptor for DefaultAnnotationHandlerMapping it would use it for all the controllers.

Scott Murphy added a comment - 30/Oct/07 03:45 AM
I retract my last comment, I was able to create a RestrictedAnnotationHandlerMapping where I define valid annotation urls. Everything works great now, thanks. You guys have really done a great job with 2.5. I have been using Spring since the 1.x days and I am really impressed with what you have done in 2.5

I'll mention again that org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping is missing from the src directory in the distribution. I don't know if you have a reason for that, but like I also said, I could not find it in CVS browse either.



Juergen Hoeller added a comment - 30/Oct/07 06:51 AM
DefaultAnnotationHandlerMapping lives in the "tiger/src" directory. "src" only contains the parts of Spring that are compiled with "-target 1.4", whereas "tiger/src" gets compiled with "-target 1.5". The "spring-sources.jar" that we provide in the "dist" directory contains all of the sources merged into one tree.

Thanks for the praise, BTW :-)

Juergen

Scott Murphy added a comment - 19/Nov/07 10:59 PM