I have a group of beans that I want to inject as a list into object1. OK, that was simple enough.
Now, I want to inject the same list into object2, so what I really want is have ref bean refer to the list both times.
Anyone have an idea how to do this?
lt;/valuegt; lt;valuegt;raskolnikov@slums.orglt;/valuegt; lt;valuegt;stavrogin@gov.orglt;/valuegt; lt;valuegt;porfiry@gov.orglt;/valuegt;
lt;/util:listgt;
lt;bean id=quot;bean1quot; class=quot;com.Bean1quot;gt; lt;property name=quot;myListquot; ref=quot;emailsquot;/gt;
lt;/beangt;
lt;bean id=quot;bean2quot; class=quot;com.Bean2quot;gt; lt;property name=quot;myListAgainquot; ref=quot;emailsquot;/gt;
lt;/beangt;Awesome, dude!
Thanks.
Depending on what version of Spring you use
Spring 1 amp; 2 use the ListFactoryBean and reference to that.Code:
lt;bean id=quot;listquot; class=quot;org..beans.factory.config.ListFactoryBeanquot;gt;
lt;property name=quot;sourceListquot;gt;
lt;listgt;
lt;valuegt;value1lt;/valuegt;
lt;valuegt;value2lt;/valuegt;
lt;/listgt;
lt;/propertygt;
lt;/beangt;
Spring 2 with new schemasCode:
lt;util:list id=quot;listquot;gt;
lt;valuegt;item1lt;/valuegt;
lt;valuegt;item2lt;/valuegt;
lt;/util:listgt; |