users@jax-rs-spec.java.net

[jax-rs-spec users] [jsr339-experts] Re: Accessing request in WriterInterceptor.aroundWriteTo() ?

From: Jan Algermissen <jan.algermissen_at_nordsc.com>
Date: Thu, 8 Nov 2012 08:30:31 +0100

On Nov 8, 2012, at 3:52 AM, Bill Burke <bburke_at_redhat.com> wrote:

>
>
> On 11/7/2012 6:45 PM, Jan Algermissen wrote:
>>
>> On Nov 8, 2012, at 12:39 AM, Bill Burke <bburke_at_redhat.com> wrote:
>>
>>> Or an injection of ContainerRequestContext?
>>>
>>> @Context
>>> ContainerRequestContext rctx;
>>
>> Yes, that would be even better - but wouldn't that have to be an instance local to aroundWriteTo?
>>
>
> thread local proxies for these types of field injections.
>

See... thread local has been on my dive-into list for a while. Thanks.

So, I would just do this, right? (IOW, nothing new needed to support my use case)

@Provider
class TestInterceptor implements WriterInterceptor {
        
  @Context
  HttpHeaders headers;
                
  @Override
  public void aroundWriteTo(WriterInterceptorContext wCtx)
         throws IOException, WebApplicationException {
        
      String h = headers.getHeaderString("Accept-Encoding");
      if(if h !=null && h.contains("gzip") ) {
        // hook gzipper into the ostream
      }
  }
}





> --
> Bill Burke
> JBoss, a division of Red Hat
> http://bill.burkecentral.com