Class AbstractThingHandlerDiscoveryService<T extends ThingHandler>
java.lang.Object
org.openhab.core.config.discovery.AbstractDiscoveryService
org.openhab.core.config.discovery.AbstractThingHandlerDiscoveryService<T>
- All Implemented Interfaces:
DiscoveryService
,ThingHandlerService
@NonNullByDefault
public abstract class AbstractThingHandlerDiscoveryService<T extends ThingHandler>
extends AbstractDiscoveryService
implements ThingHandlerService
The
AbstractThingHandlerDiscoveryService
extends the AbstractDiscoveryService
for thing-based
discovery services.
It handles the injection of the ThingHandler
- Author:
- Jan N. Klug - Initial contribution, Laurent Garnier - Added discovery with an optional input parameter
-
Field Summary
Fields inherited from class org.openhab.core.config.discovery.AbstractDiscoveryService
i18nProvider, localeProvider, scanListener, scheduler
Fields inherited from interface org.openhab.core.config.discovery.DiscoveryService
CONFIG_PROPERTY_BACKGROUND_DISCOVERY
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractThingHandlerDiscoveryService
(Class<T> thingClazz, int timeout) protected
AbstractThingHandlerDiscoveryService
(Class<T> thingClazz, @Nullable Set<ThingTypeUID> supportedThingTypes, int timeout) protected
AbstractThingHandlerDiscoveryService
(Class<T> thingClazz, @Nullable Set<ThingTypeUID> supportedThingTypes, int timeout, boolean backgroundDiscoveryEnabledByDefault) protected
AbstractThingHandlerDiscoveryService
(Class<T> thingClazz, @Nullable Set<ThingTypeUID> supportedThingTypes, int timeout, boolean backgroundDiscoveryEnabledByDefault, @Nullable String scanInputLabel, @Nullable String scanInputDescription) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Called on component activation, if the implementation of this class is an OSGi declarative service and does not override the method.void
Called on component deactivation, if the implementation of this class is an OSGi declarative service and does not override the method.void
dispose()
This method is used by the framework during de-activation of the service.@Nullable ThingHandler
Gets the ThingHandler on which the actions (methods) should be calledvoid
This method is used by the framework during activation of the service.void
Called when the configuration for the discovery service is changed.void
setThingHandler
(ThingHandler handler) Sets the ThingHandler on which the actions (methods) should be calledprotected abstract void
This method is called by theAbstractDiscoveryService.startScan(ScanListener)
implementation of theAbstractDiscoveryService
.Methods inherited from class org.openhab.core.config.discovery.AbstractDiscoveryService
abortScan, addDiscoveryListener, getLocalizedDiscoveryResult, getScanInputDescription, getScanInputLabel, getScanTimeout, getSupportedThingTypes, getTimestampOfLastScan, isBackgroundDiscoveryEnabled, isScanInputSupported, removeDiscoveryListener, removeOlderResults, removeOlderResults, removeOlderResults, startBackgroundDiscovery, startScan, startScan, startScan, stopBackgroundDiscovery, stopScan, thingDiscovered, thingRemoved
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.openhab.core.thing.binding.ThingHandlerService
activate
-
Field Details
-
thingHandler
-
-
Constructor Details
-
AbstractThingHandlerDiscoveryService
protected AbstractThingHandlerDiscoveryService(Class<T> thingClazz, @Nullable Set<ThingTypeUID> supportedThingTypes, int timeout, boolean backgroundDiscoveryEnabledByDefault, @Nullable String scanInputLabel, @Nullable String scanInputDescription) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
AbstractThingHandlerDiscoveryService
protected AbstractThingHandlerDiscoveryService(Class<T> thingClazz, @Nullable Set<ThingTypeUID> supportedThingTypes, int timeout, boolean backgroundDiscoveryEnabledByDefault) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
AbstractThingHandlerDiscoveryService
protected AbstractThingHandlerDiscoveryService(Class<T> thingClazz, @Nullable Set<ThingTypeUID> supportedThingTypes, int timeout) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
AbstractThingHandlerDiscoveryService
protected AbstractThingHandlerDiscoveryService(Class<T> thingClazz, int timeout) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
-
Method Details
-
startScan
protected abstract void startScan()Description copied from class:AbstractDiscoveryService
This method is called by theAbstractDiscoveryService.startScan(ScanListener)
implementation of theAbstractDiscoveryService
. The abstract class schedules a call ofAbstractDiscoveryService.stopScan()
afterAbstractDiscoveryService.getScanTimeout()
seconds. If this behavior is not appropriate, theAbstractDiscoveryService.startScan(ScanListener)
method should be overridden.- Specified by:
startScan
in classAbstractDiscoveryService
-
setThingHandler
Description copied from interface:ThingHandlerService
Sets the ThingHandler on which the actions (methods) should be called- Specified by:
setThingHandler
in interfaceThingHandlerService
- Parameters:
handler
- theThingHandler
-
getThingHandler
Description copied from interface:ThingHandlerService
Gets the ThingHandler on which the actions (methods) should be called- Specified by:
getThingHandler
in interfaceThingHandlerService
- Returns:
- the
ThingHandler
-
activate
Description copied from class:AbstractDiscoveryService
Called on component activation, if the implementation of this class is an OSGi declarative service and does not override the method. The method implementation callsAbstractDiscoveryService.startBackgroundDiscovery()
if background discovery is enabled by default and not overridden by the configuration.- Overrides:
activate
in classAbstractDiscoveryService
- Parameters:
config
- configuration properties
-
modified
Description copied from class:AbstractDiscoveryService
Called when the configuration for the discovery service is changed. If background discovery should be enabled and is currently disabled, the methodAbstractDiscoveryService.startBackgroundDiscovery()
is called. If background discovery should be disabled and is currently enabled, the methodAbstractDiscoveryService.stopBackgroundDiscovery()
is called. In all other cases, nothing happens.- Overrides:
modified
in classAbstractDiscoveryService
- Parameters:
config
- configuration properties
-
deactivate
public void deactivate()Description copied from class:AbstractDiscoveryService
Called on component deactivation, if the implementation of this class is an OSGi declarative service and does not override the method. The method implementation callsAbstractDiscoveryService.stopBackgroundDiscovery()
if background discovery is enabled at the time of component deactivation.- Specified by:
deactivate
in interfaceThingHandlerService
- Overrides:
deactivate
in classAbstractDiscoveryService
-
initialize
public void initialize()Description copied from interface:ThingHandlerService
This method is used by the framework during activation of the service. It is called AFTER the component is fully activated and thing handler has been set. Implementations should override this method to add additional initialization code. This method should callsuper.initialize()
to ensure background discovery is properly handled. SeeThingHandlerService.activate()
,ThingHandlerService.dispose()
- Specified by:
initialize
in interfaceThingHandlerService
-
dispose
public void dispose()Description copied from interface:ThingHandlerService
This method is used by the framework during de-activation of the service. It is called while the component is still activated. Code depending on an activated service should go here. This method should callsuper.dispose()
to ensure background discovery is properly handled. SeeThingHandlerService.deactivate()
,ThingHandlerService.initialize()
- Specified by:
dispose
in interfaceThingHandlerService
-