org.glassfish.jersey.jetty.connector
Class JettyConnector

java.lang.Object
  extended by org.glassfish.jersey.jetty.connector.JettyConnector
All Implemented Interfaces:
Connector, Inflector<ClientRequest,ClientResponse>

public class JettyConnector
extends Object
implements Connector

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:

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();
 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 (marek.potociar at oracle.com)

Method Summary
 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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getHttpClient

public org.eclipse.jetty.client.HttpClient getHttpClient()
Get the HttpClient.

Returns:
the HttpClient.

getCookieStore

public CookieStore getCookieStore()
Get the CookieStore.

Returns:
the CookieStore instance or null when JettyClientProperties.DISABLE_COOKIES set to true.

apply

public ClientResponse apply(ClientRequest jerseyRequest)
                     throws javax.ws.rs.ProcessingException
Specified by:
apply in interface Connector
Specified by:
apply in interface Inflector<ClientRequest,ClientResponse>
Throws:
javax.ws.rs.ProcessingException

apply

public Future<?> apply(ClientRequest jerseyRequest,
                       AsyncConnectorCallback callback)
Specified by:
apply in interface Connector

getName

public String getName()
Specified by:
getName in interface Connector

close

public void close()
Specified by:
close in interface Connector


Copyright © 2007-2013, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.