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'sHttpClient
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
Constructors Constructor Description DropwizardApacheConnector(org.apache.hc.client5.http.impl.classic.CloseableHttpClient client, @Nullable org.apache.hc.client5.http.config.RequestConfig defaultRequestConfig, boolean chunkedEncodingEnabled)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.glassfish.jersey.client.ClientResponse
apply(org.glassfish.jersey.client.ClientRequest jerseyRequest)
Future<?>
apply(org.glassfish.jersey.client.ClientRequest request, org.glassfish.jersey.client.spi.AsyncConnectorCallback callback)
void
close()
protected @Nullable org.apache.hc.core5.http.HttpEntity
getHttpEntity(org.glassfish.jersey.client.ClientRequest jerseyRequest)
Get an Apache'sHttpEntity
from Jersey'sClientRequest
String
getName()
-
-
-
Method Detail
-
apply
public org.glassfish.jersey.client.ClientResponse apply(org.glassfish.jersey.client.ClientRequest jerseyRequest)
- Specified by:
apply
in interfaceorg.glassfish.jersey.client.spi.Connector
- Specified by:
apply
in 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'sHttpEntity
from Jersey'sClientRequest
Create 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
HttpEntity
implementation
-
apply
public Future<?> apply(org.glassfish.jersey.client.ClientRequest request, org.glassfish.jersey.client.spi.AsyncConnectorCallback callback)
- Specified by:
apply
in interfaceorg.glassfish.jersey.client.spi.Connector
-
getName
public String getName()
- Specified by:
getName
in interfaceorg.glassfish.jersey.client.spi.Connector
-
close
public void close()
- Specified by:
close
in interfaceorg.glassfish.jersey.client.spi.Connector
-
-