class NotificationManager extends AbstractDataSourcePropertyManager<Client, NotificationClientRepository> implements DataSink {

	@Override
	public void onNewDataComplete(DataSource source) {
		for (Client client : getAll(source)) {
			Sender<?> sender = senderCache.get(source, client);
			senderCache.release(source, client);

			sender.onNewDataComplete();
			SenderResult result = sender.getSenderResult();
			switch(result.getStatus()) {
				case SUCCESS:
					break;

				case ERROR:
					String errorMsg = "Failed to send notification to client " + client.getId();
					if (result.getErrorCause() != null)
						errorMsg = errorMsg + " (" + result.getErrorCause().getMessage() + ")";
					if (result.getErrorMsg() != null)
						errorMsg = errorMsg + " (" + result.getErrorMsg() + ")";
					Log.error(errorMsg);
					break;

				case REMOVE_CLIENT:
					Log.info("Unregistering client " + result.getOldClient().getId());
					remove(source, null, result.getOldClient());
					break;

				case UPDATE_CLIENT:
					Log.info("Updating client id to " + result.getNewClient().getId());
					remove(source, null, result.getOldClient());
					add(source, null, result.getNewClient());
					break;
			}
		}
	}

	@Inject  NotificationManager(
			Cache<NotificationClientRepository> repositoryCache,
			RepositoryFactory repositoryFactory,
			SenderCache senderCache);

}