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_TIMEOUTClientProperties.READ_TIMEOUTClientProperties.REQUEST_ENTITY_PROCESSING- default value isRequestEntityProcessing.CHUNKEDClientProperties.PROXY_URIClientProperties.PROXY_USERNAMEClientProperties.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
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA customization SPI for the async client instance underlying Grizzly connectors.static interfaceA customization SPI for the async client request instances. -
Constructor Summary
ConstructorsConstructorDescriptionCreate 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 givenclientinstance and Jersey client runtimeconfiguration.static com.ning.http.client.AsyncHttpClientgetHttpClient(Configurable<?> component) Retrieve the underlying GrizzlyAsyncHttpClientinstance fromJerseyClientorJerseyWebTargetconfigured to useGrizzlyConnectorProvider.static Invocation.Builderregister(Invocation.Builder builder, GrizzlyConnectorProvider.RequestCustomizer customizer) Register a request customizer for a single request.static ClientConfigregister(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:ConnectorProviderGet a Jersey client connector instance for a givenclientinstance 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 contextorhostname verifierare 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:
getConnectorin interfaceConnectorProvider- Parameters:
client- Jersey client instance.config- Jersey client runtime configuration.- Returns:
- configured
Connectorinstance to be used by the client.
-
getHttpClient
Retrieve the underlying GrizzlyAsyncHttpClientinstance fromJerseyClientorJerseyWebTargetconfigured to useGrizzlyConnectorProvider.- Parameters:
component-JerseyClientorJerseyWebTargetinstance that is configured to useGrizzlyConnectorProvider.- Returns:
- underlying Grizzly
AsyncHttpClientinstance. - Throws:
IllegalArgumentException- in case thecomponentis neitherJerseyClientnorJerseyWebTargetinstance 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.RequestCustomizerattached.
-
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
RequestCustomizerattached.
-