net.java.truevfs.comp.inst.Mediator Maven / Gradle / Ivy
Show all versions of truevfs-comp-inst Show documentation
/*
* 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.*;
import java.nio.channels.SeekableByteChannel;
import javax.annotation.concurrent.Immutable;
import net.java.truecommons.cio.*;
import net.java.truevfs.kernel.spec.*;
/**
* Implements the mediator role of the mediator pattern for instrumenting all
* objects which are used by the TrueVFS Kernel.
* When any of the instrumentation methods are called, implementations are
* given the choice to either return the given object as is or to decorate it
* with a colleague for instrumentation.
*
* Implementations generally need to be thread-safe.
*
* @param the type of this mediator.
* @author Christian Schlichtherle
*/
@Immutable
public abstract class Mediator> {
/**
* Instruments the given {@code subject}.
*
* @param subject the subject of instrumentation.
* @return An instrumenting object or {@code subject} if the implementation
* does not want to instrument it.
*/
public FsManager instrument(FsManager subject) {
return subject;
}
/**
* Instruments the given {@code subject}.
*
* @param subject the subject of instrumentation.
* @return An instrumenting object or {@code subject} if the implementation
* does not want to instrument it.
*/
public IoBufferPool instrument(IoBufferPool subject) {
return subject;
}
/**
* Instruments the given {@code subject}.
*
* @param context the instrumenting object which called this method.
* @param subject the subject of instrumentation.
* @return An instrumenting object or {@code subject} if the implementation
* does not want to instrument it.
* @see #instrument(FsManager)
*/
public FsCompositeDriver instrument(
InstrumentingManager context,
FsCompositeDriver subject) {
return subject;
}
/**
* Instruments the given {@code subject}.
*
* @param context the instrumenting object which called this method.
* @param subject the subject of instrumentation.
* @return An instrumenting object or {@code subject} if the implementation
* does not want to instrument it.
* @see #instrument(FsManager)
*/
public FsController instrument(
InstrumentingManager context,
FsController subject) {
return subject;
}
/**
* Instruments the given {@code subject}.
*
* @param context the instrumenting object which called this method.
* @param subject the subject of instrumentation.
* @return An instrumenting object or {@code subject} if the implementation
* does not want to instrument it.
* @see #instrument(IoBufferPool)
*/
public IoBuffer instrument(
InstrumentingBufferPool context,
IoBuffer subject) {
return subject;
}
/**
* Instruments the given {@code subject}.
*
* @param context the instrumenting object which called this method.
* @param subject the subject of instrumentation.
* @return An instrumenting object or {@code subject} if the implementation
* does not want to instrument it.
* @see #instrument(InstrumentingManager, FsCompositeDriver)
*/
public FsModel instrument(
InstrumentingCompositeDriver context,
FsModel subject) {
return subject;
}
/**
* Instruments the given {@code subject}.
*
* @param context the instrumenting object which called this method.
* @param subject the subject of instrumentation.
* @return An instrumenting object or {@code subject} if the implementation
* does not want to instrument it.
* @see #instrument(InstrumentingManager, FsCompositeDriver)
*/
public FsController instrument(
InstrumentingCompositeDriver context,
FsController subject) {
return subject;
}
/**
* Instruments the given {@code subject}.
*
* @param the type of the target entry for I/O operations.
* @param context the instrumenting object which called this method.
* @param subject the subject of instrumentation.
* @return An instrumenting object or {@code subject} if the implementation
* does not want to instrument it.
* @see #instrument(InstrumentingManager, FsController)
* @see #instrument(InstrumentingCompositeDriver, FsController)
*/
public InputSocket instrument(
InstrumentingController context,
InputSocket subject) {
return subject;
}
/**
* Instruments the given {@code subject}.
*
* @param the type of the target entry for I/O operations.
* @param context the instrumenting object which called this method.
* @param subject the subject of instrumentation.
* @return An instrumenting object or {@code subject} if the implementation
* does not want to instrument it.
* @see #instrument(InstrumentingManager, FsController)
* @see #instrument(InstrumentingCompositeDriver, FsController)
*/
public OutputSocket instrument(
InstrumentingController context,
OutputSocket subject) {
return subject;
}
/**
* Instruments the given {@code subject}.
*
* @param the type of the target entry for I/O operations.
* @param context the instrumenting object which called this method.
* @param subject the subject of instrumentation.
* @return An instrumenting object or {@code subject} if the implementation
* does not want to instrument it.
* @see #instrument(InstrumentingBufferPool, IoBuffer)
*/
public InputSocket instrument(
InstrumentingBuffer context,
InputSocket subject) {
return subject;
}
/**
* Instruments the given {@code subject}.
*
* @param the type of the target entry for I/O operations.
* @param context the instrumenting object which called this method.
* @param subject the subject of instrumentation.
* @return An instrumenting object or {@code subject} if the implementation
* does not want to instrument it.
* @see #instrument(InstrumentingBufferPool, IoBuffer)
*/
public OutputSocket instrument(
InstrumentingBuffer context,
OutputSocket subject) {
return subject;
}
/**
* Instruments the given {@code subject}.
*
* @param the type of the target entry for I/O operations.
* @param context the instrumenting object which called this method.
* @param subject the subject of instrumentation.
* @return An instrumenting object or {@code subject} if the implementation
* does not want to instrument it.
* @see #instrument(InstrumentingController, InputSocket)
* @see #instrument(InstrumentingBuffer, InputSocket)
*/
public InputStream instrument(
InstrumentingInputSocket context,
InputStream subject) {
return subject;
}
/**
* Instruments the given {@code subject}.
*
* @param the type of the target entry for I/O operations.
* @param context the instrumenting object which called this method.
* @param subject the subject of instrumentation.
* @return An instrumenting object or {@code subject} if the implementation
* does not want to instrument it.
* @see #instrument(InstrumentingController, InputSocket)
* @see #instrument(InstrumentingBuffer, InputSocket)
*/
public SeekableByteChannel instrument(
InstrumentingInputSocket context,
SeekableByteChannel subject) {
return subject;
}
/**
* Instruments the given {@code subject}.
*
* @param the type of the target entry for I/O operations.
* @param context the instrumenting object which called this method.
* @param subject the subject of instrumentation.
* @return An instrumenting object or {@code subject} if the implementation
* does not want to instrument it.
* @see #instrument(InstrumentingController, OutputSocket)
* @see #instrument(InstrumentingBuffer, OutputSocket)
*/
public OutputStream instrument(
InstrumentingOutputSocket context,
OutputStream subject) {
return subject;
}
/**
* Instruments the given {@code subject}.
*
* @param the type of the target entry for I/O operations.
* @param context the instrumenting object which called this method.
* @param subject the subject of instrumentation.
* @return An instrumenting object or {@code subject} if the implementation
* does not want to instrument it.
* @see #instrument(InstrumentingController, OutputSocket)
* @see #instrument(InstrumentingBuffer, OutputSocket)
*/
public SeekableByteChannel instrument(
InstrumentingOutputSocket context,
SeekableByteChannel subject) {
return subject;
}
}