AOP 자체에 대한 개념과 설명은 아래 링크를 참조합니다.
1. 사용예제 코드
@Aspect
public class TimeTraceAop {
@Around("execution(* jpabook.jpashop..*(..))")
public Object execute(ProceedingJoinPoint joinPoint) throws Throwable {
long start = System.currentTimeMillis();
System.out.println("START: " + joinPoint.toString());
try {
return joinPoint.proceed();
} finally {
long finish = System.currentTimeMillis();
long timeMs = finish - start;
System.out.println("END: " + joinPoint.toString() + " " + timeMs + "ms");
}
}
}
Java
복사