Class JettyConnector
java.lang.Object
org.glassfish.jersey.jetty.connector.JettyConnector
- All Implemented Interfaces:
Connector,Inflector<ClientRequest,ClientResponse>
A
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_COOKIES*
JettyClientProperties.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.
- Author:
- Arul Dhesiaseelan (aruld at acm.org), Marek Potociar
-
Constructor Summary
ConstructorsConstructorDescriptionJettyConnector(Client jaxrsClient, Configuration config) Create the new Jetty client connector. -
Method Summary
Modifier and TypeMethodDescriptionapply(ClientRequest jerseyRequest) Future<?>apply(ClientRequest jerseyRequest, AsyncConnectorCallback callback) voidclose()org.eclipse.jetty.http.HttpCookieStoreGet theCookieStore.org.eclipse.jetty.client.HttpClientGet theHttpClient.getName()protected org.eclipse.jetty.client.HttpClientgetRegisteredHttpClient(Configuration config) provides custom registeredHttpClientif any (or NULL)protected org.eclipse.jetty.client.HttpClientTransportinitClientTransport(org.eclipse.jetty.io.ClientConnector clientConnector) provides required HTTP client transport for client the default transport isHttpClientTransportOverHTTP
-
Constructor Details
-
JettyConnector
Create the new Jetty client connector.- Parameters:
jaxrsClient- JAX-RS client instance, for which the connector is created.config- client configuration.
-
-
Method Details
-
initClientTransport
protected org.eclipse.jetty.client.HttpClientTransport initClientTransport(org.eclipse.jetty.io.ClientConnector clientConnector) provides required HTTP client transport for client the default transport isHttpClientTransportOverHTTP- Returns:
- instance of
HttpClientTransport - Since:
- 2.41
-
getRegisteredHttpClient
provides custom registeredHttpClientif any (or NULL)- Parameters:
config- configuration whereHttpClientcould be registered- Returns:
HttpClientinstance if any was previously registered or NULL- Since:
- 2.41
-
getHttpClient
public org.eclipse.jetty.client.HttpClient getHttpClient()Get theHttpClient.- Returns:
- the
HttpClient.
-
getCookieStore
public org.eclipse.jetty.http.HttpCookieStore getCookieStore()Get theCookieStore.- Returns:
- the
CookieStoreinstance or null when JettyClientProperties.DISABLE_COOKIES set to true.
-
apply
- Specified by:
applyin interfaceConnector- Specified by:
applyin interfaceInflector<ClientRequest,ClientResponse> - Throws:
ProcessingException
-
apply
-
getName
-
close
public void close()
-