我们使用aop记录日志,和传统记录日志不同的是注解的值是可以改变的,比如
@LogRecord(operateName = "用户登录系统")
我们写了工具类通过反射可以将注解的operateName改成 "root用户登录系统".
那么问题来了: 多个人同时登录(并发量很大的时候),operateName就不是当前人的名字了. 请问这怎么解决呢?
这是我aop获取注解的代码
String targetName = joinPoint.getTarget ().getClass ().getName ();
Class targetClass = Class.forName (targetName);
Method method = ((MethodSignature) joinPoint.getSignature ()).getMethod ();
Method realMethod = targetClass.getMethod (methodName, method.getParameterTypes ());
LogRecord logRecord = realMethod.getDeclaredAnnotation (LogRecord.class);
c币不足,敬请谅解