Hi,
first: I'm new to this list, so hello everyone. I'm just starting with
Jersey, but I like it a lot so far, so thanks for this nice tool :-)
next: I'm aware that this question has been asked before, but it
didn't really receive an answer, or at least none that I'd like (or I
missed it, in which case I apologize).
Would it be possible to allow MessageBodyReaders to produce not only a
single parameter, but a set of parameters for a method call, so that
single resource methods could take e.g. multiple named parameters from
a form POST as application/x-www-form-encoded?
I'd think of something like this:
Replace in MessageBodyReader<T>:
T readFrom(Class<T> type, Type genericType, MediaType mediaType,
Annotation annotations[],
MultivaluedMap<String, String> httpHeaders,
InputStream entityStream) throws IOException;
with:
Object[] readFrom(Class<T>[] types, Type[] genericTypes, MediaType
mediaType,
Annotation annotations[],
MultivaluedMap<String, String> httpHeaders,
InputStream entityStream) throws IOException;
So that MessageBodyReader could inspect the types, find those types
that have names fitting - for example - the method parameter names
with the form values, and set those accordingly?
The problem is of course that this reflection is somewhat costly and
you ideally wouldn't want to do this every time. So maybe we could
instantiate one message body reader for each method that has multiple
parameters and set that up to read messages for this method properly.
Alternatively you could create a holder class for each form submission
and either create a separate MIME type for each different form you
have, associate the MessageBodyReaders with certain URIs to produce
different classes from the same MIME type, but that seems wrong.
Best regards,
Martin