Sunday, April 27, 2014

Spring bean scopes

Below are the list of Spring scopes

1)singleton: By default all the beans created in Spring are singleton per container.If you not mention scope attribute in your bean definition file beans then beans will created are singletons only.

2)prototype:  New bean will be created for each request with this scope.You can override the default singleton scope to prototype in bean definition file as shown below.

<bean id="account" class="com.ramesh.Account" scope="prototype">

3)request:Scopes a bean definition to a HTTP request.Valid only in the case of web application context(E.g.: Spring MVC)

4)session: Scopes a bean definition to a HTTP session.Valid only the case of web application context(E.g.: Spring MVC)

5)global-session: Scopes a bean definition to a global HTTP session.Valid in the case of Portlets context

No comments:

Post a Comment