@Component
@Aspect
public class TimeTraceAop {
@Around("execution(* hello.hellospring..*(..))") //시간을 계산하는 위 클래스를 공통 관심 사항으로 지정
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 +
}
}
}