org.glassfish.jersey.apache.connector
Class ApacheConnector

java.lang.Object
  extended by org.glassfish.jersey.apache.connector.ApacheConnector
All Implemented Interfaces:
Connector, Inflector<ClientRequest,ClientResponse>

public class ApacheConnector
extends Object
implements Connector

A Connector 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:

By default a request entity is buffered and repeatable such that authorization may be performed automatically in response to a 401 response.

If the property ClientProperties.CHUNKED_ENCODING_SIZE size is set to a value greater than 0 then chunked encoding will be enabled and the request entity (if present) will not be buffered and is not repeatable. For authorization to work in such scenarios the property ApacheClientProperties.PREEMPTIVE_BASIC_AUTHENTICATION must be set to true.

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

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.

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

Author:
jorgeluisw@mac.com, Paul Sandoz (paul.sandoz at oracle.com), Pavel Bucek (pavel.bucek at oracle.com), Arul Dhesiaseelan (aruld at acm.org)
See Also:
ApacheClientProperties.CONNECTION_MANAGER

Constructor Summary
ApacheConnector(Configuration config)
          Create the new Apache HTTP Client connector.
 
Method Summary
 ClientResponse apply(ClientRequest clientRequest)
           
 Future<?> apply(ClientRequest request, AsyncConnectorCallback callback)
           
 void close()
           
 org.apache.http.client.CookieStore getCookieStore()
          Get the CookieStore.
 org.apache.http.client.HttpClient getHttpClient()
          Get the HttpClient.
 String getName()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ApacheConnector

public ApacheConnector(Configuration config)
Create the new Apache HTTP Client connector.

Parameters:
config - client configuration.
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 set to true.

apply

public ClientResponse apply(ClientRequest clientRequest)
                     throws ProcessingException
Specified by:
apply in interface Connector
Specified by:
apply in interface Inflector<ClientRequest,ClientResponse>
Throws:
ProcessingException

apply

public Future<?> apply(ClientRequest request,
                       AsyncConnectorCallback callback)
Specified by:
apply in interface Connector

getName

public String getName()
Specified by:
getName in interface Connector

close

public void close()
Specified by:
close in interface Connector


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