Spring comma separated list of bean references

In Spring, is it possible to feed a comma separated list of bean references into another bean, ideally without any custom property editors. This list comes from a placeholder that I have no control over.

For example (does not work):

<bean id="bean1" class="java.lang.Integer />
<bean id="bean2" class="java.lang.Integer />

<bean class="customclass">
  <constructor-arg><ref bean="bean1,bean2" /></constructor-arg>
</bean>

Which would be identical to:

<bean id="bean1" class="java.lang.Integer />
<bean id="bean2" class="java.lang.Integer />

<bean class="customclass">
  <constructor-arg>
    <list>
      <ref bean="bean1"/>
      <ref bean="bean2"/>
    </list>
  </constructor-arg>
</bean>

Answers


It is possible using this approach:

Consider a properties file with entries like this:

test.properties:

beanlist1=#{{@bean1,@bean2}}

Now you will be able to do this:

<context:property-placeholder location="test.properties"/>
<bean id="bean1" class="java.lang.Integer />
<bean id="bean2" class="java.lang.Integer />

<bean class="customclass">
  <constructor-arg value="${beanlist}></constructor-arg>
</bean>

which is fairly close to what you want(slightly different representation - #{{@bean1,@bean2}} instead of bean1,bean2) .

Another way is the following:

<bean class="customclass">
  <constructor-arg value="#{{@bean1,@bean2}}"></constructor-arg>
</bean>

Both work using the Spring-EL expression to represent a list.


Need Your Help

How can I pass both Vertex & Face normals to a Three.js shader?

javascript three.js glsl shader normals

If I understand correctly, the THREE.Geometry methods, .computeFaceNormals() &amp; .computeVertexNormals(), each assign values to an 'innate' attribute array, "normal".

Session problem in cxml Punchout in Struts2 Java

java struts2 session-variables

We have created a punchout(cXML Punchout) supplier site which integrates with ariba. It is working fine when tried in google chrome with frames environment but keeps on losing its session in IE for...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.