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?
Make your service a bridge and use that bridge in all your things. I just did that and it worked great.
It is described in the docs:
You basically reference in your own OSGI xml the needed services like in this example:
and implement, in this case, a
Allready done it:
This file has been truncated.
<?xml version="1.0" encoding="UTF-8"?>
Copyright (c) 2010-2018 by the respective copyright holders.
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License v1.0
which accompanies this distribution, and is available at
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.openhab.binding.silvercrestwifisocket.internal.SilvercrestWifiSocketHandlerFactory">
name="mediator" policy="static" bind="setMediator" cardinality="1..1" unbind="unsetMediator"/>