public class JettyConnectorProvider extends Object implements ConnectorProvider
ConnectorProvider
for Jersey connector
instances that utilize the Jetty HTTP Client to send and receive
HTTP request and responses.
The following connector configuration properties are supported:
ClientProperties.ASYNC_THREADPOOL_SIZE
ClientProperties.CONNECT_TIMEOUT
ClientProperties.FOLLOW_REDIRECTS
ClientProperties.PROXY_URI
ClientProperties.PROXY_USERNAME
ClientProperties.PROXY_PASSWORD
ClientProperties.PROXY_PASSWORD
JettyClientProperties.DISABLE_COOKIES
JettyClientProperties.ENABLE_SSL_HOSTNAME_VERIFICATION
JettyClientProperties.PREEMPTIVE_BASIC_AUTHENTICATION
JettyClientProperties.SYNC_LISTENER_RESPONSE_MAX_SIZE
This transport supports both synchronous and asynchronous processing of client requests. The following methods are supported: GET, POST, PUT, DELETE, HEAD, OPTIONS, TRACE, CONNECT and MOVE.
Typical usage:
ClientConfig config = new ClientConfig();
config.connectorProvider(new JettyConnectorProvider());
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();
Connector instances created via Jetty HTTP Client-based connector provider support only
entity buffering
.
Defining the property ClientProperties.REQUEST_ENTITY_PROCESSING
has no
effect on Jetty HTTP Client-based connectors.
Constructor and Description |
---|
JettyConnectorProvider() |
Modifier and Type | Method and Description |
---|---|
Connector |
getConnector(Client client,
Configuration runtimeConfig)
Get a Jersey client connector instance for a given
client instance
and Jersey client runtime configuration . |
static org.eclipse.jetty.client.HttpClient |
getHttpClient(Configurable<?> component)
Retrieve the underlying Jetty
HttpClient instance from
JerseyClient or JerseyWebTarget
configured to use JettyConnectorProvider . |
public Connector getConnector(Client client, Configuration runtimeConfig)
ConnectorProvider
client
instance
and Jersey client runtime configuration
.
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 context
or hostname verifier
are 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.
getConnector
in interface ConnectorProvider
client
- Jersey client instance.runtimeConfig
- Jersey client runtime configuration.Connector
instance to be used by the client.public static org.eclipse.jetty.client.HttpClient getHttpClient(Configurable<?> component)
HttpClient
instance from
JerseyClient
or JerseyWebTarget
configured to use JettyConnectorProvider
.component
- JerseyClient
or JerseyWebTarget
instance that is configured to use
JettyConnectorProvider
.HttpClient
instance.IllegalArgumentException
- in case the component
is neither JerseyClient
nor JerseyWebTarget
instance or in case the component
is not configured to use a JettyConnectorProvider
.Copyright © 2007-2024, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.