File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting method name on spring AOP @Before

 
john wutka
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Waswani Naresh
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any good examples, links on this topic. please advise
 
Pavan Vusirika
Greenhorn
Posts: 1
Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • 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


 
Prabu Dhanapal
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic