Search code examples
listserviceosgi

is there a way to view registered services in an OSGi application?


I have an OSGi application running Equinox. I'd like to see the services that are provided by the application. How can I do this?


Solution

  • It depends whether you mean interactively, using an OSGi shell, or programmatically from your application.

    Interactively

    You can use the Equinox console. See 'services'. To only see the services you have deployed you need to use an LDAP filter. Here's an example:

    (objectClass=my.package.name.*)
    

    Also see @Neil Bartlett's answer which might be easier as you can just constrain by bundle id (assuming you know it, but that's easy to find).

    Programatically

    Use the ServiceTracker approach. Neil also wrote all about this, so make sure to give him your upvotes too :)