Spring Framework

Spring Projects

Spring Project 1

adplus-dvertising
Scope Attribute of bean
Previous Home Next

Introduction: Spring framework provide the facility how many time you creating object through the IOC container. If you want this object is create only one time or more the one time then you give the all information in our configuration file. Through "SCOPE" attribute Spring framework provide this solution.

If you are define "SCOPE" attribute in bean tag element then developer choose two option first option if you create object only one time then give "SINGLETON BEAN" in scope attribute and you create object more then one time then give "PROTOTYPE BEAN" in scope attribute.

Type of Scope attribute of bean

There are two types of bean in SCOPE attribute which are following:

  1. Singleton Bean
  2. Prototype Bean

Singleton Bean: This bean provide the facility to create only one bean if any user request bean then same bean provide more then one user.

Syntax of Singleton bean:

<bean id=" " factory-bean=" " factory-method=" " scope="singleton"></bean>

Prototype Bean: This bean provide the facility to request more then one bean if any user request bean then different bean provide each request.

Syntax of Prototype bean:

<bean id=" " factory-bean=" " factory-method=" " scope="prototype"></bean>
Previous Home Next