Skip to content

Instantly share code, notes, and snippets.

@ludovicfrin
Last active February 1, 2016 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ludovicfrin/96b5277820d899145a46 to your computer and use it in GitHub Desktop.
Save ludovicfrin/96b5277820d899145a46 to your computer and use it in GitHub Desktop.
Contrôleur pour service RestFul Jersey
package fr.frin.jersey;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import fr.frin.phonesync.webapp.entity.Sms;
/**
* Controleur
*
* @author Ludovic FRIN
*/
@Path("/entity")
public class Controller {
@GET
@Produces({ MediaType.APPLICATION_JSON })
public List<Entity> read() {
...
}
@GET @Path("{id}")
@Produces({ MediaType.APPLICATION_JSON })
public Entity read(@PathParam("id") Long id) {
...
}
@POST @Path("{id}")
@Consumes({MediaType.APPLICATION_JSON})
@Produces({ MediaType.APPLICATION_JSON })
public Entity create (Entity entity) {
...
}
@DELETE @Path("{id}")
@Produces({ MediaType.APPLICATION_JSON })
public Response delete (@PathParam("id") Long id) {
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment