12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package microfolies;
- import java.net.URI;
- import java.util.Date;
- import java.util.logging.Logger;
- import javax.ws.rs.GET;
- import javax.ws.rs.PathParam;
- import javax.ws.rs.Produces;
- import javax.ws.rs.core.UriBuilder;
- import org.glassfish.jersey.jdkhttp.JdkHttpServerFactory;
- import org.glassfish.jersey.server.ResourceConfig;
- import com.sun.net.httpserver.HttpServer;
- @Path("/microfolies")
- @Produces("text/plain")
- public class RestApplication {
- private static Logger LOGGER = Logger.getLogger("jai.jaxrs");
- @Path("/badge/{id}/{espace}")
- @GET
- public String validerBadge(@PathParam("id") String id, @PathParam("espace") String espace) {
- LOGGER.info("validation du badge " + id + " a l'espace " + espace);
- return "Success";
- }
- @Path("freq/{espace}/{from}/{to}")
- @GET
- public int frequence(@PathParam("espace") String espace, @PathParam("from") Date from, @PathParam("to") Date to) {
- LOGGER.info("frequence de " + from + " a " + to + " espace " + espace);
- return "Graphe";
- }
- @Path("profile/{id}")
- @GET
- public int profil(@PathParam("id")String id) {
- LOGGER.info("profil " +id);
- return "Profil";
- }
- public static void main(String[] args) {
- URI baseUri = UriBuilder.fromUri("http://localhost/").port(9998).build();
- ResourceConfig config = new ResourceConfig(RestApplication.class);
- HttpServer server = JdkHttpServerFactory.createHttpServer(baseUri, config);
- }
- }
|