Scopes and the Blueprint Container
In the Blueprint programming model, we 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 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>
Related:
Blueprint bundles Blueprint XML Beans and the Blueprint Container Services and the Blueprint Container References and the Blueprint Container Object values and the Blueprint Container Object life cycles and the Blueprint Container Resource references and the Blueprint Container Dynamism and the Blueprint Container Type converters and the Blueprint Container JNDI lookup for blueprint components Developing an OSGi application OSGi Service Platform Release 4 Version 4.2 Enterprise Specification Building OSGi applications with the Blueprint Container specification
File name: was317.html
prettyPrint();