|
@@ -4,17 +4,23 @@ 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.stereotype.Component;
|
|
|
|
|
|
@Aspect
|
|
|
@Component
|
|
|
public class AdapterAspect {
|
|
|
+ Logger logger = LoggerFactory.getLogger(AdapterAspect.class);
|
|
|
@Pointcut("@annotation(edu.travel.adapter.annotation.AdapterAnnotation)")
|
|
|
public void pointcut() {}
|
|
|
|
|
|
@Around("pointcut()")
|
|
|
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
Object proceed = joinPoint.proceed(joinPoint.getArgs());
|
|
|
+ long endTime = System.currentTimeMillis();
|
|
|
+ logger.info("远程调用耗时:{} ms", (endTime - startTime));
|
|
|
return proceed;
|
|
|
}
|
|
|
}
|