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