I am using Spring 3 AOP, and I have an aspect that requires access to the HttpServletRequest. It looks something like this:
@Aspect
public class MyAspect {
@Autowired
private HttpServletRequest httpServletRequest;
public void init() {
// Do something once...
}
@Before("my pointcut here...")
private void myMethod() {
// I need the httpServletRequest...
}
@After("my pointcut here...")
private void myOtherMethod() {
// I need the httpServletRequest...
}
}
And is configured like this:
<bean id="myAspect" class="com.some.package.MyAspect" init-method="init" />
Is the init method only called once per IoC container, even though this is an aspect, and is the httpServletRequest thread safe? If it is not, what is the best way to get at it during execution of the advice and have it be thread safe? If at all possible I prefer not to use a thread local.