See my comments inline.

On Thu, Dec 18, 2008 at 04:55, Thilina Gunarathne <[email protected]> wrote:
> Hi Andreas,
> I'm sorry, I missed this mail.. Saw it only now...
>
> I agree with you regarding the 1. But I guess the solution will need to
> address deferred building, which will make it bit complex... Something like
> implementing a pushbackInputStream which will directly give the bytes from
> the transport inputstream while buffering it to give it the next time...

The existing BinaryBuilder uses IOUtils#toByteArray and then
constructs a DataSource from the byte[]. This avoids the problem that
UnknownContentBuilder has, but this solution is also clearly
suboptimal. Your idea sounds very good. I'm sure that a DataSource
that implements this behavior already exists somewhere in Axiom, Axis2
or Synapse.

> Regarding 2, I don't think we can call anything "the" right solution for
> this. Normally Axis2 uses OMDataSources to carry native data as long as it
> can, so that if an entity which knows how to process the native data can
> take advantage of it.. Also using the OMSourcedElement, clearly distinguish
> the usage of unknown content from other messages...

In the case of binary data, this functionality as already provided by
DataHandler/DataSource. UnknownContentOMDataSource only defers the
construction of the wrapper OMElement and the OMText object that holds
the reference to the DataHandler, which IMHO is not very useful.
Actually your argument applies much more to PlainTextBuilder, which
for the moment uses IOUtils.toString(inputStream, charSetEnc) and then
creates an OMText node with the returned string. Here it would
definitely make sense to defer building the tree as much as possible.
Note that we have code in Synapse that does this (for text output
generated by an XSL transformation). See TextFileDataSource and
WrappedTextNodeStreamReader.

> Regarding the 3, my apologies once again... I was not aware of such a thing
> when I wrote the above. IMHO builder should live inside Axis2.. I did this
> (and the mime support) as a solution to the issue raised in Synapse. Wonder
> why they did not simply use the impl you mentioned.... May be I'm missing
> something.. Let's see how we can combine these efforts...

No need to apologize. With the large volume of code in Axis2 and its
surrounding projects, probably nobody is able to say whether a given
piece of functionality already exists somewhere or not. After all
thats why we spam the dev lists with the Subversion commit logs, so
that people can review and shout when code is duplicated...

> thanks,
> Thilina.
>
>> 1. The class InputStreamDataSource (the one in
>> org.apache.axis2.builder.unknowncontent) violates the
>> javax.activation.DataSource contract which says for the getInputStream
>> method that "a new InputStream object must be returned each time this
>> method is called, and [that] the stream must be positioned at the
>> beginning of the data." The consequence will be that the message
>> produced by UnknownContentBuilder can only be read once. This is a
>> serious flaw.
>>
>> 2. The AXIOM tree produced by UnknownContentBuilder has only two
>> nodes: an OMElement and an OMText (with a DataHandler). Using an
>> OMSourcedElement/OMDataSource is not justified for this and would
>> introduce unnecessary complexity and overhead.
>>
>> 3. The code in UnknownContentBuilder to a large extend duplicates the
>> code in org.apache.axis2.format.BinaryBuilder (in
>> axis2-transport-base), which doesn't have problems 1 and 2.
>>
>> Could you please make a proposal how to improve this?
>>
>> Regards,
>>
>> Andreas
>
>
>
> --
> Thilina Gunarathne  - http://thilinag.blogspot.com
>

Reply via email to