You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by SriramSundararajan01 <Sr...@gmail.com> on 2013/02/21 17:15:50 UTC

GZIP filter getting applied for all resource

Hi Team,

   I am using CXF 2.5.9 version for REST webservices. I am trying out GZIP
compression using @GZIP annotation. I have two resource classes ResourceOne
and ResourceTwo as below
@Path("/uri/{name}")
public class ResourceTwo {
}

@Path("/{name}")
@GZIP(threshold = 0)
public class ResourceOne {
}

 After adding this I was expecting only the response of methods in
ResourceOne class to be compressed. But even the response from ResourceTwo
class are compressed. When I checked the CXF logs, it clearly says
GZIPInterceptor is being applied. In my xml file I dint add any
GZIPInterceptor as well.

Please let me know what I am doing wrong here. 


Thanks,
Sriram




--
View this message in context: http://cxf.547215.n5.nabble.com/GZIP-filter-getting-applied-for-all-resource-tp5723541.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: GZIP filter getting applied for all resource

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 21/02/13 16:15, SriramSundararajan01 wrote:
> Hi Team,
>
>     I am using CXF 2.5.9 version for REST webservices. I am trying out GZIP
> compression using @GZIP annotation. I have two resource classes ResourceOne
> and ResourceTwo as below
> @Path("/uri/{name}")
> public class ResourceTwo {
> }
>
> @Path("/{name}")
> @GZIP(threshold = 0)
> public class ResourceOne {
> }
>
>   After adding this I was expecting only the response of methods in
> ResourceOne class to be compressed. But even the response from ResourceTwo
> class are compressed. When I checked the CXF logs, it clearly says
> GZIPInterceptor is being applied. In my xml file I dint add any
> GZIPInterceptor as well.
>
> Please let me know what I am doing wrong here.
>
The interceptor is applied to the whole endpoint so it affects even 
those resources which should have their data GZIP-processed.

You can create two endpoints, example, with jaxrs:@address="/" (and 
ResourceOne) and jaxrs:@address="/uri" (and ResourceTwo) or dynamically 
add GZIP interceptor, say, to the outbound chain - you can register 
RequestHandler out interceptor, inject @Context UriInfo in it, if the 
path has "/uri" - then don't add it, otherwise do, example,

outMessage.getInterceptorChain().add(new GZIPOutInterceptor());

Strating from CXF 2.7.x this dynamic application of GZIP will also be 
possible to do with JAX-RS 2.0 name bindings

HTH
Sergey

>
> Thanks,
> Sriram
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/GZIP-filter-getting-applied-for-all-resource-tp5723541.html
> Sent from the cxf-user mailing list archive at Nabble.com.


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com