Class ApacheConnectorProvider
- java.lang.Object
-
- org.glassfish.jersey.apache.connector.ApacheConnectorProvider
-
- All Implemented Interfaces:
ConnectorProvider
public class ApacheConnectorProvider extends Object implements ConnectorProvider
Connector provider for Jerseyconnectorsthat utilize Apache HTTP Client to send and receive HTTP request and responses.The following connector configuration properties are supported:
ApacheClientProperties.CONNECTION_CLOSING_STRATEGYApacheClientProperties.CONNECTION_MANAGERApacheClientProperties.CONNECTION_MANAGER_SHAREDApacheClientProperties.CONNECTION_CLOSING_STRATEGYApacheClientProperties.CREDENTIALS_PROVIDERApacheClientProperties.DISABLE_COOKIESApacheClientProperties.KEEPALIVE_STRATEGYApacheClientProperties.PREEMPTIVE_BASIC_AUTHENTICATIONClientProperties.PROXY_URIClientProperties.PROXY_USERNAMEClientProperties.PROXY_PASSWORDClientProperties.REQUEST_ENTITY_PROCESSING- default value isRequestEntityProcessing.CHUNKEDApacheClientProperties.REQUEST_CONFIGApacheClientProperties.RETRY_HANDLERApacheClientProperties.REUSE_STRATEGYApacheClientProperties.USE_SYSTEM_PROPERTIES
Connector instances created via this connector provider use
chunked encodingas a default setting. This can be overridden by theClientProperties.REQUEST_ENTITY_PROCESSING. By default theClientProperties.CHUNKED_ENCODING_SIZEproperty is only supported when using the defaultorg.apache.http.conn.HttpClientConnectionManagerinstance. If custom connection manager is used, then chunked encoding size can be set by providing a customorg.apache.http.HttpClientConnection(via customorg.apache.http.impl.conn.ManagedHttpClientConnectionFactory) and overriding it'screateOutputStreammethod.Use of authorization by the AHC-based connectors 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
ApacheClientProperties.PREEMPTIVE_BASIC_AUTHENTICATIONmust be set totrue.If a
ClientResponseis obtained and an entity is not read from the response thenInboundMessageContext.close()MUST be called after processing the response to release connection-based resources.Registration of
ApacheHttpClientBuilderConfiguratorinstance on theClientis supported. A configuration provided byApacheHttpClientBuilderConfiguratorwill override theHttpClientBuilderconfiguration set by using the properties.If a response entity is obtained that is an instance of
Closeablethen 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, OPTIONS, PATCH and TRACE.
- Since:
- 2.5
- Author:
- Pavel Bucek, Arul Dhesiaseelan (aruld at acm.org), jorgeluisw at mac.com, Marek Potociar, Paul Sandoz, Maksim Mukosey (mmukosey at gmail.com)
-
-
Constructor Summary
Constructors Constructor Description ApacheConnectorProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ConnectorgetConnector(Client client, Configuration runtimeConfig)static org.apache.http.client.CookieStoregetCookieStore(Configurable<?> component)Retrieve the underlying ApacheCookieStoreinstance fromJerseyClientorJerseyWebTargetconfigured to useApacheConnectorProvider.static org.apache.http.client.HttpClientgetHttpClient(Configurable<?> component)Retrieve the underlying ApacheHttpClientinstance fromJerseyClientorJerseyWebTargetconfigured to useApacheConnectorProvider.
-
-
-
Method Detail
-
getConnector
public Connector getConnector(Client client, Configuration runtimeConfig)
- Specified by:
getConnectorin interfaceConnectorProvider
-
getHttpClient
public static org.apache.http.client.HttpClient getHttpClient(Configurable<?> component)
Retrieve the underlying ApacheHttpClientinstance fromJerseyClientorJerseyWebTargetconfigured to useApacheConnectorProvider.- Parameters:
component-JerseyClientorJerseyWebTargetinstance that is configured to useApacheConnectorProvider.- Returns:
- underlying Apache
HttpClientinstance. - Throws:
IllegalArgumentException- in case thecomponentis neitherJerseyClientnorJerseyWebTargetinstance or in case the component is not configured to use aApacheConnectorProvider.- Since:
- 2.8
-
getCookieStore
public static org.apache.http.client.CookieStore getCookieStore(Configurable<?> component)
Retrieve the underlying ApacheCookieStoreinstance fromJerseyClientorJerseyWebTargetconfigured to useApacheConnectorProvider.- Parameters:
component-JerseyClientorJerseyWebTargetinstance that is configured to useApacheConnectorProvider.- Returns:
- underlying Apache
CookieStoreinstance. - Throws:
IllegalArgumentException- in case thecomponentis neitherJerseyClientnorJerseyWebTargetinstance or in case the component is not configured to use aApacheConnectorProvider.- Since:
- 2.16
-
-