@Override
        public int write(ByteBuffer src) throws IOException {
            int bytes = originalChannel.write(src);
            incrementOutgoingCounter(bytes);
            return bytes;
        }
Wrapper on a WritableByteChannel to intercept and count number of written bytes.
xmppserver/src/main/java/org/jivesoftware/openfire/net/ServerTrafficCounter.java