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

Contents of /miscJava/Test3/src/main/java/dk/thoerup/webservice/RestSimpleJerseyTest.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2513 - (show annotations) (download)
Sat Apr 25 21:18:52 2015 UTC (9 years ago) by torben
File size: 671 byte(s)
Adding jax-rs sample
1 package dk.thoerup.webservice;
2
3 import javax.ws.rs.GET;
4 import javax.ws.rs.Path;
5 import javax.ws.rs.Produces;
6 import javax.ws.rs.core.MediaType;
7
8 @Path("/Rest")
9 public class RestSimpleJerseyTest {
10
11 public static class TestResponse {
12 public int id;
13 public String name;
14
15 public TestResponse(int i, String n) {
16 this.id = i;
17 this.name = n;
18 }
19
20 }
21
22 @Path("/Simple")
23 @GET
24 @Produces(MediaType.TEXT_PLAIN)
25 public String getIt() {
26 return "Got it!";
27 }
28
29 @Path("/Object")
30 @GET
31 @Produces({"application/xml", "application/json"})
32 public TestResponse getObj() {
33 return new TestResponse(1, "Hej");
34 }
35
36
37
38
39
40 }

  ViewVC Help
Powered by ViewVC 1.1.20