jmv_driver
(Jaime Vaz)
February 11, 2017, 1:31pm
1
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,
holmes.j
(Jason Holmes)
July 9, 2017, 9:07pm
2
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:
<?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
http://www.eclipse.org/legal/epl-v10.html
-->
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.openhab.binding.silvercrestwifisocket.internal.SilvercrestWifiSocketHandlerFactory">
<implementation class="org.openhab.binding.silvercrestwifisocket.internal.SilvercrestWifiSocketHandlerFactory"/>
<service>
<provide interface="org.eclipse.smarthome.core.thing.binding.ThingHandlerFactory"/>
</service>
<reference interface="org.openhab.binding.silvercrestwifisocket.handler.SilvercrestWifiSocketMediator"
name="mediator" policy="static" bind="setMediator" cardinality="1..1" unbind="unsetMediator"/>
This file has been truncated. show original