@Override
        public int read(ByteBuffer dst) throws IOException {
            int bytes = originalChannel.read(dst);
            if (bytes > -1) {
                incrementIncomingCounter(bytes);
            }
            return bytes;
        }
Wrapper on a ReadableByteChannel to intercept and count number of read bytes.
xmppserver/src/main/java/org/jivesoftware/openfire/net/ServerTrafficCounter.java