users@jersey.java.net

[Jersey] Re: Do Jersey have a way to detal with JAXB objects without @XmlRootElement?

From: Dhanush Gopinath <dhanush.gopinath_at_altair.com>
Date: Thu, 23 Dec 2010 14:45:05 +0530

Hi Grant,

 

I do not think this is a bad feature since this is already mentioned in
the user guide
(http://jersey.java.net/nonav/documentation/latest/xml.html#d0e1867) but
it will be better to change the return type as JAXBElement<T> rather
than using Object.

 

Thanks

Dhanush

 

________________________________

From: Grant Yang [mailto:guang.g.yang_at_oracle.com]
Sent: Thursday, December 23, 2010 7:26 AM
To: users_at_jersey.java.net
Cc: Thorick Chow; Gerard Davison
Subject: [Jersey] Do Jersey have a way to detal with JAXB objects
without @XmlRootElement?

 

Hi experts,

 

We met a not very big issue on developing our solutions, but I guess a
confirmation will do great help.

 

That is, we have multiple XSD to construct our objects and they import
and referred each other. Our problem is sometimes we will meet some
generated POJO without @XmlRootElement with that (after investigation
these POJO are not the out most Element) but we really want to return
that in JAX-RS resource methods.

 

Currently we are ! doing workaround by ObjectFactory and it seems
working fine, but it just looks like a workaround;

 

@GET

public Object a() {

final JAXBElement<MyPOJO> jaxb = new
ObjectFactory().createMyPOJO(myPOJO);

return jaxb;

}

 

I am wondering is there any more graceful way to handle this case. I
browsed the internet and it seems some JAX-RS container have some
switches to do this for application developers - do you think we have
similar solution in Jersey, or at least d! o you think this is a good
feature for future?

 

Thanks

Grant.