use of org.eclipse.smarthome.config.discovery.inbox.InboxListener in project smarthome by eclipse.
the class PersistentInbox method notifyListeners.
private void notifyListeners(DiscoveryResult result, EventType type) {
for (InboxListener listener : this.listeners) {
try {
switch(type) {
case added:
listener.thingAdded(this, result);
break;
case removed:
listener.thingRemoved(this, result);
break;
case updated:
listener.thingUpdated(this, result);
break;
}
} catch (Exception ex) {
String errorMessage = String.format("Cannot notify the InboxListener '%s' about a Thing %s event!", listener.getClass().getName(), type.name());
logger.error(errorMessage, ex);
}
}
// in case of EventType added/updated the listeners might have modified the result in the discoveryResultStorage
DiscoveryResult resultForEvent = type == EventType.removed ? result : get(result.getThingUID());
postEvent(resultForEvent, type);
}
Aggregations