> -----Original Message-----
> From: Marc.Hadley_at_Sun.COM [mailto:Marc.Hadley_at_Sun.COM]
> Sent: 2007?11?8? 0:15
> To: dev_at_jsr311.dev.java.net
> Subject: Re: JSR311: ProviderFactory API needs a bit refactoring?
>
>
> On Nov 7, 2007, at 6:39 AM, Paul Sandoz wrote:
> >
> >> Split them into two interfaces. We may as well take stefans comment
> >> into consideration and rename the EntityProvider to something less
> >> confusing.
> >
> > Agreed, what about MessageBodyReader and MessageBodyWriter
> ? I like
> > the idea of keeping the names close to reading/writing
> since that is
> > what these do with InputStream and OutputStream respectively.
> >
> > While we are this the topic... It is sometimes useful for a
> > container to ask a writer if it knows the size of something
> it will
> > write, so the container can use chunked encoding or
> Content-Length,
> > for example if File or byte[], or ByteArrayInputStream types are
> > used then a writer knows the length. So we could have a method:
> >
> > // Returns a non-negative integer if size is known
> > long MessageBodyWriter.getSize(T t)
> >
> Something like:
>
> public interface MessageBodyReader<T> {
> boolean isReadable(Class<?> type);
> T readFrom(Class<T> type, MediaType mediaType,
> MultivaluedMap<String, String> httpHeaders,
> InputStream entityStream) throws IOException;
> }
>
> and
>
> public interface MessageBodyWriter<T> {
> boolean isWriteable(Class<?> type);
> void writeTo(T t, MediaType mediaType,
> MultivaluedMap<String, Object> httpHeaders,
> OutputStream entityStream) throws IOException;
> long getSize(T t)
> }
>
> with the corresponding:
>
> public abstract class ProviderFactory {
> ...
> public abstract <T> MessageBodyReader<T>
> createMessageBodyReader(Class<T> type, MediaType media);
> public abstract <T> MessageBodyWriter<T>
> createMessageBodyWriter(Class<T> type, MediaType media);
> }
>
This looks good. Thanks.
Jervis
> Marc.
>
> ---
> Marc Hadley <marc.hadley at sun.com>
> CTO Office, Sun Microsystems.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: dev-help_at_jsr311.dev.java.net
>
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland