package com.example.spring.aop.aoplogger; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; public class Logger { public void beforMethodExecuted(JoinPoint joinPoint) { System.out.println("AOP Logger (BEFORE): " + joinPoint.getSignature()); } public void afterMethodExecuted(JoinPoint joinPoint) { System.out.println("AOP Logger (AFTER): " + joinPoint.getSignature()); } public Object methodExecutionMonitor(ProceedingJoinPoint pjp) throws Throwable { long startTime = System.nanoTime(); Object retVal = pjp.proceed(); long endTime = System.nanoTime(); System.out.println("Method execution time (ns): " + pjp.getSignature() + " " + (endTime - startTime)); return retVal; } }