public class Apache5ConnectorProvider extends Object implements ConnectorProvider
connectors that utilize
Apache HTTP Client to send and receive HTTP request and responses.
The following connector configuration properties are supported:
Apache5ClientProperties.CONNECTION_CLOSING_STRATEGYApache5ClientProperties.CONNECTION_MANAGERApache5ClientProperties.CONNECTION_MANAGER_SHAREDApache5ClientProperties.DISABLE_COOKIESApache5ClientProperties.CREDENTIALS_PROVIDERApache5ClientProperties.KEEPALIVE_STRATEGYApache5ClientProperties.PREEMPTIVE_BASIC_AUTHENTICATIONClientProperties.PROXY_URIClientProperties.PROXY_USERNAMEClientProperties.PROXY_PASSWORDClientProperties.REQUEST_ENTITY_PROCESSING
- default value is RequestEntityProcessing.CHUNKEDApache5ClientProperties.REQUEST_CONFIGApache5ClientProperties.RETRY_STRATEGYApache5ClientProperties.REUSE_STRATEGYApache5ClientProperties.USE_SYSTEM_PROPERTIES
Connector instances created via this connector provider use
chunked encoding as a default setting.
This can be overridden by the ClientProperties.REQUEST_ENTITY_PROCESSING.
By default the ClientProperties.CHUNKED_ENCODING_SIZE property is only supported
when using the default HttpClientConnection instance. If custom
connection manager is used, then chunked encoding size can be set by providing a custom
HttpClientConnection (via custom ManagedHttpClientConnectionFactory)
and overriding it's createOutputStream method.
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
Apache5ClientProperties.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.
Registration of Apache5HttpClientBuilderConfigurator instance on the
Client is supported. A configuration provided by
Apache5HttpClientBuilderConfigurator will override the HttpClientBuilder
configuration set by using the properties.
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, OPTIONS, PATCH and TRACE.
| Constructor and Description |
|---|
Apache5ConnectorProvider() |
| Modifier and Type | Method and Description |
|---|---|
Connector |
getConnector(Client client,
Configuration runtimeConfig)
Get a Jersey client connector instance for a given
client instance
and Jersey client runtime configuration. |
static org.apache.hc.client5.http.cookie.CookieStore |
getCookieStore(Configurable<?> component)
Retrieve the underlying Apache
CookieStore instance from
JerseyClient or JerseyWebTarget
configured to use ApacheConnectorProvider. |
static org.apache.hc.client5.http.classic.HttpClient |
getHttpClient(Configurable<?> component)
Retrieve the underlying Apache
HttpClient instance from
JerseyClient or JerseyWebTarget
configured to use ApacheConnectorProvider. |
public Connector getConnector(Client client, Configuration runtimeConfig)
ConnectorProviderclient instance
and Jersey client runtime configuration.
Note that the supplied runtime configuration can be different from the client instance
configuration as a single client can be used to serve multiple differently configured runtimes.
While the SSL context or hostname verifier
are shared, other configuration properties may change in each runtime.
Based on the supplied client and runtime configuration data, it is up to each connector provider implementation to decide whether a new dedicated connector instance is required or if the existing, previously create connector instance can be reused.
getConnector in interface ConnectorProviderclient - Jersey client instance.runtimeConfig - Jersey client runtime configuration.Connector instance to be used by the client.public static org.apache.hc.client5.http.classic.HttpClient getHttpClient(Configurable<?> component)
HttpClient instance from
JerseyClient or JerseyWebTarget
configured to use ApacheConnectorProvider.component - JerseyClient or JerseyWebTarget instance that is configured to use
ApacheConnectorProvider.HttpClient instance.IllegalArgumentException - in case the component is neither JerseyClient
nor JerseyWebTarget instance or in case the component
is not configured to use a ApacheConnectorProvider.public static org.apache.hc.client5.http.cookie.CookieStore getCookieStore(Configurable<?> component)
CookieStore instance from
JerseyClient or JerseyWebTarget
configured to use ApacheConnectorProvider.component - JerseyClient or JerseyWebTarget instance that is configured to use
ApacheConnectorProvider.CookieStore instance.IllegalArgumentException - in case the component is neither JerseyClient
nor JerseyWebTarget instance or in case the component
is not configured to use a ApacheConnectorProvider.Copyright © 2007-2023, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.