de.schlichtherle.truezip.fs.inst.jul.JulOutputStream 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.
/*
* 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.io.DecoratingOutputStream;
import de.schlichtherle.truezip.socket.IOPool;
import de.schlichtherle.truezip.socket.OutputSocket;
import edu.umd.cs.findbugs.annotations.CreatesObligation;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.concurrent.Immutable;
/**
* @author Christian Schlichtherle
*/
@Immutable
final class JulOutputStream
extends DecoratingOutputStream {
private static final Logger
logger = Logger.getLogger(JulOutputStream.class.getName());
private final Entry target;
@CreatesObligation
@edu.umd.cs.findbugs.annotations.SuppressWarnings("OBL_UNSATISFIED_OBLIGATION")
JulOutputStream(final OutputSocket> socket) throws IOException {
this(socket, socket.getLocalTarget());
}
@CreatesObligation
@edu.umd.cs.findbugs.annotations.SuppressWarnings("OBL_UNSATISFIED_OBLIGATION")
private JulOutputStream(final OutputSocket> socket, final Entry target)
throws IOException {
super(socket.newOutputStream());
this.target = target;
Level level = target instanceof IOPool.Entry ? Level.FINER : Level.FINEST;
logger.log(level, "Stream writing " + target, new NeverThrowable());
}
@Override
public void close() throws IOException {
try {
delegate.close();
} finally {
Level level = target instanceof IOPool.Entry ? Level.FINER : Level.FINEST;
logger.log(level, "Closed " + target, new NeverThrowable());
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy