Package org.igniterealtime.jbosh
Class BodyParserSAX
java.lang.Object
org.igniterealtime.jbosh.BodyParserSAX
- All Implemented Interfaces:
BodyParser
Implementation of the BodyParser interface which uses the SAX API
that is part of the JDK. Due to the fact that we can cache and reuse
SAXPArser instances, this has proven to be significantly faster than the
use of the javax.xml.stream API introduced in Java 6 while simultaneously
providing an implementation accessible to Java 5 users.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
SAX event handler class. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Logger
Logger.private static final ThreadLocal
<SoftReference<SAXParser>> Thread local to contain a SAX parser instance for each thread that attempts to use one.private static final SAXParserFactory
SAX parser factory. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static SAXParser
Gets a SAXParser for use in parsing incoming messages.Parses the XML message, extracting the useful data from the initial body element and returning it in a results object.
-
Field Details
-
LOG
Logger. -
SAX_FACTORY
SAX parser factory. -
PARSER
Thread local to contain a SAX parser 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 Details
-
BodyParserSAX
BodyParserSAX()
-
-
Method Details
-
parse
Parses the XML message, extracting the useful data from the initial body element and returning it in a results object.- Specified by:
parse
in interfaceBodyParser
- Parameters:
xml
- XML to parse- Returns:
- useful data parsed out of the XML
- Throws:
BOSHException
- on parse error
-
getSAXParser
Gets a SAXParser for use in parsing incoming messages.- Returns:
- parser instance
-