/[projects]/miscJava/Test4Simple/src/main/java/dk/thoerup/webservice/RestSimpleJerseyTest.java
ViewVC logotype

Diff of /miscJava/Test4Simple/src/main/java/dk/thoerup/webservice/RestSimpleJerseyTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2516 by torben, Mon Apr 27 15:41:43 2015 UTC revision 2517 by torben, Tue Apr 28 05:54:46 2015 UTC
# Line 1  Line 1 
1  package dk.thoerup.webservice;  package dk.thoerup.webservice;
2    
3    import java.io.Serializable;
4    
5  import javax.ws.rs.GET;  import javax.ws.rs.GET;
6  import javax.ws.rs.Path;  import javax.ws.rs.Path;
7  import javax.ws.rs.Produces;  import javax.ws.rs.Produces;
8  import javax.ws.rs.core.MediaType;  import javax.ws.rs.core.MediaType;
9    import javax.xml.bind.annotation.XmlRootElement;
10    
11  @Path("/Rest")  @Path("/samples")
12  public class RestSimpleJerseyTest {  public class RestSimpleJerseyTest {
13                    
14          public static class TestResponse {  
15                  public int id;          @Path("/simple")
                 public String name;  
                   
                 public TestResponse(int i, String n) {  
                         this.id = i;  
                         this.name = n;  
                 }  
                   
         }  
           
         @Path("/Simple")  
16             @GET             @GET
17              @Produces(MediaType.TEXT_PLAIN)              @Produces(MediaType.TEXT_PLAIN)
18              public String getIt() {              public String getIt() {
19                  return "Got it!";                  return "Got it!";
20              }              }
21    
22          @Path("/Object")          @Path("/json")
23               @GET
24               @Produces(MediaType.APPLICATION_JSON)
25                public TestResponse getJSON() {
26                    return new TestResponse(1, "Hej");
27                }
28            
29            @Path("/xml")
30             @GET             @GET
31             @Produces({"application/xml", "application/json"})             @Produces(MediaType.APPLICATION_XML)
32              public TestResponse getObj() {              public TestResponse getXML() {
33                  return new TestResponse(1, "Hej");                  return new TestResponse(1, "Hej");
34              }              }
35                    

Legend:
Removed from v.2516  
changed lines
  Added in v.2517

  ViewVC Help
Powered by ViewVC 1.1.20