@Override
        public void write(byte b[], int off, int len) throws IOException {
            // forward request to wrapped stream
            originalStream.write(b, off, len);
            // update outgoingCounter
            incrementOutgoingCounter(b.length);
        }
Original output stream being wrapped to count outgoing traffic.
xmppserver/src/main/java/org/jivesoftware/openfire/net/ServerTrafficCounter.java