osgi 中的动态=域导出是什么?

What is dynamic=domain export in osgi?

我使用 osgi/equinox,在浏览我们的一个包 MANIFEST.MF 文件时,我遇到了奇怪的行:

Export-Package: package.a.b.c;dynamic=domain

使用 dynamic=domain 选项导出包是什么意思,它与常规导出(没有任何其他选项)有何不同?

您可以根据需要向 Export-Package 子句添加任意数量的自定义属性。另一方面(Import-Package),您可以指定只有具有特定属性的包才适合您。

参见OSGi核心规范3.6.5 Export-Package章节:

The following attributes are part of this specification:

  • version - The version of the named packages with syntax as defined in Version on page 35. It defines the version of the associated packages. The default value is 0.0.0.

  • specification-version - An alias for the version attribute only to ease migration from earlier versions. If the version attribute is present, the values must be equal.

Additionally, arbitrary matching attributes may be specified. See Attribute Matching on page 58

并参见OSGi核心规范3.7.7属性匹配一章:

For example, the following statements will match.

A: Import-Package: com.acme.foo;company=ACME

B: Export-Package: com.acme.foo; «
  company="ACME"; «
  security=false

Attribute values are compared string wise except for the version and bundle-version attributes which use version range comparisons. Leading and trailing white space in attribute values must be ignored.

请注意,我只引用了这些章节的部分内容。你应该检查规范中的原始内容。

我认为这些属性在 Equinox 的代码中没有以特定方式处理。如果有多个包同名,它们可以用在 Import-Pacakge 子句中。