Hi folks, I am working on a poc using resteasy framework and resteasy's MessageBodyWriterInterceptor
the resource looks like this @GET @Path("/{id}") public Response getUserDetails(@PathParam("id") String id); The business logic is implemented using a stateless ejb below is the implementation @Override public Response getUserDetails(HttpRequest request, String id) { ----- business logic ------- ResponseBuilder builder = Response.ok()); return builder.build(); } The interceptor class code is mentioned below ============================== @Provider @ServerInterceptor public class ResponseInterceptor implements MessageBodyWriterInterceptor{ private static final Logger logger = Logger.getLogger(ResponseInterceptor.class); ResponseBuilder builder = null; @Override public void write(MessageBodyWriterContext context) throws IOException, WebApplicationException { Object entity = context.getEntity(); logger.debug("Response interceptor: "+entity.getClass()); if (entity != null) { if ( entity instanceof User){ User entls = (User)entity; if (entls !=null && entls.getErrorCode()!=null) { if (entls.getErrorCode() == Status.BAD_REQUEST.getStatusCode()){ logger.debug("Response interceptor: "+entls.getErrorCode()); throw new BadRequestException("Bad request",Response.status(400) .entity(entls).header("Bad request", "400") .type("application/xml") .build()); } My question are the following 1. Whether it's good to create all the response from the interceptor class i.e . for htpp 200, 40*, 50* etc..or we should handle only exceptional cases which are then Handel by the Exception mappers 2. What is the advantage of PostProcessorInterceptors over MessageBodyWriterInterceptor ? 3. Could you please provide some sample use case? 4. out of Resteasy interceptor and Ejb interceptor which one is good in terms of performance ? Thanks & Regards BBSR ------------------------------------------------------------------------------ Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and much more. Get web development skills now with LearnDevNow - 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. SALE $99.99 this month only -- learn more at: http://p.sf.net/sfu/learnmore_122812 _______________________________________________ Resteasy-users mailing list Resteasy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/resteasy-users