Bean instance created by spring container can be in one of the following scopes.
Singleton : When bean scope is singleton only one instance will be created for that bean and the same instance will be returned when you call getBean() method. Singleton is the default scope in ApplicationContext container. When scope of bean is singleton than default loading type is aggressive loading.- Singleton
- Prototype
- Request
- Session
- Global-Session
Prototype : When bean scope is prototype then new instance will be created for that bean when you call getBean() method. When scope is prototype the default loading type is lazy loading.
Request : Request scope is equal to HttpServletRequest in web application it means for every new request a new instance will be created.
Session : Session scope is equal to HttpSession scope in web application. It means for new instance per user.
Global-Session : Global-Session scope is equals to session in portlet based web application.
0 comments:
Post a Comment