Thread Safety and Spring Scopes in Web Flow
I'm looking for clarification on spring bean scopes and web flow.
My understanding is that by default a spring bean: a controller for example is a singleton and so long as that bean doesn't have state/has thread safe fields it will be thread safe.
Each HTTP request gets its own thread and these would share an instance of the controller bean.
I'm new to spring web flow and I've seen some examples where the controller is holding state for example a user field for the current user. An initialisation method of the controller is called when the flow is entered and this sets the controller fields. My understanding (which may be wrong) is that means each request thread can then overwrite the user field potentially leading to issues.
I can't see anything in spring config xml or annotations to declare the bean as not a singleton Ie prototype, per request etc.
Is there some web flow magic going on? Or am I on the wrong track?
Thanks
链接地址: http://www.djcxy.com/p/39178.html