Tuesday, 29 October 2013

Debugging OSGi services

This post is a collection of tips of how to "debug" into OSGi services, grouped by the providers I am using. I will keep updating this whenever I find something new.

Apache Felix Declarative Services

Setup:

Active     |    5|Apache Felix Log Service (1.0.1)
Active     |    5|Apache Felix Declarative Services (1.6.2)
Active     |    5|Apache Felix EventAdmin (1.3.2)
Active     |    3|Apache Felix Configuration Admin Service (1.4.0)
Active     |    3|Apache Felix File Install (3.2.4)
Active     |    1|Apache Felix Gogo Command (0.12.0)
Active     |    1|Apache Felix Gogo Runtime (0.10.0)
Active     |    1|Apache Felix Gogo Shell (0.10.0)

Hint: I didn't get the scr shell commands with Declarative Services 1.6.0. Also, not all of the listed bundles might be necessary, this is just my setup.

scr:list will give you something like this:

[   1] [active       ] de.twenty11.skysail.server.config.ServerConfiguration
[   4] [active       ] de.twenty11.skysail.server.webapp.internal.WebappApplication
[   3] [active       ] de.twenty11.skysail.server.internal.Events
[   0] [active       ] de.twenty11.skysail.common.config.ConfigurationProvider
[   2] [active       ] de.twenty11.skysail.server.internal.Configuration


Now pick the id of the component you are interested in and type, for example,

scr:info 2

You will get all the details of the component, together with the information if all the requirements are satisfied (so that the component is actually active):

(...)
Reference: ApplicationProvider
    Satisfied: satisfied
    Service Name: de.twenty11.skysail.server.services.ApplicationProvider
    Multiple: multiple
    Optional: optional
    Policy: dynamic
    Policy option: reluctant
    Bound to:        [de.twenty11.skysail.server.services.ApplicationProvider]
        [de.twenty11.skysail.server.services.ApplicationProvider]
        [de.twenty11.skysail.server.services.ApplicationProvider]
        [de.twenty11.skysail.server.services.ApplicationProvider]
        [de.twenty11.skysail.server.services.ApplicationProvider]
Reference: MenuProvider
    Satisfied: satisfied
    Service Name: de.twenty11.skysail.server.services.MenuProvider
    Multiple: multiple
    Optional: optional
    Policy: dynamic
    Policy option: reluctant
    Bound to:        [de.twenty11.skysail.server.services.MenuProvider]
        [de.twenty11.skysail.server.services.MenuProvider]


help, as always, gives you the available commands:

scr:config
scr:disable
scr:enable
scr:info
scr:list

Reference: Felix Declarative Services Documentation