| | |
| | | import org.aspectj.lang.annotation.Pointcut; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * trace log api aop |
| | | */ |
| | |
| | | TraceParamDto traceParamDto = new TraceParamDto(); |
| | | JSONObject paramIn = new JSONObject(); |
| | | JSONObject paramOut = new JSONObject(); |
| | | try { |
| | | Object[] args = pjp.getArgs(); |
| | | for (int paramIndex = 0; paramIndex < args.length; paramIndex++) { |
| | | paramIn.put("param" + paramIndex, args[paramIndex]); |
| | | |
| | | Object[] args = pjp.getArgs(); |
| | | for (int paramIndex = 0; paramIndex < args.length; paramIndex++) { |
| | | if (args[paramIndex] instanceof HttpServletRequest) { |
| | | // HttpServletRequest request = (HttpServletRequest) args[paramIndex]; |
| | | // paramIn.put("param" + paramIndex, request.getParameterMap()); |
| | | continue; |
| | | } |
| | | traceParamDto.setReqParam(paramIn.toJSONString()); |
| | | out = pjp.proceed(); |
| | | if (paramOut != null) { |
| | | paramOut.put("param", out); |
| | | } else { |
| | | paramOut.put("param", new JSONObject()); |
| | | if (args[paramIndex] instanceof HttpServletResponse) { |
| | | continue; |
| | | } |
| | | traceParamDto.setResParam(paramOut.toJSONString()); |
| | | Java110TraceFactory.putParams(traceParamDto); |
| | | } catch (Throwable e) { |
| | | throw e; |
| | | } finally { |
| | | return out; |
| | | paramIn.put("param" + paramIndex, args[paramIndex]); |
| | | } |
| | | traceParamDto.setReqParam(paramIn.toJSONString()); |
| | | out = pjp.proceed(); |
| | | if (paramOut != null) { |
| | | paramOut.put("param", out); |
| | | } else { |
| | | paramOut.put("param", new JSONObject()); |
| | | } |
| | | traceParamDto.setResParam(paramOut.toJSONString()); |
| | | Java110TraceFactory.putParams(traceParamDto); |
| | | return out; |
| | | } |
| | | } |