/** * */ package com.icil.esolution.aspect; import java.util.Date; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; /** * *@ClassName: TimeAspect * * @Description: * * @Author: Sea * * @Date: 16 Oct 2018 7:18:40 PM * * * @Copyright: 2018 icil . All rights reserved. */ @Aspect @Component public class TimeAspect { private static Logger logger =LoggerFactory.getLogger(TimeAspect.class); // @Around("execution(* com.sea.web.controller.UserController.*(..))") //com.icil.esolution.service.impl @Around("execution(* com.icil.esolution.controller.*.*(..))") public Object handleControllerMethod(ProceedingJoinPoint pjp) throws Throwable { long start = new Date().getTime(); Object object = pjp.proceed(); String costTime= (new Date().getTime() - start)+""; String methodName = pjp.getSignature().getName(); logger.info("*************** Run the method --> {} total cost time is {} ms********************",methodName,costTime); return object; } }