MessageBodyReaderSupport and MessageBodyWriterSupport for List<User>

7 views
Skip to first unread message

confile

unread,
Dec 3, 2013, 11:54:08 AM12/3/13
to grails-jax...@googlegroups.com

I have problems to generate the MessageBodyReaderSupport and MessageBodyWriterSupport for List and List

I have the following Resource

class UserResource {
@POST
    @Consumes('application/json')
    @Produces('application/json')
    List<User> getusers(List<UserDto>  userlist) { 
           return userlist
       }
}

I defined the MessageBodyWriterSupport for User and the MessageBodyReaderSupport for UserDto. I would expect that these reader and writer will be used when I use a collection typ like a List. But this is not the case I have to write my own reader and writer for

For example this:

@Provider
@Produces('application/json')
class ArrayListWriter extends MessageBodyWriterSupport<ArrayList> {
  ...
}

Can you please tell how I could write a MessageBodyReaderSupport and MessageBodyWriterSupport for a generic list class?

When I have MessageBodyWriterSupport for User and Item then it would be great when these writers are used when I generate List and List
Is this possible? 
Would be great if you could post an example for that. Thank you for your help.

Reply all
Reply to author
Forward
0 new messages