use of org.eclipse.smarthome.binding.mqtt.handler.BrokerHandler in project smarthome by eclipse.
the class MqttBrokerHandlerFactory method createHandler.
@Override
@Nullable
protected ThingHandler createHandler(Thing thing) {
if (mqttService == null) {
throw new IllegalStateException("MqttService must be bound, before ThingHandlers can be created");
}
if (!(thing instanceof Bridge)) {
throw new IllegalStateException("A bridge type is expected");
}
final ThingTypeUID thingTypeUID = thing.getThingTypeUID();
final AbstractBrokerHandler handler;
if (thingTypeUID.equals(MqttBindingConstants.BRIDGE_TYPE_SYSTEMBROKER)) {
handler = new SystemBrokerHandler((Bridge) thing, mqttService);
} else if (thingTypeUID.equals(MqttBindingConstants.BRIDGE_TYPE_BROKER)) {
handler = new BrokerHandler((Bridge) thing);
} else {
throw new IllegalStateException("Not supported " + thingTypeUID.toString());
}
createdHandler(handler);
return handler;
}
Aggregations