0

I have a factory bean that produces List. But I call this factory multiple times meaning I end up with a lot of beans of type List.

I have another bean that has a property of type List. Somehow I need to put all the List beans in to one single list and provide it as a property using Spring XML.

How do I do this?

<bean id="usefulBean" class="...">
    <property name="listProperty" ref="listX1AndX2AndX3AndSoOn">
</bean>

<bean id="listX1" factory-bean="anInstanceFactory" factory-method="create">
    ...
</bean>

<bean id="listX2" factory-bean="anInstanceFactory" factory-method="create">
    ...
</bean>

<bean id="listX3" factory-bean="anInstanceFactory" factory-method="create">
    ...
</bean>
Kias
  • 841
  • 9
  • 22
  • possible duplicate of [Is there a way to re-use a in spring configuration file?](http://stackoverflow.com/questions/12760436/is-there-a-way-to-re-use-a-utillist-in-spring-configuration-file) – Eugene Evdokimov Jan 23 '14 at 07:07
  • No, that's a different problem. They want to branch a list, I want to extend it. – Kias Jan 23 '14 at 17:52
  • I mean I want to add to it. – Kias Jan 23 '14 at 18:18
  • Maybe that question sounds a bit different but answers to it describe several approaches that you may find helpful, for example http://stackoverflow.com/a/12760854/546117. There is another very similar question http://stackoverflow.com/q/14520536/546117 – Eugene Evdokimov Jan 23 '14 at 19:28
  • Those answers indicate it's not possible without creating an external bean to do it for you (which is what I did in the end). Thanks – Kias Jan 23 '14 at 21:55

0 Answers0