javax.ws.rs.container
Interface ContainerResponseFilter


public interface ContainerResponseFilter

An extension interface implemented by container response filters.

By default, i.e. if no name binding is applied to the filter implementation class, the filter instance is applied globally, however only for the responses for which the incoming request has been matched to a particular resource by JAX-RS runtime. If there is a @NameBinding annotation applied to the filter, the filter will also be executed at the post-match response extension point, but only in case the matched resource or sub-resource method is bound to the same name-binding annotation.

In case the filter should be applied at the pre-match response extension point, i.e. globaly for any response, regardless of whether the originating request has been matched to a particular resource or sub-resource method or not, the filter MUST be annotated with a @PreMatching annotation.

Implement a name-bound or global response filter in cases when you want limit the filter functionality to a particular resource or resource method or if you depend on a matched resource information in your filter processing. In other cases, when the filter should be applied globally to all responses, even in those cases when a request has not been matched to a resource implement a pre-matching response filter.

Filters implementing this interface must be annotated with @Provider to be discovered by the JAX-RS runtime. Container response filter instances may also be discovered and bound dynamically to particular resource methods.

Since:
2.0
Author:
Marek Potociar, Santiago Pericas-Geertsen
See Also:
PreMatching, ContainerRequestFilter

Method Summary
 void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
          Filter method called after a response has been provided for a request (either by a request filter or by a matched resource method.
 

Method Detail

filter

void filter(ContainerRequestContext requestContext,
            ContainerResponseContext responseContext)
            throws java.io.IOException
Filter method called after a response has been provided for a request (either by a request filter or by a matched resource method.

Filters in the filter chain are ordered according to their binding priority (see BindingPriority).

Parameters:
requestContext - request context.
responseContext - response context.
Throws:
java.io.IOException - if an I/O exception occurs.
See Also:
PreMatching


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.