I am trying to inject a list of beans in a list property in my blueprint.xml (similar to what you would do in Spring configuration):
blueprint.xml:
<blueprint
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<bean id="myBean" class="MyClass" />
<bean id="anotherBean" class="AnotherClass">
<property name="myClasses">
<list>
<ref bean="myBean" />
<list>
</property>
</bean>
</blueprint>
AnotherClass:
public class AnotherClass {
private List<MyClass> myClasses;
public void setMyClasses(List<MyClass> classes) {
this.myClasses = classes;
}
}
I had a look at the Blueprint XML schema and the R4.2 enterprise spec (which we are using) and found nothing suitable. But this is just such an obvious use case that I can't believe that this is not possible.
Any suggestions what I am missing here and how to do this?
I came across same issue and found an answer here. In ref element, change from bean to component-id.
<bean id="myBean" class="MyClass" />
<bean id="anotherBean" class="AnotherClass">
<property name="myClasses">
<list>
<ref component-id="myBean" />
</list>
</property>
</bean>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With