• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting method name on spring AOP @Before

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using spring AOP @Before. I was able to get all the variables but not the method name. how to get the method name. I am following link
http://static.springsource.org/spring/docs/2.5.x/reference/aop.html
Please give me ideas, sample code. thank you.
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can inject JoinPoint object in the AOP method and use the APIs exposed by JoinPoint.

To get the method name on which the aspect is getting applied, you can use

joinPoint.getSignature().getName()
 
john wutka
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
any good examples, links on this topic. please advise
 
Greenhorn
Posts: 1
Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

john wutka wrote:any good examples, links on this topic. please advise



If you want generic advice to all the methods irrespective of the arguments size below is the code..



and if you want advice to methods with specific arguments

.....



observe the "argNames" in the above code,joinPoint followed by the argument names.You can play with joinPoint now ...

Hope this helps you


 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think this website will help you a lot. I recently came across this, Have a look at this. They have given the simple example for both Annotation driven and xml driven approaches.

http://www.compiletimeerror.com/2013/05/spring-aop-before-advice-example.html

Hope this helps
 
Oh the stink of it! Smell my tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic