users@jersey.java.net

[Jersey] How to use JResponse to return a list for interface

From: Brendan cheng <ccp999_at_hotmail.com>
Date: Mon, 25 Mar 2013 09:31:59 +0000

Hi,
I have a problem in return a collection of objects using their interface. for example, Animal is the interface and Dog is a class. where I can only do a list of dogs like so:

interface Animal{}
class Dog implements Animal{}
@GET
@Path("test")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public JResponse<List<Dog>> getDogs(){...List<Dog> dogs = new ArrayList<Dog>();
...
return JResponse.ok(dogs).build();}

but I can't return a list of Animal, if:

Is it possible in JAXB?
Brendan