| Author |
Getting method name on spring AOP @Before
|
john wutka
Ranch Hand
Joined: Apr 14, 2011
Posts: 31
|
|
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
Joined: May 01, 2008
Posts: 66
|
|
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()
|
Naresh Waswani
|
 |
john wutka
Ranch Hand
Joined: Apr 14, 2011
Posts: 31
|
|
|
any good examples, links on this topic. please advise
|
 |
Pavan Vusirika
Greenhorn
Joined: Jan 04, 2012
Posts: 1
|
|
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
|
Pavan
|
 |
Prabu Dhanapal
Greenhorn
Joined: Aug 12, 2011
Posts: 14
|
|
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
|
 |
 |
|
|
subject: Getting method name on spring AOP @Before
|
|
|