Class GrizzlyConnectorProvider
- All Implemented Interfaces:
ConnectorProvider
connectors
that utilize
Grizzly Asynchronous HTTP Client to send and receive HTTP request and responses.
The following connector configuration properties are supported:
ClientProperties.CONNECT_TIMEOUT
ClientProperties.READ_TIMEOUT
ClientProperties.REQUEST_ENTITY_PROCESSING
- default value isRequestEntityProcessing.CHUNKED
ClientProperties.PROXY_URI
ClientProperties.PROXY_USERNAME
ClientProperties.PROXY_PASSWORD
Connector instances created via this connector provider use
chunked encoding
as a default setting.
This can be overridden by the ClientProperties.REQUEST_ENTITY_PROCESSING
.
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.
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.
- Since:
- 2.5
- Author:
- Marek Potociar
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
A customization SPI for the async client instance underlying Grizzly connectors.static interface
A customization SPI for the async client request instances. -
Constructor Summary
ConstructorDescriptionCreate new Grizzly Async HTTP Client connector provider.GrizzlyConnectorProvider
(GrizzlyConnectorProvider.AsyncClientCustomizer asyncClientCustomizer) Create new Grizzly Async HTTP Client connector provider with a custom client configuration customizer. -
Method Summary
Modifier and TypeMethodDescriptiongetConnector
(Client client, Configuration config) Get a Jersey client connector instance for a givenclient
instance and Jersey client runtimeconfiguration
.static com.ning.http.client.AsyncHttpClient
getHttpClient
(Configurable<?> component) Retrieve the underlying GrizzlyAsyncHttpClient
instance fromJerseyClient
orJerseyWebTarget
configured to useGrizzlyConnectorProvider
.static Invocation.Builder
register
(Invocation.Builder builder, GrizzlyConnectorProvider.RequestCustomizer customizer) Register a request customizer for a single request.static ClientConfig
register
(ClientConfig config, GrizzlyConnectorProvider.RequestCustomizer customizer) Register a request customizer for a all requests executed by a client instance configured with this client config.
-
Constructor Details
-
GrizzlyConnectorProvider
public GrizzlyConnectorProvider()Create new Grizzly Async HTTP Client connector provider. -
GrizzlyConnectorProvider
public GrizzlyConnectorProvider(GrizzlyConnectorProvider.AsyncClientCustomizer asyncClientCustomizer) Create new Grizzly Async HTTP Client connector provider with a custom client configuration customizer.- Parameters:
asyncClientCustomizer
- Async HTTP Client configuration customizer.- Since:
- 2.10
-
-
Method Details
-
getConnector
Description copied from interface:ConnectorProvider
Get a Jersey client connector instance for a givenclient
instance and Jersey client runtimeconfiguration
.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
orhostname 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.
- Specified by:
getConnector
in interfaceConnectorProvider
- Parameters:
client
- Jersey client instance.config
- Jersey client runtime configuration.- Returns:
- configured
Connector
instance to be used by the client.
-
getHttpClient
Retrieve the underlying GrizzlyAsyncHttpClient
instance fromJerseyClient
orJerseyWebTarget
configured to useGrizzlyConnectorProvider
.- Parameters:
component
-JerseyClient
orJerseyWebTarget
instance that is configured to useGrizzlyConnectorProvider
.- Returns:
- underlying Grizzly
AsyncHttpClient
instance. - Throws:
IllegalArgumentException
- in case thecomponent
is neitherJerseyClient
norJerseyWebTarget
instance or in case the component is not configured to use aGrizzlyConnectorProvider
.- Since:
- 2.8
-
register
public static Invocation.Builder register(Invocation.Builder builder, GrizzlyConnectorProvider.RequestCustomizer customizer) Register a request customizer for a single request. A registered customizer will be used to customize the underlying Async HTTP Client request builder.Invoking this method on an instance that is not configured to use Grizzly Async HTTP Client connector does not have any effect.
- Parameters:
builder
- JAX-RS request invocation builder.customizer
- request customizer to be registered.- Returns:
- updated Jersey client config with the Grizzly
GrizzlyConnectorProvider.RequestCustomizer
attached.
-
register
public static ClientConfig register(ClientConfig config, GrizzlyConnectorProvider.RequestCustomizer customizer) Register a request customizer for a all requests executed by a client instance configured with this client config. A registered customizer will be used to customize underlying Async HTTP Client request builders for all requests created using the Jersey client instance configured with this client config.Invoking this method on an instance that is not configured to use Grizzly Async HTTP Client connector does not have any effect.
- Parameters:
config
- Jersey client configuration.customizer
- Async HTTP Client configuration customizer.- Returns:
- updated JAX-RS client invocation builder with the Grizzly
RequestCustomizer
attached.
-