I have a web application using spring and hibernate and struts (it works on Tomcat)
The call sequence looks something like this:
Invokes spring bean service actions, which in turn invokes spring DAO bean. The DAO implementation is an implementation of Hibernate.
Question Will all my spring beans work in one thread? Can I save something in ThreadLocal and get it in another bean?
I am sure that this would not work in a session without a bean state. An EJB container can (or will) spawn a new thread for every bean call
Will spring container do the same? those. run all beans in one thread?
When I tried the JUnit test, I got the same identifier through Thread.currentThread (). getId () in the test case and two beans - which makes me think that there was only one thread in action
Or is the behavior unpredictable? Or will it change when running on a Tomcat server?
Explanation I do not want to exchange data between two streams. I want to put data in ThreadLocal and get it from all beans in the call stack. This will only work if all the beans are in the same thread.
java spring multithreading tomcat thread-local
RN.
source share