From: David ‘Bombe’ Roden Date: Tue, 28 May 2013 08:41:45 +0000 (+0200) Subject: Register metadata listeners at all components for metadata updating. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=07121c8fc483608738841207a92bdcc130ef0587;p=sonitus.git Register metadata listeners at all components for metadata updating. --- diff --git a/src/main/java/net/pterodactylus/sonitus/data/Pipeline.java b/src/main/java/net/pterodactylus/sonitus/data/Pipeline.java index 1487d13..75536fc 100644 --- a/src/main/java/net/pterodactylus/sonitus/data/Pipeline.java +++ b/src/main/java/net/pterodactylus/sonitus/data/Pipeline.java @@ -71,6 +71,21 @@ public class Pipeline implements Iterable { private Pipeline(Source source, Multimap sinks) { this.source = Preconditions.checkNotNull(source, "source must not be null"); this.sinks = Preconditions.checkNotNull(sinks, "sinks must not be null"); + for (ControlledComponent component : Lists.reverse(components())) { + logger.finest(String.format("Adding Listener to %s.", component)); + component.addMetadataListener(new MetadataListener() { + @Override + public void metadataUpdated(ControlledComponent component, Metadata metadata) { + if (!(component instanceof Source)) { + return; + } + for (ControlledComponent controlledComponent : sinks((Source) component)) { + logger.fine(String.format("Updating Metadata from %s to %s.", component, controlledComponent)); + controlledComponent.metadataUpdated(metadata); + } + } + }); + } } //