Scopes and the Blueprint Container

In the Blueprint programming model, you use the scope setting to determine whether a bean manager creates single or multiple object instances.

The Blueprint Container specification defines two scopes:
singleton
The bean manager creates a single instance of the bean and returns that instance every time that the manager is requested to provide an object. This is the default for top-level bean managers.
prototype
The bean manager creates a new instance of the bean every time that the manager is requested to provide an object. This is the default for bean managers that are specified in an inline declaration.

The following Blueprint XML example code shows how to set a singleton scope for a bean manager.

<bean id=”singletonAccount” class=“org.apache.aries.simple.Account” 
   scope=”singleton”>
   <argument value=”5”/>
</bean>

The following Blueprint XML example code shows how to set a prototype scope for a bean manager.

<bean id=”prototypeAccount” class=“org.apache.aries.simple.Account” 
   scope=”prototype”>
   <argument value=”4”/>
</bean>