Class JettyConnector
- java.lang.Object
-
- org.glassfish.jersey.jetty.connector.JettyConnector
-
- All Implemented Interfaces:
Connector,Inflector<ClientRequest,ClientResponse>
public class JettyConnector extends Object implements Connector
AConnectorthat 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 Jetty11Connector(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 propertyClientProperties.REQUEST_ENTITY_PROCESSINGhas no effect on this connector.- Author:
- Arul Dhesiaseelan (aruld at acm.org), Marek Potociar
-
-
Constructor Summary
Constructors Constructor Description JettyConnector(Client jaxrsClient, Configuration config)Create the new Jetty client connector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ClientResponseapply(ClientRequest jerseyRequest)Future<?>apply(ClientRequest jerseyRequest, AsyncConnectorCallback callback)voidclose()CookieStoregetCookieStore()Get theCookieStore.org.eclipse.jetty.client.HttpClientgetHttpClient()Get theHttpClient.StringgetName()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 Detail
-
JettyConnector
public JettyConnector(Client jaxrsClient, Configuration config)
Create the new Jetty client connector.- Parameters:
jaxrsClient- JAX-RS client instance, for which the connector is created.config- client configuration.
-
-
Method Detail
-
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
protected org.eclipse.jetty.client.HttpClient getRegisteredHttpClient(Configuration config)
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 CookieStore getCookieStore()
Get theCookieStore.- Returns:
- the
CookieStoreinstance or null when Jetty11ClientProperties.DISABLE_COOKIES set to true.
-
apply
public ClientResponse apply(ClientRequest jerseyRequest) throws ProcessingException
- Specified by:
applyin interfaceConnector- Specified by:
applyin interfaceInflector<ClientRequest,ClientResponse>- Throws:
ProcessingException
-
apply
public Future<?> apply(ClientRequest jerseyRequest, AsyncConnectorCallback callback)
-
-