dev@jsr311.java.net

Re: JSR311: ProviderFactory API needs a bit refactoring?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 07 Nov 2007 12:39:52 +0100

Heiko Braun wrote:
>
> I'd go for option three as well.

Originally when i implemented this as a prototype they were split :-)

It should be possible to split but still enable an implementation to
implement both the reader and writer with Produce/Consume annotated
(even if two separate instances would be created for reading/writing, i
guess we need to clarify things here).


> 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)

Paul.

-- 
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109