Консоль OSGi "ls -c": ссылки связаны, хотя провайдера нет - PullRequest
0 голосов
/ 12 ноября 2018

При отладке проблем с привязкой службы я вызвал команду 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 голосов
/ 12 ноября 2018

Через некоторое время я сам нашел решение, но подумал, что смогу поделиться им здесь, если у других возникнет такая же проблема.

Причина, по которой я не нашел поставщика услуг, заключается в том, что 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]
...