Skip to content

Instantly share code, notes, and snippets.

@yooniversal
Created August 3, 2021 08:50
Show Gist options
  • Save yooniversal/995168063a42ae31515123bea8079e5f to your computer and use it in GitHub Desktop.
Save yooniversal/995168063a42ae31515123bea8079e5f to your computer and use it in GitHub Desktop.
AOP 적용 : TimeTraceAop
package hello.hellospring.aop;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
@Aspect
@Component
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 + "ms");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment