OSGI Dependent services injection on OH2

Hi!

I’m developing one binding that have one central service, and this service should be injected into the DiscoveryService and into my HandlerFactory.
There is any guideline to inject one dependent service into another service? How this can be done in openhab?

Thanks,

Regards,

Make your service a bridge and use that bridge in all your things. I just did that and it worked great.

Check out https://github.com/openhab/openhab2-addons/pull/2413/files

It is described in the docs:

http://docs.openhab.org/developers/prerequisites/osgids.html

You basically reference in your own OSGI xml the needed services like in this example:

  <reference 
        interface="org.osgi.service.log.LogService"
        bind="setLog"
        unbind="unsetLog"
        cardinality="1..1"
        policy="static"
    />

and implement, in this case, a setLog and unsetLog method.

Cheers,
David

Thanks!
Allready done it: