com.sun.jersey.client.apache4
Class ApacheHttpClient4

java.lang.Object
  extended by com.sun.jersey.api.client.filter.Filterable
      extended by com.sun.jersey.api.client.Client
          extended by com.sun.jersey.client.apache4.ApacheHttpClient4
All Implemented Interfaces:
ClientHandler

public class ApacheHttpClient4
extends Client

A Client that utilizes the Apache HTTP Client to send and receive HTTP request and responses.

The following properties are only supported at construction of this class: ApacheHttpClient4Config.PROPERTY_CONNECTION_MANAGER
ApacheHttpClient4Config.PROPERTY_HTTP_PARAMS}
ApacheHttpClient4Config.PROPERTY_CREDENTIALS_PROVIDER}
ApacheHttpClient4Config.PROPERTY_DISABLE_COOKIES}
ApacheHttpClient4Config.PROPERTY_PROXY_URI}
ApacheHttpClient4Config.PROPERTY_PROXY_USERNAME}
ApacheHttpClient4Config.PROPERTY_PROXY_PASSWORD}
ApacheHttpClient4Config.PROPERTY_PREEMPTIVE_BASIC_AUTHENTICATION}

The default behaviour of the client is different than what it described in the the property ClientConfig.PROPERTY_CHUNKED_ENCODING_SIZE. By default, the apache client uses chunked encoding to write the entity. In order to buffer the entity the property ApacheHttpClient4Config.PROPERTY_ENABLE_BUFFERING must be set to true.

Using of authorization is dependent on the chunk encoding setting. If the entity buffering is enabled, the entity is buffered and authorization can be performed automatically in response to a 401 by sending the request again. When entity buffering is disabled (chunked encoding is used) then the property ApacheHttpClient4Config.PROPERTY_PREEMPTIVE_BASIC_AUTHENTICATION must be set to true.

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.

Author:
jorgeluisw@mac.com, Paul.Sandoz@Sun.Com, pavel.bucek@oracle.com
See Also:
ApacheHttpClient4Config.PROPERTY_CONNECTION_MANAGER

Constructor Summary
ApacheHttpClient4()
          Create a new client instance.
ApacheHttpClient4(ApacheHttpClient4Handler root)
          Create a new client instance.
ApacheHttpClient4(ApacheHttpClient4Handler root, ClientConfig config)
          Create a new client instance with a client configuration.
ApacheHttpClient4(ApacheHttpClient4Handler root, ClientConfig config, IoCComponentProviderFactory provider)
          Create a new instance with a client configuration and a component provider.
 
Method Summary
static ApacheHttpClient4 create()
          Create a default client.
static ApacheHttpClient4 create(ClientConfig cc)
          Create a default client with client configuration.
static ApacheHttpClient4 create(ClientConfig cc, IoCComponentProviderFactory provider)
          Create a default client with client configuration and component provider.
 ApacheHttpClient4Handler getClientHandler()
          Get the Apache HTTP client handler.
 
Methods inherited from class com.sun.jersey.api.client.Client
asyncResource, asyncResource, asyncView, asyncView, asyncView, asyncView, asyncViewResource, asyncViewResource, destroy, finalize, getExecutorService, getMessageBodyWorkers, getProperties, getProviders, getViewProxy, handle, inject, resource, resource, setChunkedEncodingSize, setConnectTimeout, setExecutorService, setFollowRedirects, setReadTimeout, view, view, view, view, view, view, viewResource, viewResource
 
Methods inherited from class com.sun.jersey.api.client.filter.Filterable
addFilter, getHeadHandler, isFilterPresent, isFilterPreset, removeAllFilters, removeFilter
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApacheHttpClient4

public ApacheHttpClient4()
Create a new client instance.


ApacheHttpClient4

public ApacheHttpClient4(ApacheHttpClient4Handler root)
Create a new client instance.

Parameters:
root - the root client handler for dispatching a request and returning a response.

ApacheHttpClient4

public ApacheHttpClient4(ApacheHttpClient4Handler root,
                         ClientConfig config)
Create a new client instance with a client configuration.

Parameters:
root - the root client handler for dispatching a request and returning a response.
config - the client configuration.

ApacheHttpClient4

public ApacheHttpClient4(ApacheHttpClient4Handler root,
                         ClientConfig config,
                         IoCComponentProviderFactory provider)
Create a new instance with a client configuration and a component provider.

Parameters:
root - the root client handler for dispatching a request and returning a response.
config - the client configuration.
provider - the IoC component provider factory.
Method Detail

getClientHandler

public ApacheHttpClient4Handler getClientHandler()
Get the Apache HTTP client handler.

Returns:
the Apache HTTP client handler.

create

public static ApacheHttpClient4 create()
Create a default client.

Returns:
a default client.

create

public static ApacheHttpClient4 create(ClientConfig cc)
Create a default client with client configuration.

Parameters:
cc - the client configuration.
Returns:
a default client.

create

public static ApacheHttpClient4 create(ClientConfig cc,
                                       IoCComponentProviderFactory provider)
Create a default client with client configuration and component provider.

Parameters:
cc - the client configuration.
provider - the IoC component provider factory.
Returns:
a default client.


Copyright © 2015 Oracle Corporation. All Rights Reserved.