如何在OSGI声明性服务中将Service-Component标头添加到bundle清单文件中?

san*_*re6 3 osgi apache-felix bnd

我正在使用OSGI声明性服务(SCR)来创建组件包.我并不热衷于使用maven-scr-plugin生成的基于注释的组件xml文件.我正在手工编写component.xml.但是,我需要将Service-Component标头添加到MANIFEST文件中.我正在使用maven-bundle-plugin来构建osgi包,我可以在插件配置中给出任何指令,将这些头添加到清单文件中?

一些有用的链接:

费利克斯 - SCR

Maven的SCR-插件

BND服务组件

谢谢

Hol*_*ins 8

可以进入清单文件的任何标头都可以作为元素进入bundle插件的配置.例如,

<plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>2.2.0</version>
        <extensions>true</extensions>
        <configuration>
            <instructions>
                <Bundle-SymbolicName>
                  ${pom.artifactId}
                </Bundle-SymbolicName>
                <Service-Component>
                 OSGI-INF/some-file.xml
                </Service-Component>
                ....
Run Code Online (Sandbox Code Playgroud)

<extensions>true</extensions>行启用了任意自定义标头,但我认为Service-Component包含在已知标头集中,因此这里不需要它.

  • maven-bundle插件只是传递了标题,它没有做任何事情.这实际上并不完全正确,因为您还可以在标题中定义组件.请参阅http://www.aqute.biz/Bnd/Components好奇为什么您不想使用bnd注释? (2认同)