views:

39

answers:

1

Can you rely on this scope and be sure that every time

1) a new session starts, the Spring bean will be initialized with default values

2) while session is kept alive, the current object will store its state during session life, will never be lost or corrupted and can always be got with [webappcontext].getBean ?

+2  A: 
  1. Not quite - the Spring bean will be created the first time it is referenced within each new HTTP session. The creation of a new HTTP session will not trigger the immediate creation of every session-scoped Spring bean, that would kill performance. They are initialized lazily, on demand.
  2. Yes

Both are guaranteed. Do you have reason to think otherwise?

skaffman
@skaffman No, for now I do not have reasons to think the opposite :) I think Spring is quite reliable, but who knows.
EugeneP
@Eugene: This is btw not specific to Spring. All decent MVC frameworks, even the homegrown ones, logically works that way.
BalusC
@BalusC Nothing is stable enough to rely on in this world. Even the best developers )
EugeneP
It would have killed Spring. It's still alive.
BalusC
@BalusC Bugs are fixed, that's why Spring is still alive :) Joke. By the way, what other frameworks you can call DECENT? Please name a couple !
EugeneP