Interface ThingHandlerFactory

All Known Implementing Classes:
BaseThingHandlerFactory

@NonNullByDefault public interface ThingHandlerFactory
The ThingHandlerFactory is responsible for creating Things and ThingHandlers. Therefore the factory must be registered as OSGi service.
Author:
Dennis Nobel - Initial contribution, Stefan Bußweiler - API changes due to bridge/thing life cycle refactoring
  • Method Details

    • supportsThingType

      boolean supportsThingType(ThingTypeUID thingTypeUID)
      Returns whether the handler is able to create a thing or register a thing handler for the given type.
      Parameters:
      thingTypeUID - the thing type UID
      Returns:
      true, if the handler supports the thing type, false otherwise
    • registerHandler

      ThingHandler registerHandler(Thing thing)
      Creates a new ThingHandler instance. In addition, the handler can be registered as a service if it is required, e.g. as FirmwareUpdateHandler, ConfigStatusProvider.

      This method is only called if the ThingHandlerFactory supports the type of the given thing.

      The framework expects this method to be non-blocking and return quickly.

      Parameters:
      thing - the thing for which a new handler must be registered
      Returns:
      the created thing handler instance, not null
      Throws:
      IllegalStateException - if the handler instance could not be created
    • unregisterHandler

      void unregisterHandler(Thing thing)
      Unregisters a ThingHandler instance.

      The framework expects this method to be non-blocking and return quickly.

      Parameters:
      thing - the thing for which the handler must be unregistered
    • createThing

      @Nullable Thing createThing(ThingTypeUID thingTypeUID, Configuration configuration, @Nullable ThingUID thingUID, @Nullable ThingUID bridgeUID)
      Creates a thing for given arguments.
      Parameters:
      thingTypeUID - thing type uid (not null)
      configuration - configuration
      thingUID - thing uid, which can be null
      bridgeUID - bridge uid, which can be null
      Returns:
      created thing
    • removeThing

      void removeThing(ThingUID thingUID)
      A thing with the given Thing UID was removed.
      Parameters:
      thingUID - thing UID of the removed object