-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyResource.java
More file actions
51 lines (41 loc) · 1.15 KB
/
MyResource.java
File metadata and controls
51 lines (41 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package org.manas.java.trail2;
import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.manas.java.trail2.service.MessageService;
@Path("/messages")
public class MyResource {
MessageService obj =new MessageService();
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<MessageResource> getIt() {
return obj.getAllMessages();
}
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public MessageResource receive(MessageResource add)
{
return obj.addMessage(add);
}
@DELETE
@Path("/{messageId}")
@Produces(MediaType.APPLICATION_JSON)
public MessageResource remove(@PathParam("messageId") String messageId)
{
return obj.removeMessage(messageId);
}
@GET
@Path("/{messageId}")
@Produces(MediaType.APPLICATION_JSON)
public MessageResource sendmessage(@PathParam("messageId") String messageId)
{
return obj.getMessage(messageId);
}
}