users@jersey.java.net

Re: Returning Heterogeneous Collections?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 15 Apr 2008 16:16:05 +0200

Hi Tom,

I think it is due to JAXB marshalling rather than anything specific to
Jersey. Is an @XmlRootElement present on classes that extend RepositoryData?

See the JavaDoc of XmlRootElement [1].

Paul.

[1]
http://java.sun.com/javase/6/docs/api/javax/xml/bind/annotation/XmlRootElement.html

Tom Davies wrote:
> Hi,
>
> I have the following code:
>
> public class RestRepositoryService {
> private RepositoryService repositoryService;
>
> @XmlRootElement
> public static class Repositories {
> public List<RepositoryData> repoData = null;
>
> public Repositories() {
> }
>
> public Repositories(List<RepositoryData> allRepos) {
> this.repoData = allRepos;
> }
> }
> ...
> @GET
> public Repositories getAllRepositories() {
> return new
> Repositories(getRepositoryService().getRepositories()); // this is a
> list of SvnRepositoryData and CvsRepositoryData instances
> }
>
> and a class hierarchy:
>
> SvnRepositoryData extends RepositoryData
> CvsRepositoryData extends RepositoryData
>
> The XML returned by getAllRepositories contains only the properties
> declared in RepositoryData.
>
> I'd like to render properties as XML based on the concrete type of each
> object in the list,
>
> 1) Is this the correct RESTful way to go?
> 2) How can I do it in Jersey?
>
> Thanks,
> Tom
>
>
> --
> ATLASSIAN - http://www.atlassian.com
> Our products help over 8,500 customers in more than 95 countries to
> collaborate
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>

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