- getArgs
the method arguments
- getThis
the proxy object. This will always be the same object as that matched by the this pointcut designator.
- getTarget
the target object. This will always be the same object as that matched by the target pointcut designator.
- getSignature
a description of the target method that is being advised
- toString
a useful description of the target method being advised
- getKind
Kind of Join point. In Spring, it is always of kind “method-execution” as we support advice only for method execution
@Component
@Aspect
public class LoggingAspect {
@Before("execution(* com..Utility.formatData(..))")
public void beforeAdviceMethod(JoinPoint joinPoint) {
System.out.println("beforeAdviceMethod <- start");
System.out.println("Join Point static part = " + joinPoint.getStaticPart());
System.out.println("Signature = " + joinPoint.getSignature());
System.out.println("Args = " + Arrays.toString(joinPoint.getArgs()));
System.out.println("Kind = " + joinPoint.getKind());
System.out.println("Join Point Long String " + joinPoint.toLongString());
System.out.println("Join Point Short String " + joinPoint.toShortString());
System.out.println("Join Point String " + joinPoint.toString());
System.out.println("Join Point getTarget " + joinPoint.getTarget());
System.out.println("Join Point getThis " + joinPoint.getThis());
System.out.println("beforeAdviceMethod <- stop\n\n");
}
}
// calling the target method
Utility utility = context.getBean(Utility.class);
utility.formatData("John", "Doe");
- output
beforeAdviceMethod <- start
Join Point static part = execution(String com.tedblob.Utility.formatData(String,String))
Signature = String com.tedblob.Utility.formatData(String,String)
Args = [John, Doe]
Kind = method-execution
Join Point Long String execution(public java.lang.String com.tedblob.Utility.formatData(java.lang.String,java.lang.String))
Join Point Short String execution(HelloBean.formatData(..))
Join Point String execution(String com.tedblob.Utility.formatData(String,String))
Join Point getTarget com.tedblob.Utility@6b695b06
Join Point getThis com.tedblob.Utility@6b695b06
beforeAdviceMethod <- stop
https://nhj12311.tistory.com/469
https://nhj12311.tistory.com/469