Tuesday, August 31, 2010

Array properties in Spring Framework - Byte Slinger

Array properties in Spring Framework - Byte Slinger

A simple trick to do inject Array values in to spring beans.

A quick blurb from the above site....

So, if you have Java that looks like this:

1
2
3
void setProperty1(String[] aStringArray){...}
void setProperty2(List<string> aStringList){...}
</string>
You can configure it with XML that looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
<property name="property1">
    <list>
        <value>one</value>
        <value>two</value>
    </list>
</property>
<property name="property2">
    <list>
        <value>one</value>
        <value>two</value>
    </list>
</property>