cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin" <sbery...@progress.com>
Subject Re: How to replace the output stream
Date Wed, 04 Mar 2009 16:19:40 GMT
Hi Dan

Thanks, this is a useful info. I'm thinking at the moment of introducing a flag like
enableBuffering at a jaxrs:endpoint level which would find its way into all the jaxrs providers
which have
a corresponding setter, which would also make it possible to turn on the buffering at the
individual provider level.

If buffering is enabled then providers will write into CachedOutputStream to be later copied
into the actual output stream.

By the way, all JAXRS providers write directly to the OutputStream which is available in a
given out message, given that 
MessageBodyWriter.writeTo has OutputStream in its signature. I guess it means that if XML-aware
providers do choose to do streaming 
then they need to create an XmlStreamWriter on top of this output stream, something what JSONProvider
does.

Perhaps I can also update the org.apache.cxf.jaxrs.ext.MessageContext(Impl) to create such
a writer with the help of our StaxUtils, 
plus also create CachingXmlEventStreamWriter ...

There're definitely some options available.....

Cheers, Sergey



>
> Sergey,
>
> There isn't a way to do this that doesn't break streaming.   For the normal
> "soap" case, in order to properly stream, we have to kind of "assume" that
> writing isn't going to cause any failures.   However, if schema validation is
> turned on, we do recognize that it could fail.  (this PROBABLY should be also
> controllable by a user property)  In that case, we kind of go into a "event
> buffering" mode where the XML events are buffered and replayed if the marshall
> succeeded.   See the AbstractOutDatatbinding code.
>
> You PROBABLY want something similar.   Normal mode would probably be to
> stream, but provide some sort of config flag or something to allow it to go
> into non-streaming/buffering mode.
>
> If you DO add a config option, we should update the AbstractOutDatatbinding to
> accept the same config option.
>
> Dan
>
>
> On Wed March 4 2009 9:01:45 am Sergey Beryozkin wrote:
>> Hi,
>>
>> I'm looking at https://issues.apache.org/jira/browse/CXF-2051 at the
>> moment. The problem is that after some initial writes to an out message's
>> OutputStream an exception is thrown and it's handled seperately by also
>> writing something to the output stream.
>>
>> Now, when it occurs the original OutputStream should really be replaced
>> with a new one. But can this be done at the moment ? It looks like the
>> initial write goes directly to the HttpServletResponse.responseStream....
>>
>> Perhaps it's a up to  auser to handle cases liek thise one ? For example,
>> introduce a Servlet filter which would buffer the output stream, or
>> directly write to HttpServletResponse which is available for both JAXWS and
>> JAXRS ?
>>
>> Thanks, Sergey
>
> -- 
> Daniel Kulp
> dkulp@apache.org
> http://www.dankulp.com/blog 


Mime
View raw message