众所周知Openfire是基于mina编写的。因此直接找到ConnectionHandler,这个类继承IoHandlerAdapter。
熟悉mina的会知道接受消息并处理的方法为messageReceived。我们也只关心这个方法:
@Override
public void messageReceived(IoSession session, Object message) throws Exception {
// Get the stanza handler for this session
StanzaHandler handler = (StanzaHandler) session.getAttribute(HANDLER);
// Get the parser to use to process stanza. For optimization there is going
// to be a parser for each running thread. Each Filter will be executed
// by the Executor placed as the first Filter. So we can have a parser associated
// to each Thread
int hashCode = Thread.currentThread().hashCode();
XMPPPacketReader parser = parsers.get(hashCode);
if (parser == null) {
parser = new XMPPPacketReader();
parsers.put(hashCode, parser);