class ThingManagerImpl implements ThingManager, ThingTracker, ThingTypeMigrationService, ReadyService.ReadyTracker {

    @Override
    public void setEnabled(ThingUID thingUID, boolean enabled) {
        Thing thing = getThing(thingUID);

        persistThingEnableStatus(thingUID, enabled);

        if (thing == null) {
            logger.debug("Thing with the UID {} is unknown, cannot set its enabled status.", thingUID);
            return;
        }

        if (enabled) {
            // Enable a thing
            if (thing.isEnabled()) {
                logger.debug("Thing {} is already enabled.", thingUID);
                return;
            }

            logger.debug("Thing {} will be enabled.", thingUID);

            if (isHandlerRegistered(thing)) {
                // A handler is already registered for that thing. Try to initialize it.
                initializeHandler(thing);
            } else {
                // No handler registered. Try to register handler and initialize the thing.
                registerAndInitializeHandler(thing, findThingHandlerFactory(thing.getThingTypeUID()));
                // Check if registration was successful
                if (!hasBridge(thing) && !isHandlerRegistered(thing)) {
                    setThingStatus(thing,
                            buildStatusInfo(ThingStatus.UNINITIALIZED, ThingStatusDetail.HANDLER_MISSING_ERROR));
                }
            }
        } else {
            if (!thing.isEnabled()) {
                logger.debug("Thing {} is already disabled.", thingUID);
                return;
            }

            logger.debug("Thing {} will be disabled.", thingUID);

            boolean disposed = false;

            if (isHandlerRegistered(thing)) {
                // Dispose handler if registered.
                ThingHandler thingHandler = thing.getHandler();
                ThingHandlerFactory thingHandlerFactory = findThingHandlerFactory(thing.getThingTypeUID());
                if (thingHandler != null && thingHandlerFactory != null) {
                    unregisterAndDisposeHandler(thingHandlerFactory, thing, thingHandler);
                    disposed = true;
                }
            }

            if (!disposed) {
                // Only set the correct status to the thing. There is no handler to be disposed
                setThingStatus(thing, buildStatusInfo(ThingStatus.UNINITIALIZED, ThingStatusDetail.DISABLED));
            }

            if (isBridge(thing)) {
                updateChildThingStatusForDisabledBridges((Bridge) thing);
            }
        }
    }

    @Activate public  ThingManagerImpl( //
            final @Reference BundleResolver bundleResolver,
            final @Reference ChannelGroupTypeRegistry channelGroupTypeRegistry,
            final @Reference ChannelTypeRegistry channelTypeRegistry,
            final @Reference CommunicationManager communicationManager,
            final @Reference ConfigDescriptionRegistry configDescriptionRegistry,
            final @Reference ConfigDescriptionValidator configDescriptionValidator,
            final @Reference EventPublisher eventPublisher,
            final @Reference ItemChannelLinkRegistry itemChannelLinkRegistry,
            final @Reference ReadyService readyService, //
            final @Reference SafeCaller safeCaller, //
            final @Reference StorageService storageService, //
            final @Reference ThingRegistry thingRegistry,
            final @Reference ThingStatusInfoI18nLocalizationService thingStatusInfoI18nLocalizationService,
            final @Reference ThingTypeRegistry thingTypeRegistry);

}