java aop写日志并发出现问题,怎么解决?

我们使用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币不足,敬请谅解

operateName 保存在上下文中的话,可以通过在aop中获取到request 之后再去处理

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class HttpContextUtils
{
    public static HttpServletRequest getHttpServletRequest()
    {
        return ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
    }
}