You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Sergey Beryozkin <sb...@gmail.com> on 2011/02/03 23:08:10 UTC

How to optimize JAXP Source reads

Hi

I'm looking at the XMLStreamDataReader in the SourceDataBinding and trying
to figure out what I can 'borrow' :-) from that code
to have the JAX-RS SourceProvider optimized.

The XMLStreamDataReader calls a resetForStreaming(XMLStreamReader) function,
when StaxSource or SAXSource is expected which seems like the key piece of
the optimization.

What exactly does it do and would it make sense to consider reusing that
code in the non-SOAP case, where we don't have wrapping tags like
soap:env and soap:body to deal with ?

It seems the best I can do in the plain XML case is to create the
XMLStreamReader from the InputStream...

Cheers, Sergey

Re: How to optimize JAXP Source reads

Posted by Daniel Kulp <dk...@apache.org>.
On Thursday 03 February 2011 5:08:10 pm Sergey Beryozkin wrote:
> Hi
> 
> I'm looking at the XMLStreamDataReader in the SourceDataBinding and trying
> to figure out what I can 'borrow' :-) from that code
> to have the JAX-RS SourceProvider optimized.
> 
> The XMLStreamDataReader calls a resetForStreaming(XMLStreamReader)
> function, when StaxSource or SAXSource is expected which seems like the
> key piece of the optimization.

Yep.  

> What exactly does it do and would it make sense to consider reusing that
> code in the non-SOAP case, where we don't have wrapping tags like
> soap:env and soap:body to deal with ?

We need to make sure that the later calls to find the close tags for soap:body 
and soap:env don't occur.   We pretty much just try to make sure nothing else 
touches the input stream or xml reader.

The FragmentStreamReader then kind of filters out those closing tags as well.

 
> It seems the best I can do in the plain XML case is to create the
> XMLStreamReader from the InputStream...

Yep.  That's the best option.  Nice and simple.   :-)


-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog