[Yanel-dev] Introducing a WebViewable interface

Michael Wechner michael.wechner at wyona.com
Thu Feb 15 16:18:09 CET 2007


Josias Thöny wrote:

> Michael Wechner wrote:
>
>> Hi
>>
>> I am currently working on the integration of a toolbar. One condition 
>> is that one knows the mime-type of a response, because
>> the toolbar only makes sense for requesst which have (x)html as a 
>> response. Hence it's important to ask a resource for the mime-type
>> before the actual response is actually being generated.
>>
>> In other situations this should also be the case for other HTTP 
>> header fields, e.g. size, because the header should be set before the 
>> response body is being streamed.
>>
>> With the current Viewable interfaces and the View class, this is not 
>> really being forced and I think it's design mistake which I caused ;-)
>
>
> How would you enforce that?
> IIUC you are talking about a getMimeType() method. This method could 
> either be in the View interface (as it is now), or in the Viewable 
> interface. In either case the only way I see to force the resource to 
> actually set the mime-type is by adding a contract in javadoc, like 
> e.g. "The resource MUST always set a valid mime-type". Then the 
> servlet could throw an exception if a resource doesn't set a mime-type.


exactly

> I guess we could add such a contract to the the getMimeType() method 
> in the View interface.
> BTW, would it make sense to move the getSize() method from the 
> ViewableV2 interface to the View interface?


Well, I think we should deprecate the View class and move the 
getMimeType into the Viewable interface.

The reason for this is to allow "streaming", i.e. the resource can 
directly write into the response instead of creating an object like 
"View" first with a buffered InputStream

>
>>
>> So I think we should either change the ViewableV2 interface (which 
>> hasn't be released yet) or introduce a new interface which takes care 
>> of the issues described above.
>
>
> How would the changed interface (or a new interface) look like?


the changed interface would contain "getMimeType()", whereas I haven't 
though concretely about the WebViewable interface.

Cheers

Michi

>
> Josias
>
>>
>> Another distinction we might want to make is between "web-viewable" 
>> and "viewable" in a more general sense.
>>
>> Hence I think it would make sense to introduce a WebViewable interface.
>>
>> WDYT?
>>
>> Cheers
>>
>> Michael
>>
>
>
> _______________________________________________
> Yanel-development mailing list
> Yanel-development at wyona.com
> http://wyona.com/cgi-bin/mailman/listinfo/yanel-development
>


-- 
Michael Wechner
Wyona      -   Open Source Content Management   -    Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
michael.wechner at wyona.com                        michi at apache.org
+41 44 272 91 61




More information about the Yanel-development mailing list