tags:

views:

30

answers:

2

I understand that a set can be defined as:

<bean id="toolbox" class="tools.Toolbox">
    <property name="tools">
        <set>
            <ref local="foo" />
            <ref local="bar" />
        </set>
    </property>
</bean>

but I can't find anything in the documentation to allow me to define the set first, for example:

<set id="myTools">
    <ref local="foo" />
    <ref local="bar" />
</set>
<bean id="toolbox" class="tools.Toolbox">
    <property name="tools" ref="myTools"/>
</bean>

Does anyone know if this works or if not how it could be accomplished?

+2  A: 

You want to use the util namespace

<util:set id="myTools">
    <ref local="foo" />
    <ref local="bar" />
</util:set>
Jon Freedman
+2  A: 

Use <util:set>

Here's the namespace:

xmlns:util="http://www.springframework.org/schema/util"

And the schemaLocation:

http://www.springframework.org/schema/util 
http://www.springframework.org/schema/util/spring-util-3.0.xsd
Bozho