xjr100419 commented on issue #784: agent spring-plugins aop URL: https://github.com/apache/incubator-skywalking/issues/784#issuecomment-361478271 RspData.java `package com.candao.dms2.gps.aop; /** * ???? * @author xiao */ public class RspData { /** * ???? {link RspStatus} */ public int status; /** * ?????? */ public String msg; /** * ?????? */ public Object data; // ???? public RspData(Object data) { this.data = data; } public RspData() { } /** * ???????RspData<br/> * @param status-????? * @param msg-????? * @return */ public static RspData getFailRspData(int status, String msg) { RspData rspData = new RspData(); rspData.status = status; rspData.msg = msg; return rspData; } @Override public String toString() { return "RspData [status=" + status + ", msg=" + msg + ", data=" + data + "]"; } }` ExceptionInterceptorAspect.java `package com.candao.dms2.gps.aop; 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.springframework.stereotype.Component; /** * ??? ??????? * * @author xiao * @date 2017?12?27? ??7:30:55 */ @Aspect @Component public class ExceptionInterceptorAspect { @Pointcut("execution(* com.candao.dms2.gps.controller..*(..)) and @annotation(org.springframework.web.bind.annotation.RequestMapping)") public void controllerMethodPointcut(){} @Around("controllerMethodPointcut()") public Object handlerControllerMethod(ProceedingJoinPoint pjp) { long startTime = System.currentTimeMillis(); RspData repData; try { repData = (RspData) pjp.proceed(); System.out.println(pjp.getSignature() + "use time:" + (System.currentTimeMillis() - startTime)); } catch (Throwable e) { repData = handlerException(pjp, e); e.printStackTrace(); } return repData; } private RspData handlerException(ProceedingJoinPoint pjp, Throwable e) { RspData result = new RspData(); return result; } } `
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
