I am using the @AspectJ style for writing aspects, to handle logging in our application. Basically I have a pointcut set up like so:
@Pointcut("call(public * com.example..*(..))")
public void logging() {}
and then a before and after advice like so:
@Before("logging()")
public void entering() {...}
...
@After("logging()")
public void exiting() {...}
I want to create a log in these methods in the following format:
logger.trace("ENTERING/EXITING [" className + "." + methodName "()]");
The problem is I don't know how to get a reference to the class and method names. I have tried:
joinPoint.getThis().getClass()
but this seems to return the caller's class name.
class A {
public void a() {
B.b();
}
}
class B {
public void b() {
...
}
}
would result in the following log
ENTERING [A.b()]
can someone give some help on how to get the actual joinpoint class and method name