chicout
chicout

Reputation: 937

Spring session scope bean, thread-safety

I am building an application with Struts2, Spring, Hibernate. Struts actions are managed by Spring, their scopes are "request" and I have session bean with some state for performing a conversation. Before I used Struts2 session map, but I wanted the "containsKey, put, get, cast" nightmare to dissapear. So I started using session scope bean managed by Spring.

Question: this bean isn't thread-safe? If we have multiple-windows-per-user-per-browser, we can get many threads in session bean? How to handle it? Build thread-safe session bean?

Upvotes: 1

Views: 1423

Answers (2)

rees
rees

Reputation: 1576

If you are concerned about "multiple-windows-per-user-per-browser" and also avoiding the "containsKey, put, get, cast" nightmare in Struts2, you could also look at the struts2-conversation plugin. The plugin would manage the thread-safety issues for you.

Upvotes: 1

JB Nizet
JB Nizet

Reputation: 691635

Yes. Everything stored in a scope larger than request is potentially accessed by multiple threads, and must be thread-safe.

Upvotes: 4

Related Questions