javax.ws.rs.ext
Interface FilterContext


public interface FilterContext

Context class used by filters implementing RequestFilter or ResponseFilter (or both).

Since:
2.0
Author:
Santiago Pericas-Geertsen, Bill Burke

Method Summary
 Response.ResponseBuilder createResponse()
          Create a fresh response builder instance.
 Map<String,Object> getProperties()
          Get a mutable map of request-scoped properties that can be used for communication between different request/response processing components.
 Request getRequest()
          Get the request object.
 Request.RequestBuilder getRequestBuilder()
          Get a builder for the request object.
 Response getResponse()
          Get the response object.
 Response.ResponseBuilder getResponseBuilder()
          Get a builder for the response object.
 void setRequest(Request req)
          Set the request object in the context.
 void setResponse(Response res)
          Set the response object in the context.
 

Method Detail

getProperties

Map<String,Object> getProperties()
Get a mutable map of request-scoped properties that can be used for communication between different request/response processing components. May be empty, but MUST never be null. In the scope of a single request/response processing, a same property map instance is shared by the following methods: A request-scoped property is an application-defined property that may be added, removed or modified by any of the components (user, filter, interceptor etc.) that participate in a given request/response processing flow.

On the client side, this property map is initialized by calling Configuration.setProperties(java.util.Map) or Configuration.setProperty(java.lang.String, java.lang.Object) on the configuration object associated with the corresponding request invocation.

On the server side, specifying the initial values is implementation-specific.

If there are no initial properties set, the request-scoped property map is initialized to an empty map.

Returns:
a mutable request-scoped property map.
See Also:
Configuration

getRequest

Request getRequest()
Get the request object.

Returns:
request object being filtered.

getResponse

Response getResponse()
Get the response object. May return null if a response is not available, e.g. in a RequestFilter, and has not been set by calling setResponse(javax.ws.rs.core.Response).

Returns:
response object being filtered or null.

setRequest

void setRequest(Request req)
Set the request object in the context.

Parameters:
req - request object to be set.

setResponse

void setResponse(Response res)
Set the response object in the context. A caching filter that implements RequestFilter or PreMatchRequestFilter could set a response by calling this method. See RequestFilter.preFilter(javax.ws.rs.ext.FilterContext) and PreMatchRequestFilter.preMatchFilter(javax.ws.rs.ext.FilterContext) for more information.

Parameters:
res - response object to be set.

getRequestBuilder

Request.RequestBuilder getRequestBuilder()
Get a builder for the request object. A newly built request can be set by calling setRequest(javax.ws.rs.core.Request).

Returns:
request builder object.

getResponseBuilder

Response.ResponseBuilder getResponseBuilder()
Get a builder for the response object. May return null if a response is not available, e.g. in a RequestFilter, and has not been set. A newly built response can be set by calling setResponse(javax.ws.rs.core.Response).

Returns:
response builder object or null.

createResponse

Response.ResponseBuilder createResponse()
Create a fresh response builder instance. A caching filter could call this method to get a response builder and initialize it from a cache. This method does not update the state of the context object.

Returns:
newly created response builder
See Also:
setResponse(javax.ws.rs.core.Response)


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