Sunday, April 2, 2017

Explain difference scopes of beans in Spring

            Explain difference scopes of beans?
We can make IOC container keeping out spring bean class  object in different scopes. They are
         a)      Singleton (default scope is Singleton)
         b)     Prototype
         c)      Session
         d)     Request
         e)      Globalsession (globalsession is removed in spring 3.x version)

 Singleton:  returns same bean class object for all factory.getBean(-) calls with same bean id.
Prototype: returns separate bean class object for every factory.getBean(-) method call.

Request: Bean class object is specific to each request.

Session: Bean class object is visible throughout session

GlobalSession : specific to port lets  environments
Use “scope” attributes of <bean> tag to specify bean scope.

Note:-
Request, session scopes can be used only in spring MVC applications.


Eg: - applicationContext.xml

No comments:

Post a Comment