蓝图相当于 Spring:list 的 util:list



我试图浏览网站和文档,但我找不到与 Spring 中的 util:list 等效的蓝图?我忽略了什么吗?如果没有,还有什么选择?无论哪种情况,我都需要一个注入到另一个豆子中的豆子列表 - 计划使用 util:list 但是。

你试过这个吗?

<bean id="myList" class="java.util.ArrayList">
    <argument>
        <list value-type="com.example.MyType">
            <ref component-id="mycomponent1"/>
            <ref component-id="mycomponent2"/>
            <ref component-id="mycomponent3"/>
            <bean class="com.example.MySubType"/>
        </list>
    </argument>
</bean>

ArrayList 将 Collection 作为构造函数参数(顺便说一下,LinkedList 也是如此)。因此,您只需创建一个 List 类型的 bean,并在构造函数中提供 Bean 引用或 bean 的列表。

http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd 命名空间中应该有一个列表元素。

可以在任何地方使用值的"值"类型的集合 可以指定。 此集合包括 元素,任何 组件类型(、<服务>等)作为内联组件, 源自字符串值的类型的泛型元素,任何 集合类型(<集合>、<列表>、<数组>、<映射>、)和 类型以注入 null 值。

另外,您可以在此处找到示例:http://grepcode.com/file/repo1.maven.org/maven2/org.apache.aries.blueprint/org.apache.aries.blueprint.sample/0.4/OSGI-INF/blueprint/config.xml

最新更新