aspose file tools*
The moose likes Other Application Frameworks and the fly likes Can CGLib retain annotations at method parameter level? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Can CGLib retain annotations at method parameter level?" Watch "Can CGLib retain annotations at method parameter level?" New topic
Author

Can CGLib retain annotations at method parameter level?

Cristian Vrabie
Ranch Hand

Joined: Jul 09, 2008
Posts: 71
Hi all,
I just tried to advice a Spring Controller using Spring AOP. For those of you that don't know it, Controllers can use annotations at type level for auto-detection, at method level for url auto-mapping and at method parameter level for forcing the use of certain parameters. For example:

Anyway, the Spring-specifics are not important.
The AOP proxy method has to be CGLib proxy(because the other option JDK proxy would not retain any annotation). And it works fine. The proxy retains the @Controller and @RequestMapping annotations so the controller is registered. What it doesn't work is the @RequestParam annotation. The proxied controller behaves as if the annotation it's not there.
This got me thinking. Can CGLib even transmit that to the proxy? If yes, then it must be a problem in the Spring AOP proxy creation/initialization. If not I'm doomed
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

AFAIK cglib proxies retain their annotations--Spring depends on annotations for other functionality as well, like injection and TX mgmt, so it strikes me as unlikely that this particular annotation would behave differently, you know?
Cristian Vrabie
Ranch Hand

Joined: Jul 09, 2008
Posts: 71
True, but most of those are processed before proxies are created for beans. Anyway, I know that GCLib retains annotations with ElementType=TYPE or METHOD. That's why @Controller and @RequestMapping works.
My only doubt was that annotations with ElementType=PARAMETER are retained (as far as I know RequestParam is the only one in Spring).
 
wood burning stoves
 
subject: Can CGLib retain annotations at method parameter level?
 
Similar Threads
@Controller annotation query
AOP Not working with Spring 3 MVC application
Multiple RequestMapping annotations on Spring 2.5.6
How to match a Spring @RequestMapping having a @pathVariable containing “/” ?
AOP ambiguous situation