de.schlichtherle.truezip.fs.inst.jmx.JmxReadOnlyFile 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.jmx;
import de.schlichtherle.truezip.rof.DecoratingReadOnlyFile;
import de.schlichtherle.truezip.rof.ReadOnlyFile;
import edu.umd.cs.findbugs.annotations.CreatesObligation;
import java.io.IOException;
import javax.annotation.WillCloseWhenClosed;
import javax.annotation.concurrent.NotThreadSafe;
/**
* @author Christian Schlichtherle
*/
@NotThreadSafe
final class JmxReadOnlyFile extends DecoratingReadOnlyFile {
private final JmxIOStatistics stats;
@CreatesObligation
@edu.umd.cs.findbugs.annotations.SuppressWarnings("OBL_UNSATISFIED_OBLIGATION")
JmxReadOnlyFile(@WillCloseWhenClosed ReadOnlyFile rof, JmxIOStatistics stats) {
super(rof);
assert null != stats;
this.stats = stats;
}
@Override
public int read() throws IOException {
int ret = delegate.read();
if (0 < ret)
stats.incBytesRead(1);
return ret;
}
@Override
public int read(byte[] b, int off, int len) throws IOException {
int ret = delegate.read(b, off, len);
if (0 < ret)
stats.incBytesRead(ret);
return ret;
}
}