OSGi控制台“ ls -c”:尽管没有提供程序,但绑定了引用

时间:2018-11-12 16:01:56

标签: osgi declarative-services

在调试服务绑定问题时,我调用了命令ls -c(或等效的list -c),并为组件获取了以下输出:

21      Component[
        name = org.example.myproject.repo
        activate = activate
        deactivate = deactivate
        modified =
        configuration-policy = optional
        factory = null
        autoenable = true
        immediate = true
        implementation = org.example.myproject.RepositoryServiceHandler
        state = Unsatisfied
        properties =
        serviceFactory = false
        serviceInterface = null
        references = {
                Reference[name = Repository, interface = org.example.core.repository.api.Repository, policy = static, cardinality = 1..1, target = null, bind = bindRepository, unbind = unbindRepository]
                Reference[name = IRepositoryClient, interface = org.example.core.repository.client.RepositoryClient, policy = static, cardinality = 1..1, target = null, bind = bindRepositoryClient, unbind = unbindRepositoryClient]
        }
        located in bundle = org.example.myproject_0.20.1348.3 [30]
]
Dynamic information :
  The component is satisfied
  All component references are satisfied
  Component configurations :
    Configuration properties:
      component.name = org.example.myproject.repo
      component.id = 34
    Instances:
      org.eclipse.equinox.internal.ds.impl.ComponentInstanceImpl@75b98b5a
        Bound References:
        String[org.example.core.repository.client.RepositoryClient]
                -> org.example.core.repository.client.impl.RepositoryClientImpl@67680c91
        String[org.example.core.repository.api.Repository]
                -> org.example.core.repository.api.impl.RepositoryImpl@1c27ecd6

我想找到提供接口org.example.core.repository.client.RepositoryClient的捆绑包,因此搜索了ls -c的完整输出。令我惊讶的是,没有其他情况出现(即,组件中只有两个引用)。

怎么可能没有提供者,但是服务仍然绑定?

应该不包含带有serviceInterface = org.example.core.repository.client.RepositoryClient的提供程序组件?

1 个答案:

答案 0 :(得分:1)

过一会儿,我自己想出了解决方案,但我想如果其他人遇到相同的问题,我仍然可以在这里共享它。

我找不到服务提供者的原因是ls -c仅列出通过声明性服务注册的服务。相反,该服务是通过程序注册的,因此未在ls -c中列出。

要搜索所有服务提供商,需要使用service命令:

osgi> services (objectClass=org.example.core.repository.client.RepositoryClient)

{org.example.core.repository.client.RepositoryClient}={service.id=83}
  Registered by bundle: org.example.core.repository.client_1.2.102 [45]
  Bundles using service:
    org.example.myproject_0.20.1348.3 [30]