de.schlichtherle.truezip.fs.inst.jul.JulDirector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truezip-extension-jmx-jul Show documentation
Show all versions of truezip-extension-jmx-jul Show documentation
This module provides a file system manager and an I/O pool service
for managing and monitoring TrueZIP via JMX and java.util.logging.
Add the JAR artifact of this module to the run time class path to
make its services available for service location in the client API
modules.
The newest version!
/*
* Copyright (C) 2005-2015 Schlichtherle IT Services.
* All rights reserved. Use is subject to license terms.
*/
package de.schlichtherle.truezip.fs.inst.jul;
import de.schlichtherle.truezip.entry.Entry;
import de.schlichtherle.truezip.fs.FsController;
import de.schlichtherle.truezip.fs.inst.InstrumentingCompositeDriver;
import de.schlichtherle.truezip.fs.inst.InstrumentingController;
import de.schlichtherle.truezip.fs.inst.InstrumentingDirector;
import de.schlichtherle.truezip.fs.inst.InstrumentingManager;
import de.schlichtherle.truezip.socket.IOPool;
import de.schlichtherle.truezip.socket.InputSocket;
import de.schlichtherle.truezip.socket.OutputSocket;
import de.schlichtherle.truezip.util.JSE7;
import javax.annotation.concurrent.Immutable;
/**
* @author Christian Schlichtherle
*/
@Immutable
public final class JulDirector extends InstrumentingDirector {
public static final JulDirector SINGLETON = new JulDirector();
private static final SocketFactory SOCKET_FACTORY = JSE7.AVAILABLE
? SocketFactory.NIO
: SocketFactory.OIO;
private JulDirector() { }
@Override
public > IOPool instrument(IOPool pool) {
return new JulIOPool(pool, this);
}
@Override
public FsController> instrument(FsController> controller, InstrumentingManager context) {
return controller;
}
@Override
public FsController> instrument(FsController> controller, InstrumentingCompositeDriver context) {
return new InstrumentingController(controller, this);
}
@Override
protected InputSocket instrument(InputSocket input) {
return SOCKET_FACTORY.newInputSocket(input, this);
}
@Override
protected OutputSocket instrument(OutputSocket output) {
return SOCKET_FACTORY.newOutputSocket(output, this);
}
private enum SocketFactory {
NIO() {
@Override
InputSocket newInputSocket(
InputSocket input, JulDirector director) {
return new JulNio2InputSocket(input, director);
}
@Override
OutputSocket newOutputSocket(
OutputSocket output, JulDirector director) {
return new JulNio2OutputSocket(output, director);
}
},
OIO() {
@Override
InputSocket newInputSocket(
InputSocket input, JulDirector director) {
return new JulInputSocket(input, director);
}
@Override
OutputSocket newOutputSocket(
OutputSocket output, JulDirector director) {
return new JulOutputSocket(output, director);
}
};
abstract InputSocket newInputSocket(
InputSocket input, JulDirector director);
abstract OutputSocket newOutputSocket(
OutputSocket output, JulDirector director);
}
}