users@jersey.java.net

XML root element customaization

From: Herak Sen <HSen_at_vertrax.com>
Date: Mon, 31 Aug 2009 12:01:14 -0400

I could not find a way to change the root element of XML generated when a collection is returned ( without writing custom message writers).
e.g.

/*Bean */

@XmlRootElement(name="customer")
public class CustomerBean
{
      public int id = 10;
      public String name = "John";
}

/*REST Resource */
public Collection< CustomerBean > test()
{
return Collections.singletonList(new CustomerBean ());
}

/*Generated XML */

<customerBeans> -- I thought the root element will be 'customers', is it a JAXB stuff?
<customer>
<id>10</id>
<name>John</name>
</customer>
</customerBeans>

Herak