sudeepdino008
sudeepdino008

Reputation: 3364

Getting the name of class intersected by a pointcut

class SampleClass{
   ChildClass childClass;
   public void init(){
       childClass = ChildUtil.getChildClass();
       childClass.callService("batman");
   }
}

Aspect

 @Aspect
    public class CallServiceAspect{
        @After("execution(* com.xyz.ChildClass.callService(..))")
        public void afterCallService(JoinPoint jp){
           log.debug(jp.getTarget().getName());
         }
    }

I want the name of class within which the callService method was intersected by the aspect(i.e. SampleClass). Is there any way to obtain it?

Upvotes: 1

Views: 247

Answers (1)

sudeepdino008
sudeepdino008

Reputation: 3364

In place of intercepting through execution, I used call. Then I was able to use jp.getThis() to get SampleClass name.

Upvotes: 1

Related Questions