Package org.openhab.core.thing.binding
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 Summary
Modifier and TypeMethodDescription@Nullable ThingcreateThing(ThingTypeUID thingTypeUID, Configuration configuration, @Nullable ThingUID thingUID, @Nullable ThingUID bridgeUID) Creates a thing for given arguments.registerHandler(Thing thing) Creates a newThingHandlerinstance.voidremoveThing(ThingUID thingUID) A thing with the givenThingUID was removed.booleansupportsThingType(ThingTypeUID thingTypeUID) Returns whether the handler is able to create a thing or register a thing handler for the given type.voidunregisterHandler(Thing thing) Unregisters aThingHandlerinstance.
-
Method Details
-
supportsThingType
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
Creates a newThingHandlerinstance. In addition, the handler can be registered as a service if it is required, e.g. asFirmwareUpdateHandler,ConfigStatusProvider.This method is only called if the
ThingHandlerFactorysupports 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
Unregisters aThingHandlerinstance.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- configurationthingUID- thing uid, which can be nullbridgeUID- bridge uid, which can be null- Returns:
- created thing
-
removeThing
A thing with the givenThingUID was removed.- Parameters:
thingUID- thing UID of the removed object
-