users@jersey.java.net

Response or void or String ??

From: Felipe Gaúcho <fgaucho_at_gmail.com>
Date: Tue, 5 May 2009 19:52:04 +0200

Now I have three choices for my methods with return type void:

---------- option #1: do nothing..
        @DELETE
        @Path("/delete/{id}")
        public void delete(@PathParam("id") String id) throws ... {
                FpEvent event = eventFacade.read(Long.valueOf(id));
                eventFacade.delete(event);
        }

---------- option #2: return a String..
        @DELETE
        @Path("/delete/{id}")
        public String delete(@PathParam("id") String id) throws ... {
                FpEvent event = eventFacade.read(Long.valueOf(id));
                eventFacade.delete(event);
                return "what is the benefit?";
        }

---------- option #2: use a void response ?

        private static final Response VOID_RESPONSE = Response.noContent().build();
        
        @DELETE
        @Path("/delete/{id}")
        public Response delete(@PathParam("id") String id) throws ... {
                FpEvent event = eventFacade.read(Long.valueOf(id));
                eventFacade.delete(event);

                return VOID_RESPONSE;
        }

---------- option #4: any better choice ?