public class JettyConnector extends Object implements Connector
Connector that utilizes the Jetty HTTP Client to send and receive
HTTP request and responses.
The following properties are only supported at construction of this class:
ClientProperties.ASYNC_THREADPOOL_SIZEClientProperties.CONNECT_TIMEOUTClientProperties.FOLLOW_REDIRECTSClientProperties.PROXY_URIClientProperties.PROXY_USERNAMEClientProperties.PROXY_PASSWORDClientProperties.PROXY_PASSWORDJettyClientProperties.DISABLE_COOKIESJettyClientProperties.ENABLE_SSL_HOSTNAME_VERIFICATIONJettyClientProperties.PREEMPTIVE_BASIC_AUTHENTICATIONJettyClientProperties.SYNC_LISTENER_RESPONSE_MAX_SIZE
ClientConfig config = new ClientConfig();
Connector connector = new JettyConnector(config);
config.connector(connector);
Client client = ClientBuilder.newClient(config);
// async request
WebTarget target = client.target("http://localhost:8080");
Future<Response> future = target.path("resource").request().async().get();
// wait for 3 seconds
Response response = future.get(3, TimeUnit.SECONDS);
String entity = response.readEntity(String.class);
client.close();
This connector supports only entity buffering.
Defining the property ClientProperties.REQUEST_ENTITY_PROCESSING has no effect on this connector.
| Modifier | Constructor and Description |
|---|---|
protected |
JettyConnector(Client jaxrsClient,
Configuration config)
Create the new Jetty client connector.
|
| Modifier and Type | Method and Description |
|---|---|
ClientResponse |
apply(ClientRequest jerseyRequest) |
Future<?> |
apply(ClientRequest jerseyRequest,
AsyncConnectorCallback callback) |
void |
close() |
CookieStore |
getCookieStore()
Get the
CookieStore. |
org.eclipse.jetty.client.HttpClient |
getHttpClient()
Get the
HttpClient. |
String |
getName() |
protected org.eclipse.jetty.client.HttpClient |
getRegisteredHttpClient(Configuration config)
provides custom registered
HttpClient if any (or NULL) |
protected org.eclipse.jetty.client.HttpClientTransport |
initClientTransport()
provides required HTTP client transport for client
the default transport is
HttpClientTransportOverHTTP |
protected JettyConnector(Client jaxrsClient, Configuration config)
jaxrsClient - JAX-RS client instance, for which the connector is created.config - client configuration.protected org.eclipse.jetty.client.HttpClientTransport initClientTransport()
HttpClientTransportOverHTTPHttpClientTransportprotected org.eclipse.jetty.client.HttpClient getRegisteredHttpClient(Configuration config)
HttpClient if any (or NULL)config - configuration where HttpClient could be registeredHttpClient instance if any was previously registered or NULLpublic org.eclipse.jetty.client.HttpClient getHttpClient()
HttpClient.HttpClient.public CookieStore getCookieStore()
CookieStore.CookieStore instance or null when
JettyClientProperties.DISABLE_COOKIES set to true.public ClientResponse apply(ClientRequest jerseyRequest) throws ProcessingException
apply in interface Connectorapply in interface Inflector<ClientRequest,ClientResponse>ProcessingExceptionpublic Future<?> apply(ClientRequest jerseyRequest, AsyncConnectorCallback callback)
Copyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.