Hi folks,

I am working on a poc using resteasy framework and  resteasy's 

the resource looks like this

    public Response getUserDetails(@PathParam("id") String id);

The business logic is implemented using a stateless ejb  below is the 

    public Response getUserDetails(HttpRequest request, String id) {
  -----  business logic -------
        ResponseBuilder builder = Response.ok());
        return builder.build();

The interceptor class code is mentioned below

public class ResponseInterceptor implements MessageBodyWriterInterceptor{
    private static final Logger logger = 
    ResponseBuilder builder = null;
    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")


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

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:
Resteasy-users mailing list

Reply via email to