Class BodyParserXmlPull

  • All Implemented Interfaces:
    BodyParser

    final class BodyParserXmlPull
    extends java.lang.Object
    implements BodyParser
    Implementation of the BodyParser interface which uses the XmlPullParser API. When available, this API provides an order of magnitude performance improvement over the default SAX parser implementation.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.logging.Logger LOG
      Logger.
      private static java.lang.ThreadLocal<java.lang.ref.SoftReference<org.xmlpull.v1.XmlPullParser>> XPP_PARSER
      Thread local to contain a XmlPullParser instance for each thread that attempts to use one.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static org.xmlpull.v1.XmlPullParser getXmlPullParser()
      Gets a XmlPullParser for use in parsing incoming messages.
      BodyParserResults parse​(java.lang.String xml)
      Parses the XML message, extracting the useful data from the initial body element and returning it in a results object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOG

        private static final java.util.logging.Logger LOG
        Logger.
      • XPP_PARSER

        private static final java.lang.ThreadLocal<java.lang.ref.SoftReference<org.xmlpull.v1.XmlPullParser>> XPP_PARSER
        Thread local to contain a XmlPullParser instance for each thread that attempts to use one. This allows us to gain an order of magnitude of performance as a result of not constructing parsers for each invocation while retaining thread safety.
    • Constructor Detail

      • BodyParserXmlPull

        BodyParserXmlPull()
    • Method Detail

      • parse

        public BodyParserResults parse​(java.lang.String xml)
                                throws BOSHException
        Parses the XML message, extracting the useful data from the initial body element and returning it in a results object.
        Specified by:
        parse in interface BodyParser
        Parameters:
        xml - XML to parse
        Returns:
        useful data parsed out of the XML
        Throws:
        BOSHException - on parse error
      • getXmlPullParser

        private static org.xmlpull.v1.XmlPullParser getXmlPullParser()
        Gets a XmlPullParser for use in parsing incoming messages.
        Returns:
        parser instance