Spring provide the facility to define the scope of bean ,to set limit instances or define area of bean. To define the bean scope set the scope properties with different parameters-
1.singleton-Allow the bean to a single instance per container.
2.prototype-Allow bean to be instantiate any number of times.
3.request-Allow a bean definition to an HTTP request.
4.session-Allow a bean definition to an HTTP session.
5.global-session-Allow a bean definition to a global HTTP session,used in only context.
Example of set the property scope-
<bean id="scope" class="com.test.BeanScopeProgram" scope="singleton"></bean>
1.singleton-Allow the bean to a single instance per container.
2.prototype-Allow bean to be instantiate any number of times.
3.request-Allow a bean definition to an HTTP request.
4.session-Allow a bean definition to an HTTP session.
5.global-session-Allow a bean definition to a global HTTP session,used in only context.
Example of set the property scope-
<bean id="scope" class="com.test.BeanScopeProgram" scope="singleton"></bean>
For Further Reading,
0 comments:
Post a Comment