不满意的OSGI组件

时间:2015-09-08 14:43:49

标签: java osgi

我有一个不满意的OSGI组件,并且不能理解为什么会这样

我的服务定义如下:

<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0"
    immediate="true" enabled="true" name="MyService">
    <implementation class="com.example.MyService" />
    <reference name="HttpService" interface="org.osgi.service.http.HttpService"
        cardinality="1..1" policy="dynamic" bind="setHttpService" unbind="unsetHttpService" />
    <service>
        <provide interface="com.example.MyService" />
    </service>
</scr:component>  

在我的OSGI控制台中,我看到:

osgi> comp 7
    Component[
    name = MyService
    activate = activate
    deactivate = deactivate
    modified = 
    configuration-policy = optional
    factory = null
    autoenable = true
    immediate = true
    implementation = com.example.MyService
    state = Unsatisfied
    properties = 
    serviceFactory = false
    serviceInterface = [com.example.MyService]
    references = {
        Reference[name = HttpService, interface = org.osgi.service.http.HttpService, policy = dynamic, cardinality = 1..1, target = null, bind = setHttpService, unbind = unsetHttpService]
    }
    located in bundle = com.example.MyService_1.00.0
]
Dynamic information :
  *The component is NOT satisfied
  The following references are not satisfied:
    Reference[name = HttpService, interface = org.osgi.service.http.HttpService, policy = dynamic, cardinality = 1..1, target = null, bind = setHttpService, unbind = unsetHttpService]
  Component configurations :
    Configuration properties:
      component.name = MyService
      component.id = 5
      objectClass = String[com.example.MyService]
    Instances:

osgi> 

这是什么意思,我该如何解决这个问题?

3 个答案:

答案 0 :(得分:1)

您的组件具有对服务HashMap<Integer, String> mMarilynManson = new HashMap<Integer, String>(); mMarilynManson.put(82,"d5c820e90ab46626aed6fg70038424b63f"); mMarilynManson.put(83,"410862c61aa32b14419c43dsf03e84a42f"); mMarilynManson.put(84,"922e09adc85b9c9dd5bgg75b84d809c5f3"); 的强制引用。显然,服务注册表中没有可用的HttpService。因此,您的组件不满意。

这可以通过安装HttpService实现来修复,例如org.apache.felix.http.jetty。文档可用here

答案 1 :(得分:0)

是否注册了org.osgi.service.http.HttpService服务?

答案 2 :(得分:-1)

您将“com.example.MyService”定义为您的实现类和接口。