com.sun.jersey.client.apache4
Class ApacheHttpClient4Handler

java.lang.Object
  extended by com.sun.jersey.api.client.RequestWriter
      extended by com.sun.jersey.api.client.TerminatingClientHandler
          extended by com.sun.jersey.client.apache4.ApacheHttpClient4Handler
All Implemented Interfaces:
ClientHandler

public final class ApacheHttpClient4Handler
extends TerminatingClientHandler

A root handler with Apache HTTP Client acting as a backend.

Client operations are thread safe, the HTTP connection may be shared between different threads.

If a response entity is obtained that is an instance of Closeable then the instance MUST be closed after processing the entity to release connection-based resources.

If a ClientResponse is obtained and an entity is not read from the response then ClientResponse.close() MUST be called after processing the response to release connection-based resources.

The following methods are currently supported: HEAD, GET, POST, PUT, DELETE and OPTIONS.

Chunked transfer encoding can be enabled or disabled but configuration of the chunked encoding size is not possible. If the ClientConfig.PROPERTY_CHUNKED_ENCODING_SIZE property is set to a non-null value then chunked transfer encoding is enabled.

Author:
jorgeluisw@mac.com, Paul.Sandoz@Sun.Com, pavel.bucek@oracle.com

Nested Class Summary
 
Nested classes/interfaces inherited from class com.sun.jersey.api.client.RequestWriter
RequestWriter.RequestEntityWriter, RequestWriter.RequestEntityWriterListener
 
Field Summary
 
Fields inherited from class com.sun.jersey.api.client.RequestWriter
EMPTY_ANNOTATIONS
 
Constructor Summary
ApacheHttpClient4Handler(org.apache.http.client.HttpClient client, org.apache.http.client.CookieStore cookieStore, boolean preemptiveBasicAuth)
          Create a new root handler with an HttpClient.
 
Method Summary
 org.apache.http.client.CookieStore getCookieStore()
          Get the CookieStore.
 org.apache.http.client.HttpClient getHttpClient()
          Get the HttpClient.
 ClientResponse handle(ClientRequest cr)
           
 
Methods inherited from class com.sun.jersey.api.client.RequestWriter
getMessageBodyWorkers, getRequestEntityWriter, setMessageBodyWorkers, writeRequestEntity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApacheHttpClient4Handler

public ApacheHttpClient4Handler(org.apache.http.client.HttpClient client,
                                org.apache.http.client.CookieStore cookieStore,
                                boolean preemptiveBasicAuth)
Create a new root handler with an HttpClient.

Parameters:
client - the HttpClient.
cookieStore - CookieStore instance
preemptiveBasicAuth - turns on preemptive basic authentication
Method Detail

getHttpClient

public org.apache.http.client.HttpClient getHttpClient()
Get the HttpClient.

Returns:
the HttpClient.

getCookieStore

public org.apache.http.client.CookieStore getCookieStore()
Get the CookieStore.

Returns:
the CookieStore instance or null when ApacheHttpClient4Config.PROPERTY_DISABLE_COOKIES set to true.

handle

public ClientResponse handle(ClientRequest cr)
                      throws ClientHandlerException
Throws:
ClientHandlerException


Copyright © 2015 Oracle Corporation. All Rights Reserved.