dev@jsr311.java.net

Re: JSR311: multipart

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Fri, 29 Feb 2008 11:24:48 -0500

On Feb 28, 2008, at 3:16 PM, Bill Burke wrote:

> I don't know if jax-rs plans to add support for multipart (form-
> data, mixed, etc...) (I wish we would figure out an abstraction),
> but currently I don't see a way of supporting it portably in the
> current model.
>
I'd like to enable such support to be built portably.

> The main reason is that there is no way of looking up providers by
> mediaType and class. There used to be a createMessageBodyReader/
> Writer. I wish we could bring that back. That way, a mulitpart
> @Provider could look up and call marshalling based on this.

Seems like RuntimeDelegate would be a reasonable place to put such a
method. Something like:

<T> List<MessageBodyReader<T>> getMessageBodyReaders(MediaType
mediaType, Class<T> type, Type genericType, Annotation annotations[]);
<T> List<MessageBodyWriter<T>> getMessageBodyWriters(MediaType
mediaType, Class<T> type, Type genericType, Annotation annotations[]);

The methods would return a list of providers whose @[Produce|
Consume]Mime matches mediaType and that return true from their
is[Readable|Writable](Class<?> type, Type genericType, Annotation
annotations[])

Would that work ?

Shame you can't do:

<P,T> List<P<T>> getProviders(Class<P> providerType, MediaType
mediaType, Class<T> type, Type genericType, Annotation annotations[]);

Marc.

> i.e.
>
> public interface MultipartMixed {
>
> public void writeObject(MediaType type, Object obj);
> }
>
> or
>
> @ProduceMime("multipart/mixed")
> List<String> get() { ... }
>
> @Provider will have a match based on multipart, Collection as a
> type. It iterates through the collection and finds a
> MessageBodyReader or Writer. Creates its own header/outputstream
> objects, calls the reader/writer, returns.
>
> or
>
> @ProduceMime("multipart/form-data")
> MyForm
> get()
>
>
>
>
> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: dev-help_at_jsr311.dev.java.net
>

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.