Package io.dropwizard.client
Class DropwizardApacheConnector
java.lang.Object
io.dropwizard.client.DropwizardApacheConnector
- All Implemented Interfaces:
org.glassfish.jersey.client.spi.Connector,org.glassfish.jersey.process.Inflector<org.glassfish.jersey.client.ClientRequest,org.glassfish.jersey.client.ClientResponse>
public class DropwizardApacheConnector
extends Object
implements org.glassfish.jersey.client.spi.Connector
Dropwizard Apache Connector.
It's a custom version of Jersey's Connector
that uses Apache's HttpClient
as an HTTP transport implementation.
It uses a pre-configured HTTP client by HttpClientBuilder
rather then creates a client from the Jersey configuration.
This approach affords to use the extended configuration of the Apache HttpClient in Dropwizard with a fluent interface of JerseyClient.
-
Constructor Summary
ConstructorsConstructorDescriptionDropwizardApacheConnector(org.apache.hc.client5.http.impl.classic.CloseableHttpClient client, @Nullable org.apache.hc.client5.http.config.RequestConfig defaultRequestConfig, boolean chunkedEncodingEnabled) -
Method Summary
Modifier and TypeMethodDescriptionorg.glassfish.jersey.client.ClientResponseapply(org.glassfish.jersey.client.ClientRequest jerseyRequest) Future<?>apply(org.glassfish.jersey.client.ClientRequest request, org.glassfish.jersey.client.spi.AsyncConnectorCallback callback) voidclose()protected @Nullable org.apache.hc.core5.http.HttpEntitygetHttpEntity(org.glassfish.jersey.client.ClientRequest jerseyRequest) Get an Apache'sHttpEntityfrom Jersey'sClientRequestgetName()
-
Constructor Details
-
DropwizardApacheConnector
public DropwizardApacheConnector(org.apache.hc.client5.http.impl.classic.CloseableHttpClient client, @Nullable org.apache.hc.client5.http.config.RequestConfig defaultRequestConfig, boolean chunkedEncodingEnabled)
-
-
Method Details
-
apply
public org.glassfish.jersey.client.ClientResponse apply(org.glassfish.jersey.client.ClientRequest jerseyRequest) - Specified by:
applyin interfaceorg.glassfish.jersey.client.spi.Connector- Specified by:
applyin interfaceorg.glassfish.jersey.process.Inflector<org.glassfish.jersey.client.ClientRequest,org.glassfish.jersey.client.ClientResponse>
-
getHttpEntity
protected @Nullable org.apache.hc.core5.http.HttpEntity getHttpEntity(org.glassfish.jersey.client.ClientRequest jerseyRequest) Get an Apache'sHttpEntityfrom Jersey'sClientRequestCreate a custom HTTP entity, because Jersey doesn't provide a request stream or a byte buffer.
- Parameters:
jerseyRequest- representation of an HTTP request in Jersey- Returns:
- a correct
HttpEntityimplementation
-
apply
public Future<?> apply(org.glassfish.jersey.client.ClientRequest request, org.glassfish.jersey.client.spi.AsyncConnectorCallback callback) - Specified by:
applyin interfaceorg.glassfish.jersey.client.spi.Connector
-
getName
- Specified by:
getNamein interfaceorg.glassfish.jersey.client.spi.Connector
-
close
public void close()- Specified by:
closein interfaceorg.glassfish.jersey.client.spi.Connector
-