Interface DiscoveryServiceRegistry
DiscoveryServiceRegistry
is a service interface which provides
the following features.
- Monitoring of
DiscoveryService
s - Direct accessing monitored
DiscoveryService
s - Forwarding all events received from the monitored
DiscoveryService
s.
- Author:
- Michael Grammling - Initial contribution, Ivaylo Ivanov - Added getMaxScanTimeout, Laurent Garnier - Added discovery with an optional input parameter
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Aborts a started discovery on allDiscoveryService
s for the given binding id.boolean
abortScan
(ThingTypeUID thingTypeUID) Aborts a started discovery on allDiscoveryService
s for the given thing type.void
addDiscoveryListener
(DiscoveryListener listener) Adds aDiscoveryListener
to the listeners' registry.getDiscoveryServices
(String bindingId) Returns the list of allDiscoveryService
s, that discover thing types of the given binding id.int
getMaxScanTimeout
(String bindingId) Returns the maximum discovery timeout from all discovery services registered for the specified binding idint
getMaxScanTimeout
(ThingTypeUID thingTypeUID) Returns the maximum discovery timeout from all discovery services registered for the specified thingTypeUIDReturns a list of bindings, that support discovery.Returns a list of thing types, that support discovery.void
removeDiscoveryListener
(DiscoveryListener listener) Removes aDiscoveryListener
from the listeners' registry.boolean
startScan
(String bindingId, @Nullable String input, @Nullable ScanListener listener) Forces the associatedDiscoveryService
s to start a discovery for all thing types of the given binding id.boolean
startScan
(ThingTypeUID thingTypeUID, @Nullable String input, @Nullable ScanListener listener) Forces the associatedDiscoveryService
s to start a discovery.boolean
supportsDiscovery
(String bindingId) Returns true if the given binding id supports discovery for at least one thing type.boolean
supportsDiscovery
(ThingTypeUID thingTypeUID) Returns true if the given thing type UID supports discovery, false otherwise.
-
Method Details
-
startScan
boolean startScan(ThingTypeUID thingTypeUID, @Nullable String input, @Nullable ScanListener listener) Forces the associatedDiscoveryService
s to start a discovery.Returns
true
, if at least oneDiscoveryService
could be found and forced to start a discovery, otherwisefalse
. If the discovery process has already been started before,true
is returned.- Parameters:
thingTypeUID
- the Thing type UID pointing to collection of discovery services to be forced to start a discoveryinput
- an optional input parameter to be used during discovery scan, can be null.listener
- a callback to inform about errors or termination, can be null. If more than one discovery service is started, theScanListener.onFinished()
callback is called after all discovery services finished their scan. If one discovery service raises an error, the methodScanListener.onErrorOccurred(Exception)
is called directly. All other finished or error callbacks will be ignored and not forwarded to the listener.- Returns:
- true if a t least one discovery service could be found and forced to start a discovery, otherwise false
-
startScan
Forces the associatedDiscoveryService
s to start a discovery for all thing types of the given binding id.Returns
true
, if at least oneDiscoveryService
could be found and forced to start a discovery, otherwisefalse
.- Parameters:
bindingId
- the binding id pointing to one or more discovery services to be forced to start a discoveryinput
- an optional input parameter to be used during discovery scan, can be null.listener
- a callback to inform about errors or termination, can be null. If more than one discovery service is started, theScanListener.onFinished()
callback is called after all discovery services finished their scan. If one discovery service raises an error, the methodScanListener.onErrorOccurred(Exception)
is called directly. All other finished or error callbacks will be ignored and not forwarded to the listener.- Returns:
- true if a t least one discovery service could be found and forced to start a discovery, otherwise false
-
abortScan
Aborts a started discovery on allDiscoveryService
s for the given thing type.Returns
true
, if at least oneDiscoveryService
could be found and all found discoveries could be aborted, otherwisefalse
. If the discovery process has not been started before,true
is returned.- Parameters:
thingTypeUID
- the Thing type UID whose discovery scans should be aborted- Returns:
- true if at least one discovery service could be found and all discoveries could be aborted, otherwise false
-
abortScan
Aborts a started discovery on allDiscoveryService
s for the given binding id.Returns
true
, if at least oneDiscoveryService
could be found and all found discoveries could be aborted, otherwisefalse
. If the discovery process has not been started before,true
is returned.- Parameters:
bindingId
- the binding id whose discovery scans should be aborted- Returns:
- true if at least one discovery service could be found and all discoveries could be aborted, otherwise false
-
supportsDiscovery
Returns true if the given thing type UID supports discovery, false otherwise.- Parameters:
thingTypeUID
- thing type UID- Returns:
- true if the given thing type UID supports discovery, false otherwise
-
supportsDiscovery
Returns true if the given binding id supports discovery for at least one thing type.- Parameters:
bindingId
- bindingId- Returns:
- true if the given binding id supports discovery, false otherwise
-
addDiscoveryListener
Adds aDiscoveryListener
to the listeners' registry.When a
DiscoveryResult
is created by any of the monitoredDiscoveryService
s, (e.g. by forcing the startup of the discovery process or while enabling the auto discovery mode), the specified listener is notified.This method returns silently if the specified listener has already been registered before.
- Parameters:
listener
- the listener to be added
-
removeDiscoveryListener
Removes aDiscoveryListener
from the listeners' registry.When this method returns, the specified listener is no longer notified about
DiscoveryResult
s created by any of the monitoredDiscoveryService
s (e.g. by forcing the startup of the discovery process or while enabling the auto discovery mode).This method returns silently if the specified listener has not been registered before.
- Parameters:
listener
- the listener to be removed
-
getSupportedThingTypes
List<ThingTypeUID> getSupportedThingTypes()Returns a list of thing types, that support discovery.- Returns:
- list of thing types, that support discovery
-
getSupportedBindings
Returns a list of bindings, that support discovery.- Returns:
- list of bindings, that support discovery
-
getDiscoveryServices
Returns the list of allDiscoveryService
s, that discover thing types of the given binding id.- Returns:
- list of discovery services, that discover thing types of the given binding id
- Throws:
IllegalStateException
-
getMaxScanTimeout
Returns the maximum discovery timeout from all discovery services registered for the specified thingTypeUID- Parameters:
thingTypeUID
- thing type UID- Returns:
- the maximum amount of seconds which the discovery can take
-
getMaxScanTimeout
Returns the maximum discovery timeout from all discovery services registered for the specified binding id- Parameters:
bindingId
- id of the binding- Returns:
- the maximum amount of seconds which the discovery can take
-