1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| @Aspect @Component @Slf4j public class OrderIdAspect {
@Pointcut("(execution(* xxx.xxxx.xxx.service.OrderConsumerService.processText(..)) ||" + "execution(* xxx.xxxx.xxx.service.OrderConsumerService.getPaperJsonContent(..)) ||" + "execution(* xxx.xxxx.xxx.service.OrderConsumerService.getTextJsonObject(..)) ||" + "execution(* xxx.xxxx.xxx.service.OrderConsumerService.TextConsumeMessage*(..)) ||" + "execution(* xxx.xxxx.xxx.service.OrderConsumerService.PaperConsumeMessage*(..)))" + "&& args(torder, ..)") public void orderMethod1(Torder torder) { }
@Around(value = "orderMethod1(torder)", argNames = "joinPoint,torder") public Object logMethod1(ProceedingJoinPoint joinPoint, Torder torder) throws Throwable { log.info("Accessed method: {}", joinPoint.getSignature().toShortString()); MDC.put("orderId", torder.getOrderId()); try { return joinPoint.proceed(); } finally { MDC.remove("orderId"); } }
@Pointcut("(execution(* xxx.xxxx.xxx.web.controller.CommonController.commitJCInformation(..)) ||" + "execution(* xxx.xxxx.xxx.service.impl.OrderServiceImpl.getAsyncErrorStatusOrder(..)) ||" + "execution(* xxx.xxxx.xxx.web.controller.CommonController.getStatusByOrderId(..)) ||" + "execution(* xxx.xxxx.xxx.web.controller.CommonController.userComment(..)) ||" + "execution(* xxx.xxxx.xxx.service.impl.OrderServiceImpl.commitJCInformation(..)) ||" + "execution(* xxx.xxxx.xxx.service.OrderConsumerService.getTextStatusByOrderId(..)) ||" + "execution(* xxx.xxxx.xxx.service.OrderConsumerService.getPaperStatusByOrderId(..)) ||" + "execution(* xxx.xxxx.xxx.manager.ThirdManager.getTaskProcessStatus(..)) ||" + "execution(* xxx.xxxx.xxx.manager.ThirdManager.getTextTaskProcessStatus(..)) ||" + "execution(* xxx.xxxx.xxx.manager.ThirdManager.createTextAlgorithmTask(..)))" + "&& args(orderId, ..)") public void orderMethod2(String orderId) { }
@Around(value = "orderMethod2(orderId)", argNames = "joinPoint,orderId") public Object logMethod2(ProceedingJoinPoint joinPoint, String orderId) throws Throwable { log.info("Accessed method: {}", joinPoint.getSignature().toShortString()); MDC.put("orderId", orderId); try { return joinPoint.proceed(); } finally { MDC.remove("orderId"); } } }
|