osgideclarative-services

OSGi console "ls -c": References are bound although there is no provider


While debugging service binding issues, I called the command ls -c (or equivalent list -c) and got the following output for my component:

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

I wanted to find the bundle that provides the interface org.example.core.repository.client.RepositoryClient and therefore searched the complete output of ls -c. To my surprise, there were no other occurrences (i.e. only the two references in my component).

How is it possible that there is no provider, but the service is still bound? Shouldn't there be a provider component with serviceInterface = org.example.core.repository.client.RepositoryClient?


Solution

  • I figured out the solution myself after a while, but I thought I might still share it here in case others have the same problem.

    The reason that I didn't find the service provider is that ls -c only lists services registered via declarative services. Instead, the service was registered programmatically, and therefore not listed by ls -c.

    To search all service providers, the service command needs to be used:

    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]