Jesse Long | 7 Jun 2012 17:04
Gravatar

IResourceStreamWriter#write

Hi Wicket Devs,

(wicket 6.0.0-beta2 btw).

Why does IResourceStreamWriter#write() take a Response and not an 
OutputStream?

As I see it, ResourceStreamResource (which is called from 
ResourceStreamRequestHandler) is responsible for setting the headers for 
the response, and does. What more could the IResourceStreamWriter want 
to do with the response?

AbstractResource#respond() calls 
ResourceStreamResource#newResourceResponse(), which returns all the 
headers in the ResourceReponse (using normal IResourceStream calls), and 
passes back a wrapped call to IResourceStreamWriter#write() as the 
writer callback. AbstractResource#respond() then sets the headers on the 
Response, then only calls IResourceStreamWriter#write() via the write 
callback only if AbstractResource thinks data needs to be written based 
on the values returned from the normal IResourceStream calls.

So, if the IResourceStreamWriter sets different headers in its write() 
method to the values produced by calling lastModifiedTime() etc (I would 
consider this a bad idea, and probably wrong), there is a danger that 
unexpected behaviour may occur if AbstractResource#respond() decides NOT 
to call the writer callback (which will call 
IResourceStreamWriter#write()). The IResourceStreamWriter implementer 
may wonder why his headers are not being set.

If the IResourceStreamWriter does not set any headers apart from the 
(Continue reading)

Martin Grigorov | 8 Jun 2012 02:26
Picon
Favicon

Re: IResourceStreamWriter#write

Hi Jesse,

The signature of this method has been changed with:

commit 4977f66ef55eaa5d89ed5d3751ff6aefc9652c50
Author: Matej Knopp <knopp@...>
Date:   Mon Jan 4 01:03:29 2010 +0000

    Wild attempt to integrate new RequestCycle
    src/main/java almost builds, definitely doesn't work
    rest doesn't even build

    put bunch of classes that will likely be removed to src/main/disabled

    hopefully will continue working on it shortly

I.e. it was changed in the very early early days of 1.5.
I'm not sure whether the change is intentional, i.e. whether Matej
wanted to improve the API by making it consistent with the rest of the
code or it was just part of "make the code compiling" coding session.

The javadoc says that IResourceStreamWriter can stream to the client
without buffering but looking at the current version I think this is
no more true, i.e. the written data IS buffered.

I personally have never needed to use this class in my apps and I'm
not very familiar with it.

 <at> Devs: is this class broken in 1.5.x ? Should we revert the API change for 6.x ?

(Continue reading)

Jesse Long | 8 Jun 2012 09:48
Gravatar

Re: IResourceStreamWriter#write

Hi All,

Martin, thanks for the response, see comments below:

On 08/06/2012 02:26, Martin Grigorov wrote:
> Hi Jesse,
>
> The signature of this method has been changed with:
>
> commit 4977f66ef55eaa5d89ed5d3751ff6aefc9652c50
> Author: Matej Knopp<knopp@...>
> Date:   Mon Jan 4 01:03:29 2010 +0000
>
>      Wild attempt to integrate new RequestCycle
>      src/main/java almost builds, definitely doesn't work
>      rest doesn't even build
>
>      put bunch of classes that will likely be removed to src/main/disabled
>
>      hopefully will continue working on it shortly
>
>
> I.e. it was changed in the very early early days of 1.5.
> I'm not sure whether the change is intentional, i.e. whether Matej
> wanted to improve the API by making it consistent with the rest of the
> code or it was just part of "make the code compiling" coding session.

I think it makes it more inconsistent. IResourceStream has a size, 
contentType and lastModified. It also has a getInputStream() to get the 
data. This can be implemented for things like java.io.File etc that have 
(Continue reading)

Martin Grigorov | 8 Jun 2012 10:21
Picon
Favicon

Re: IResourceStreamWriter#write

Hi,

Please file a ticket.
We should fix that for Wicket 6.x. I understand that it is weird to
migrate an app from 1.4 to 1.5 and then revert the change when
migrating to 6.x but I believe its is for good.

On Fri, Jun 8, 2012 at 10:48 AM, Jesse Long <jpl@...> wrote:
> Hi All,
>
> Martin, thanks for the response, see comments below:
>
>
> On 08/06/2012 02:26, Martin Grigorov wrote:
>>
>> Hi Jesse,
>>
>> The signature of this method has been changed with:
>>
>> commit 4977f66ef55eaa5d89ed5d3751ff6aefc9652c50
>> Author: Matej Knopp<knopp@...>
>> Date:   Mon Jan 4 01:03:29 2010 +0000
>>
>>     Wild attempt to integrate new RequestCycle
>>     src/main/java almost builds, definitely doesn't work
>>     rest doesn't even build
>>
>>     put bunch of classes that will likely be removed to src/main/disabled
>>
>>     hopefully will continue working on it shortly
(Continue reading)


Gmane