【问题标题】:Accessing information in Apache Felix metatype file?访问 Apache Felix 元类型文件中的信息?
【发布时间】:2018-08-26 17:02:57
【问题描述】:

我正在尝试了解 Apache Felix 中 metatype 文件在我的 OSGi 应用程序中的用途。

示例 XML

<?xml version="1.0" encoding="UTF-8"?>
<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0">
    <OCD description="BundleMetaData" name="com.osgi.client" id="osgiclient">
        <AD name="Bundle Name"  id="osgiclient-feature" required="true" type="String" default="CUSTOM :: GREETER CLIENT :: BUNDLE"/>
    </OCD>
    <Designate pid="com.osgi.client">
        <Object ocdref="com.osgi.client"/>
    </Designate>
</metatype:MetaData>

我想以编程方式获取Bundle Name,但请参阅:

http://felix.apache.org/documentation/subprojects/apache-felix-metatype-service.html

需要某种 PID 来获取数据:

ObjectClassDefinition ocd = information.getObjectClassDefinition(pid, locale);

但是,我分析了 information 对象并没有看到任何 PID。如何从 XML 访问这些属性?

【问题讨论】:

    标签: osgi apache-karaf apache-felix


    【解决方案1】:

    我建议查看Metatype specification 以了解其工作原理和使用方法。

    PID 是一个持久标识,用作Configuration Admin 服务中配置数据的主键。

    【讨论】:

      猜你喜欢
      • 2013-07-14
      • 2013-03-04
      • 2010-10-21
      • 2015-06-28
      • 1970-01-01
      • 1970-01-01
      • 2021-07-29
      • 2015-04-22
      • 2013-05-15
      相关资源
      最近更新 更多