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 inline.

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>

Concept topic

Terms of use | Feedback


Timestamp icon Last updated: Tuesday, 20 September 2011
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=matt&product=was-nd-zos&topic=ca_blueprint_scopes

Copyright IBM Corporation 2009, 2011. All Rights Reserved.
This information center is powered by Eclipse technology. (http://www.eclipse.org)