public abstract class ClientFilter extends java.lang.Object implements ClientHandler
An application-based filter extends this class and implements the
ClientHandler.handle(com.sun.jersey.api.client.ClientRequest)
method. The general implementation pattern
is as follows:
class AppClientFilter extends ClientFilter { public ClientResponse handle(ClientRequest cr) { // Modify the request ClientRequest mcr = modifyRequest(cr); // Call the next client handler in the filter chain ClientResponse resp = getNext().handle(mcr); // Modify the response return modifyResponse(resp); } }
A client filter is re-entrant and may be called by by more than one thread at the same time.
A client filter instance MUST be occur at most once in any Filterable
instance, otherwise unexpected results may occur.
If it is necessary to add the same type of client filter more than once
to the same Filterable
instance or to more than one Filterable
instance then a new instance of that filter MUST be added.
Constructor and Description |
---|
ClientFilter() |
Modifier and Type | Method and Description |
---|---|
ClientHandler |
getNext()
Get the next client handler to invoke in the chain
of filters.
|
abstract ClientResponse |
handle(ClientRequest cr)
Handle a HTTP request as a
ClientRequest and return the HTTP
response as a ClientResponse . |
public final ClientHandler getNext()
public abstract ClientResponse handle(ClientRequest cr) throws ClientHandlerException
ClientHandler
ClientRequest
and return the HTTP
response as a ClientResponse
.handle
in interface ClientHandler
cr
- the HTTP request.ClientHandlerException
- if the client
handler fails to process the request or response.Copyright © 2016 Oracle Corporation. All Rights Reserved.