net.java.truevfs.comp.inst.InstrumentingInputSocket Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truevfs-comp-inst Show documentation
Show all versions of truevfs-comp-inst Show documentation
Provides basic functionality for instrumenting the TrueVFS Kernel.
/*
* Copyright (C) 2005-2015 Schlichtherle IT Services.
* All rights reserved. Use is subject to license terms.
*/
package net.java.truevfs.comp.inst;
import java.io.IOException;
import java.io.InputStream;
import java.nio.channels.SeekableByteChannel;
import java.util.Objects;
import javax.annotation.CheckForNull;
import javax.annotation.concurrent.Immutable;
import net.java.truecommons.cio.DecoratingInputSocket;
import net.java.truecommons.cio.Entry;
import net.java.truecommons.cio.InputSocket;
import net.java.truecommons.cio.OutputSocket;
/**
* @param the type of the mediator.
* @param the type of the {@linkplain #target() target entry} for I/O
* operations.
* @see InstrumentingOutputSocket
* @author Christian Schlichtherle
*/
@Immutable
public class InstrumentingInputSocket<
M extends Mediator,
E extends Entry>
extends DecoratingInputSocket {
protected final M mediator;
public InstrumentingInputSocket(
final M mediator,
final InputSocket extends E> socket) {
super(socket);
this.mediator = Objects.requireNonNull(mediator);
}
@Override
public InputStream stream(@CheckForNull OutputSocket extends Entry> peer)
throws IOException {
return mediator.instrument(this, socket.stream(peer));
}
@Override
public SeekableByteChannel channel(
@CheckForNull OutputSocket extends Entry> peer)
throws IOException {
return mediator.instrument(this, socket.channel(peer));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy