2009-10-29 76 views
1

我有以下几点:春季(JAVA) - 注册VS列表

List<Color> acceptableColors; 

使用Spring,这将是最好的这种方式实例化这个列表:

<bean> 
    <list> 
    <value ref="orange" /> 
    <value ref="yellow" /> 
    .... 
    </list> 
</bean> 

或者说,是有办法做一个注册方案,我们使用Spring来执行以下Java代码:

ColorRegister.register(orange) 
ColorRegister.register(yellow) 

回答

1

没有为S创建您自己的自定义模式元素普林(这是可能的,documented),这可能是你能做的最好的,使用util架构/命名空间:

<util:list id="acceptableColors"> 
    <ref bean="orange"/> 
    <ref bean="yellow"/> 
</util:list>