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

From the gogo shell type:

inspect cap service

That will show all services registered by all bundles. If you want to show services for a specific bundle then type:

inspect cap service <id>

Where <id> is the numeric bundle ID of the bundle you are interested in.


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 :)

Tags:

List

Service

Osgi