问题
Is it possible switch the native parser, which I believe is based on Java reflection. We have some performance issues and wondering whether we can switch the implementation.
Your advise is highly appreciated.
Additional information: This is inherited code and we need to fix performance issues in our web-services. I am looking for performance boost without code changes. The existing code uses JAXB for marshalling and unmarshalling java objects which are generated via CXF (wsdl to java).
My goal is to switch the implementation to sTax and then use Woodstox library.
回答1:
If your JAXB implementation uses a StAX parser under the covers via the standard JAXP APIs, then adding the Woodstox jar to your classpath should cause your JAXB impl to use Woodstox. You should see a performance improvement by doing this.
Since the Woodstox jar contains the following entries, adding it to the classpath will allow the JAXP APIs to return an instance of it:
- META-INF/services/javax.xml.stream.XMLInputFactory
- META-INF/services/javax.xml.stream.XMLOuputFactory
Note: I lead EclipseLink JAXB (MOXy), and MOXy uses a StAX parser when one is available. The other JAXB implementations (Metro, JaxMe) probably do the same thing.
来源:https://stackoverflow.com/questions/5477842/jaxb-to-use-woodstox-parser-for-performance