import net.pterodactylus.sonitus.data.Metadata;
import net.pterodactylus.sonitus.data.Sink;
+import com.google.common.eventbus.EventBus;
+
/**
* {@link net.pterodactylus.sonitus.data.Sink} that writes all received data
* into a file.
/** The logger. */
private static final Logger logger = Logger.getLogger(FileSink.class.getName());
+ /** The event bus. */
+ private final EventBus eventBus;
+
/** The path of the file to write to. */
private final String path;
private FileOutputStream fileOutputStream;
+ /** The current metadata. */
+ private Metadata metadata;
+
/**
* Creates a new file sink that will write to the given path.
*
+ * @param eventBus
+ * The event bus
* @param path
* The path of the file to write to
*/
- public FileSink(String path) {
+ public FileSink(EventBus eventBus, String path) {
+ this.eventBus = eventBus;
this.path = path;
}
//
@Override
- public List<Controller> controllers() {
+ public String name() {
+ return path;
+ }
+
+ @Override
+ public Metadata metadata() {
+ return metadata;
+ }
+
+ @Override
+ public List<Controller<?>> controllers() {
return Collections.emptyList();
}
@Override
public void open(Metadata metadata) throws IOException {
fileOutputStream = new FileOutputStream(path);
+ metadataUpdated(metadata);
}
@Override
@Override
public void metadataUpdated(Metadata metadata) {
- /* ignore. */
+ this.metadata = metadata;
}
@Override