无法使用bndtools启动声明式服务(DS)组件

时间:2015-09-09 20:14:35

标签: osgi declarative-services bnd bndtools

我已经安装了eclipse的标准bndtools插件,并运行了apache felix osgi运行时。我正在尝试了解声明性服务(DS)组件。显然,在有注释之前(在bndtools教程中给出了一个例子),组件是使用xml数据编写的。这就是我想要做的。

这是一个简单的类(将作为DS组件发布):" HelloComponent.java"

package org.osgi.book.ds.minimal;

public class HelloComponent {
    public HelloComponent(){
        System.out.println("HelloComponent created.");
    }
}

以下是制作组件声明的xml文件:" minimal.xml"

<?xml version="1.0" encoding="UTF-8"?>
<!-- minimal.xml -->

<scr:component xmlns:scr="http://www.osgi.org/xlmns/scr/v1.1.0" immediate="true">
    <implementation class="org.osgi.book.ds.minimal.HelloComponent"/>
</scr:component>

这是.bnd文件,它应该由bndtools用来生成最终将发布到OSGi运行时的jar文件:&#34; minimal_ds.bnd&#34;

Private-Package: org.osgi.book.ds.minimal

Include-Resource: minimal.xml
Service-Component: minimal.xml

请注意,我在主机运行时OSGi容器中启动并运行以下捆绑包:

   ID|State      |Level|Name
    0|Active     |    0|System Bundle (4.4.1)
    2|Active     |    1|Apache Felix Gogo Command (0.14.0)
    3|Active     |    1|Apache Felix Gogo Runtime (0.12.1)
    4|Active     |    1|Apache Felix Gogo Shell (0.10.0)
    5|Active     |    1|BookReaderOSGiInPractice.minimal_ds (0.0.0.201509091856)
   15|Active     |    1|Apache Felix Configuration Admin Service (1.8.0)
   16|Active     |    1|Apache Felix Declarative Services (1.8.2)
   17|Active     |    1|osgi.enterprise (4.2.0.201003190513)
   18|Active     |    1|osgi.residential (4.3.0.201111022239)

尽管一切都在积极运行,但我无法弄清楚为什么DS组件没有被初始化(我应该看到控制台输出:&#34; HelloComponent创建。&#34;)。任何帮助表示赞赏。

最后,这是项目目录结构:

BookReaderInPractice
|
|- src
|   |- org.osgi.book.ds.minimal
|           |_ HelloComponent.java
|
|- minimal_ds.bnd
|
|- minimal.xml

0 个答案:

没有答案
相关问题