【问题标题】:blueprint equivalent of util:list from Spring相当于 Spring 中的 util:list 的蓝图
【发布时间】:2015-01-19 10:07:39
【问题描述】:

我试图浏览网站和文档,但找不到与 Spring 中的 util:list 等效的蓝图?我忽略了什么吗?如果不存在,还有什么替代方案?在任何一种情况下,我都需要一个注入另一个 bean 的 bean 列表 - 计划使用 util:list 但是..

【问题讨论】:

    标签: blueprint-osgi


    【解决方案1】:

    你试过了吗?

    <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 的列表。

    【讨论】:

      【解决方案2】:

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

      可以在任何地方使用值的“值”类型的集合 可以指定。该集合包括 和 元素,任何 组件类型(、 等)作为内联组件, 源自字符串值的类型的通用元素,任何 集合类型(、、、、),以及 类型注入一个空值。

      另外,你可以在这里找到一个例子:http://grepcode.com/file/repo1.maven.org/maven2/org.apache.aries.blueprint/org.apache.aries.blueprint.sample/0.4/OSGI-INF/blueprint/config.xml

      【讨论】:

      • 我正在寻找 util:list 的等价物,而不是作为属性“值”的列表。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-19
      • 2021-04-03
      • 2021-11-07
      • 1970-01-01
      • 1970-01-01
      • 2014-07-27
      • 1970-01-01
      相关资源
      最近更新 更多