Type converters and the Blueprint Container
During injection, the Blueprint Container converts the XML value elements into value objects injected into the manager components. The elements are converted based on the type of the injected property.
The Blueprint Container provides the following built-in conversions:
- String values can be converted to all primitive types, wrapper types, or any types that have a public constructor that takes a String value.
- Array elements can be converted to collection objects with compatible member types.
- List or set elements can be converted to array objects with compatible member types.
The Blueprint Container also supports generics. If the generics information is available, the Blueprint Container uses that information for the conversions. For example, in the following Blueprint XML example code, the list element is converted into a list of java.util.Long objects.
public class AccountManager { ... public void setAccountNumbers(List<Long> accounts) { ... } }<bean id="accountManagerFour" class="org.apache.aries.AccountManager"> <property name="accountNumbers"> <list> <value>123</value> <value>456</value> <value>789</value> </list> </property> </bean>A Blueprint bundle can also provide its own converters. The custom converters are bean managers that provide an object that implements the Blueprint Converter interface. Specify the custom converters in the type-converters element under the Blueprint element. When the Blueprint Container is initialized, the type converters are initialized first, so that other managers can use the custom converters. For further details, see the Blueprint Container specification.
Related:
Blueprint bundles Blueprint XML Beans and the Blueprint Container Services and the Blueprint Container References and the Blueprint Container Scopes 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 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: was319.html
prettyPrint();