@Override
        public int read(byte b[], int off, int len) throws IOException {
            int bytes = originalStream.read(b, off, len);
            if (bytes > -1) {
                incrementIncomingCounter(bytes);
            }
            return bytes;
        }
Original input stream being wrapped to count incmoing traffic.
xmppserver/src/main/java/org/jivesoftware/openfire/net/ServerTrafficCounter.java