1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.jersey;
12
13 import javax.ws.rs.DELETE;
14 import javax.ws.rs.GET;
15 import javax.ws.rs.HeaderParam;
16 import javax.ws.rs.POST;
17 import javax.ws.rs.Path;
18 import javax.ws.rs.PathParam;
19 import javax.ws.rs.Produces;
20 import javax.ws.rs.QueryParam;
21 import javax.ws.rs.core.Response;
22
23 @Path("/helloworld")
24 public class HelloWorldResource
25 {
26 @POST
27 @Produces("text/plain")
28 public String sayHelloWorld()
29 {
30 return "Hello World";
31 }
32
33 @GET
34 @Produces("application/json")
35 @Path("/sayHelloWithJson/{name}")
36 public HelloBean sayHelloWithJson(@PathParam("name") String name)
37 {
38 HelloBean hello = new HelloBean();
39 hello.setMessage("Hello " + name);
40 return hello;
41 }
42
43 @DELETE
44 @Produces("text/plain")
45 public String deleteHelloWorld()
46 {
47 return "Hello World Delete";
48 }
49
50 @GET
51 @Produces("text/plain")
52 @Path("/sayHelloWithUri/{name}")
53 public String sayHelloWithUri(@PathParam("name") String name)
54 {
55 return "Hello " + name;
56 }
57
58 @GET
59 @Produces("text/plain")
60 @Path("/sayHelloWithHeader")
61 public Response sayHelloWithHeader(@HeaderParam("X-Name") String name)
62 {
63 return Response.status(201).header("X-ResponseName", name).entity("Hello " + name).build();
64 }
65
66 @GET
67 @Produces("text/plain")
68 @Path("/sayHelloWithQuery")
69 public String sayHelloWithQuery(@QueryParam("name") String name)
70 {
71 return "Hello " + name;
72 }
73 }