Class JettyConnectorProvider
- java.lang.Object
-
- org.glassfish.jersey.jetty.connector.JettyConnectorProvider
-
- All Implemented Interfaces:
ConnectorProvider
public class JettyConnectorProvider extends java.lang.Object implements ConnectorProvider
AConnectorProviderfor Jerseyconnectorinstances that utilize the Jetty HTTP Client to send and receive HTTP request and responses.The following connector configuration properties are supported:
ClientProperties.ASYNC_THREADPOOL_SIZEClientProperties.CONNECT_TIMEOUTClientProperties.FOLLOW_REDIRECTSClientProperties.PROXY_URIClientProperties.PROXY_USERNAMEClientProperties.PROXY_PASSWORDClientProperties.PROXY_PASSWORDJettyClientProperties.PREEMPTIVE_BASIC_AUTHENTICATIONJettyClientProperties.DISABLE_COOKIES
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 propertyClientProperties.REQUEST_ENTITY_PROCESSINGhas no effect on Jetty HTTP Client-based connectors.- Since:
- 2.5
-
-
Constructor Summary
Constructors Constructor Description JettyConnectorProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ConnectorgetConnector(javax.ws.rs.client.Client client, javax.ws.rs.core.Configuration runtimeConfig)Get a Jersey client connector instance for a givenclientinstance and Jersey client runtimeconfiguration.static org.eclipse.jetty.client.HttpClientgetHttpClient(javax.ws.rs.core.Configurable<?> component)Retrieve the underlying JettyHttpClientinstance fromJerseyClientorJerseyWebTargetconfigured to useJettyConnectorProvider.
-
-
-
Method Detail
-
getConnector
public Connector getConnector(javax.ws.rs.client.Client client, javax.ws.rs.core.Configuration runtimeConfig)
Description copied from interface:ConnectorProviderGet a Jersey client connector instance for a givenclientinstance and Jersey client runtimeconfiguration.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 contextorhostname verifierare 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.
- Specified by:
getConnectorin interfaceConnectorProvider- Parameters:
client- Jersey client instance.runtimeConfig- Jersey client runtime configuration.- Returns:
- configured
Connectorinstance to be used by the client.
-
getHttpClient
public static org.eclipse.jetty.client.HttpClient getHttpClient(javax.ws.rs.core.Configurable<?> component)
Retrieve the underlying JettyHttpClientinstance fromJerseyClientorJerseyWebTargetconfigured to useJettyConnectorProvider.- Parameters:
component-JerseyClientorJerseyWebTargetinstance that is configured to useJettyConnectorProvider.- Returns:
- underlying Jetty
HttpClientinstance. - Throws:
java.lang.IllegalArgumentException- in case thecomponentis neitherJerseyClientnorJerseyWebTargetinstance or in case the component is not configured to use aJettyConnectorProvider.- Since:
- 2.8
-
-