Bean scopes (in Spring 2.0)
There are only 2 scopes : singleton and prototype.
Beans defined in spring framework are singleton beans.
If singleton attribute is specified true then bean becomes singleton and if set to false then the bean becomes a prototype bean.
By default it is set to true. So, all the beans in spring 2.0 framework are by default singleton beans.
Bean scopes (in Spring 2.5)
Spring 2.5 provides additional scopes using scope attribute :
1. singleton : Scopes a single bean definition to a single object instance per Spring IoC container.
2. prototype : Scopes a single bean definition to any number of object instances.
3. request : Scopes a single bean definition to the lifecycle of a single HTTP request; that is each and every HTTP request will have its own instance of a bean created off the back of a single bean definition.
(Only valid in the context of a web-aware Spring ApplicationContext.)
4. session : Scopes a single bean definition to the lifecycle of a HTTP session.
(Only valid in the context of a web-aware Spring ApplicationContext.)
5. global session : Scopes a single bean definition to the lifecycle of a global HTTP session.
(Typically only valid when used in a portlet context. ; Only valid in the context of a web-aware Spring ApplicationContext)
The default scope of bean (if no bean scope is defined) : singleton
No comments:
Post a Comment
Note: only a member of this blog may post a comment.