• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Can CGLib retain annotations at method parameter level?

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!