import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; @Aspect public class AopSample{ private Logger logger = LoggerFactory.getLogger(this.getClass()); @Pointcut("exection()") public void executeTime() { } @Around("executeTime()") public Object around(ProceedingJoinPoint joinPoint) throws Throwable { long startTime = System.currentTimeMillis(); try { return joinPoint.proceed(); } finally { long timeTaken = System.currentTimeMillis() - startTime; logger.info("Time Taken({} ms) by {}", timeTaken, joinPoint); } } }