Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Path("/test")
- public class TestResource {
- @GET
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- @XmlElementWrapper( name= "tests")
- @XmlElements({
- @XmlElement(name= "coolTest", type=CoolTest.class)
- /**Add other type of test that are managed by this resource **/})
- public List<Test> getTests(){
- List<Test> tests = new ArrayList<Test>();
- tests.add(new CoolTest("1", "Cool"));
- return tests;
- }
- }
- @XmlTransient
- public abstract class Test {
- private String id;
- public Test(){}
- public Test(String id){
- this.id = id;
- }
- @XmlElement
- public String getId() {
- return id;
- }
- public void setId(String id) {
- this.id = id;
- }
- }
- @XmlRootElement
- public class CoolTest extends Test{
- private String coolMsg;
- public CoolTest(){}
- public CoolTest(String id, String coolTest){
- super(id);
- this.coolMsg = coolTest;
- }
- @XmlElement
- public String getCoolMsg() {
- return coolMsg;
- }
- public void setCoolMsg(String coolTest) {
- this.coolMsg = coolTest;
- }
- }
- SEVERE: A message body writer for Java class java.util.ArrayList, and Java type java.util.List<org.arrowhead.wp5.core.model.Test>, and MIME media type application/xml was not found.
- @XmlRootElement
- @XmlSeeAlso({CoolTest.class})
- @Path("/test")
- @XmlRootElement
- public class TestResource {
- @XmlElementWrapper(name = "tests")
- @XmlElements({@XmlElement(name="coolTestPotato", type=CoolTest.class)})
- public List<Test> getTestList(){
- List<Test> tests = new ArrayList<Test>();
- tests.add(new CoolTest("1", "Cool"));
- return tests;
- }
- @GET
- @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
- public TestResource getTests(){
- return this;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement