Right, it's OK.
Your
MyAspect
should be registered as bean anyway.It doesn't matter is it AOP Aspect or not: the dependency injection infrastructure the same.
Now about
HttpSession
. This object isn't registered as bean, but for him Spring provide a trick -WebApplicationContextUtils.SessionObjectFactory
. This object is registered as
beanFactory.registerResolvableDependency(HttpSession.class, new SessionObjectFactory());
And when the injection works it wraps SessionObjectFactory
with Proxy
to invoke real methods on demand from ThreadLocal<RequestAttributes>
variable. That mean that each call of your MyAspect.myMethod
does the stuff for concrete HttpSession
, if your current Thread is a Servlet Thread, of course.
So, the answer to your question: yes, it is thread safe.