OpenFire output XML to console at development time

Source: Internet
Author: User

OpenFire Previous versions, you can output XML directly to the console while debugging. But it can't be exported now. I followed the next source. The debug output is implemented by the plug-in Debugger Plugin.

Located in the source directory: Src\plugins\xmldebugger

public void Initializeplugin (PlugInManager manager, File plugindirectory) {//ADD filter to filter chain Builder        Connectionmanagerimpl Connmanager = (Connectionmanagerimpl) xmppserver.getinstance (). GetConnectionManager ();        Defaultportfilter = new Rawprintfilter ("C2s");        Socketacceptor socketacceptor = Connmanager.getsocketacceptor (); if (socketacceptor! = null) {Socketacceptor.getfilterchain (). Addbefore ("XMPP", "Rawdebugger", Defaultportfilte        R);        } oldportfilter = new Rawprintfilter ("SSL");        Socketacceptor sslacceptor = Connmanager.getsslsocketacceptor ();        if (sslacceptor! = null) {Sslacceptor.getfilterchain (). Addbefore ("XMPP", "Rawdebugger", Oldportfilter);        } componentportfilter = new Rawprintfilter ("Excomp");        Socketacceptor componentacceptor = Connmanager.getcomponentacceptor (); if (componentacceptor! = null) {Componentacceptor.getfilterchain (). Addbefore ("XMPP","Rawdebugger", Componentportfilter);        } multiplexerportfilter = new Rawprintfilter ("CM");        Socketacceptor multiplexeracceptor = Connmanager.getmultiplexersocketacceptor (); if (multiplexeracceptor! = null) {Multiplexeracceptor.getfilterchain (). Addbefore ("XMPP", "Rawdebugger", Multip        Lexerportfilter);        } interpretedprinter = new Interpretedxmlprinter (); if (Jiveglobals.getbooleanproperty ("plugin.debugger.interpretedAllowed")) {//ADD the packet interceptor that        Prints interpreted XML interceptormanager.getinstance (). Addinterceptor (Interpretedprinter);    }//Listen to property Events Propertyeventdispatcher.addlistener (this); }

From the initialization code, C2S printing has been allowed. After I trace the code, I find the following code message instanceof Bytebuffer condition is false


public void Messagereceived (Nextfilter Nextfilter, iosession session, Object message) throws Exception {//Decode the Bytebuff ER and print it to the stdout if (enabled && message instanceof bytebuffer) {Bytebuffer Bytebuffer            = (bytebuffer) message;            Keep current position in the buffer int currentpos = Bytebuffer.position ();            Decode buffer Charset encoder = charset.forname ("UTF-8");            Charbuffer Charbuffer = Encoder.decode (Bytebuffer.asreadonlybuffer ());            Print buffer content System.out.println (prefix + "-RECV (" + session.hashcode () + "):" + Charbuffer);        Reset to old position in the buffer bytebuffer.position (CURRENTPOS);    }//Pass the message to the next filter super.messagereceived (Nextfilter, session, message); }


Fortunately, debugging provides direct printing of XML output:

public class Interpretedxmlprinter implements Packetinterceptor {public    void Interceptpacket (Packet Packet, Session session, Boolean incoming, Boolean processed)            throws Packetrejectedexception {        if (!processed & & incoming) {            System.out.println ("interpreted:" + packet.toxml ());}}}    

From the initialization code you can see that to enable the above features, you need to set plugin.debugger.interpretedAllowed to True,openfire default to False

So, log on to the admin side and add it to the server-"System properties. XML can be output to the control side.




OpenFire output XML to console at development time

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.