Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package resources;
- import java.util.ArrayList;
- import java.util.List;
- import javax.ejb.Singleton;
- import javax.ws.rs.core.Context;
- import javax.ws.rs.core.UriInfo;
- import javax.ws.rs.Consumes;
- import javax.ws.rs.Produces;
- import javax.ws.rs.GET;
- import javax.ws.rs.Path;
- import javax.ws.rs.PUT;
- import javax.ws.rs.core.MediaType;
- /**
- * REST Web Service
- *
- * @author tomas
- */
- @Singleton
- @Path("zoznam")
- public class ZoznamResource {
- @Context
- private UriInfo context;
- private List<String> zoznam;
- /**
- * Creates a new instance of ZoznamResource
- */
- public ZoznamResource() {
- zoznam = new ArrayList<>();
- zoznam.add("test1");
- zoznam.add("test2");
- }
- /**
- * Retrieves representation of an instance of resources.ZoznamResource
- * @return an instance of java.lang.String
- */
- @GET
- @Path("zoznam")
- @Produces(MediaType.TEXT_PLAIN)
- public String getText() {
- //TODO return proper representation object
- StringBuilder ret = new StringBuilder();
- zoznam.forEach(val->{
- ret.append(val).append("\n");
- });
- return ret.toString();
- }
- /**
- * PUT method for updating or creating an instance of ZoznamResource
- * @param content representation for the resource
- */
- @PUT
- @Consumes(MediaType.TEXT_PLAIN)
- public void putText(String content) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement