Interface DiscoveryServiceRegistry


@NonNullByDefault public interface DiscoveryServiceRegistry
The DiscoveryServiceRegistry is a service interface which provides the following features.
Author:
Michael Grammling - Initial contribution, Ivaylo Ivanov - Added getMaxScanTimeout, Laurent Garnier - Added discovery with an optional input parameter
See Also:
  • Method Details

    • startScan

      boolean startScan(ThingTypeUID thingTypeUID, @Nullable String input, @Nullable ScanListener listener)
      Forces the associated DiscoveryServices to start a discovery.

      Returns true, if at least one DiscoveryService could be found and forced to start a discovery, otherwise false. 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 discovery
      input - 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, the ScanListener.onFinished() callback is called after all discovery services finished their scan. If one discovery service raises an error, the method ScanListener.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

      boolean startScan(String bindingId, @Nullable String input, @Nullable ScanListener listener)
      Forces the associated DiscoveryServices to start a discovery for all thing types of the given binding id.

      Returns true, if at least one DiscoveryService could be found and forced to start a discovery, otherwise false.

      Parameters:
      bindingId - the binding id pointing to one or more discovery services to be forced to start a discovery
      input - 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, the ScanListener.onFinished() callback is called after all discovery services finished their scan. If one discovery service raises an error, the method ScanListener.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

      boolean abortScan(ThingTypeUID thingTypeUID)
      Aborts a started discovery on all DiscoveryServices for the given thing type.

      Returns true, if at least one DiscoveryService could be found and all found discoveries could be aborted, otherwise false . 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

      boolean abortScan(String bindingId)
      Aborts a started discovery on all DiscoveryServices for the given binding id.

      Returns true, if at least one DiscoveryService could be found and all found discoveries could be aborted, otherwise false . 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

      boolean supportsDiscovery(ThingTypeUID thingTypeUID)
      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

      boolean supportsDiscovery(String bindingId)
      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

      void addDiscoveryListener(DiscoveryListener listener)
      Adds a DiscoveryListener to the listeners' registry.

      When a DiscoveryResult is created by any of the monitored DiscoveryServices, (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

      void removeDiscoveryListener(DiscoveryListener listener)
      Removes a DiscoveryListener from the listeners' registry.

      When this method returns, the specified listener is no longer notified about DiscoveryResults created by any of the monitored DiscoveryServices (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

      List<String> getSupportedBindings()
      Returns a list of bindings, that support discovery.
      Returns:
      list of bindings, that support discovery
    • getDiscoveryServices

      Set<DiscoveryService> getDiscoveryServices(String bindingId) throws IllegalStateException
      Returns the list of all DiscoveryServices, 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

      int getMaxScanTimeout(ThingTypeUID thingTypeUID)
      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

      int getMaxScanTimeout(String bindingId)
      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