Class GrizzlyConnectorProvider
- java.lang.Object
-
- org.glassfish.jersey.grizzly.connector.GrizzlyConnectorProvider
-
- All Implemented Interfaces:
ConnectorProvider
public class GrizzlyConnectorProvider extends Object implements ConnectorProvider
Connector provider for Jerseyconnectorsthat 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 encodingas a default setting. This can be overridden by theClientProperties.REQUEST_ENTITY_PROCESSING.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.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:
- Marek Potociar
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceGrizzlyConnectorProvider.AsyncClientCustomizerA customization SPI for the async client instance underlying Grizzly connectors.static interfaceGrizzlyConnectorProvider.RequestCustomizerA customization SPI for the async client request instances.
-
Constructor Summary
Constructors Constructor Description GrizzlyConnectorProvider()Create 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ConnectorgetConnector(jakarta.ws.rs.client.Client client, jakarta.ws.rs.core.Configuration config)static com.ning.http.client.AsyncHttpClientgetHttpClient(jakarta.ws.rs.core.Configurable<?> component)Retrieve the underlying GrizzlyAsyncHttpClientinstance fromJerseyClientorJerseyWebTargetconfigured to useGrizzlyConnectorProvider.static jakarta.ws.rs.client.Invocation.Builderregister(jakarta.ws.rs.client.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 Detail
-
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 Detail
-
getConnector
public Connector getConnector(jakarta.ws.rs.client.Client client, jakarta.ws.rs.core.Configuration config)
- Specified by:
getConnectorin interfaceConnectorProvider
-
getHttpClient
public static com.ning.http.client.AsyncHttpClient getHttpClient(jakarta.ws.rs.core.Configurable<?> component)
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 jakarta.ws.rs.client.Invocation.Builder register(jakarta.ws.rs.client.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.
-
-