Top Description Methods
org.eclipse.jetty.client

public Interface Destination

Known Direct Implementers
org.eclipse.jetty.client.transport.HttpDestination
Imports
java.util.concurrent.CompletableFuture, org.eclipse.jetty.util.FuturePromise, .Promise

A Destination represents the receiver of HTTP requests, and it is identified by an Origin.

Destination holds a pool of Connections, but allows to create unpooled connections if the application wants full control over connection management via newConnection(Promise).

Destinations may be obtained via HttpClient#resolveDestination(Request).

Method Summary

Modifier and TypeMethod and Description
public ConnectionPool
getConnectionPool()

Returns: the connection pool associated with this destination

public HttpClient
getHttpClient()

Returns: the HttpClient that manages this destination

public Origin
getOrigin()

Returns: the origin of this destination

public ProxyConfiguration.Proxy
getProxy()

Returns: the proxy associated with this destination, or null if there is no proxy

public boolean
isSecure()

Returns: whether the communication with the destination is secure

public void
newConnection(Promise<Connection>
the promise of a new, unpooled, Connection
promise
)

Creates asynchronously a new, unpooled, Connection that will be returned at a later time through the given Promise.

public default CompletableFuture<Connection>

Returns:

a CompletableFuture for a new, unpooled, Connection
newConnection
()

Creates asynchronously a new, unpooled, Connection that will be returned at a later time through the given Promise.

public void
send(Request
the request to send to this destination
request
,
Response.CompleteListener
the listener that receives response events
listener
)

Sends the given request to this destination.

Method Detail

getConnectionPoolback to summary
public ConnectionPool getConnectionPool()
Returns:ConnectionPool

the connection pool associated with this destination

getHttpClientback to summary
public HttpClient getHttpClient()
Returns:HttpClient

the HttpClient that manages this destination

getOriginback to summary
public Origin getOrigin()
Returns:Origin

the origin of this destination

getProxyback to summary
public ProxyConfiguration.Proxy getProxy()
Returns:ProxyConfiguration.Proxy

the proxy associated with this destination, or null if there is no proxy

isSecureback to summary
public boolean isSecure()
Returns:boolean

whether the communication with the destination is secure

newConnectionback to summary
public void newConnection(Promise<Connection> promise)

Creates asynchronously a new, unpooled, Connection that will be returned at a later time through the given Promise.

Use FuturePromise to wait for the connection:

Destination destination = ...;
FuturePromise<Connection> futureConnection = new FuturePromise<>();
destination.newConnection(futureConnection);
Connection connection = futureConnection.get(5, TimeUnit.SECONDS);
Parameters
promise:Promise<Connection>

the promise of a new, unpooled, Connection

newConnectionback to summary
public default CompletableFuture<Connection> newConnection()

Creates asynchronously a new, unpooled, Connection that will be returned at a later time through the given Promise.

Returns:CompletableFuture<Connection>

a CompletableFuture for a new, unpooled, Connection

sendback to summary
public void send(Request request, Response.CompleteListener listener)

Sends the given request to this destination.

You can use this method to send the request to a specific destination that may be different from the request authority.

For example when HttpClient is used in a proxy, it may receive a request with authority yourserver.com but the proxy logic may want to forward the request to a specific backend server, say backend01, therefore:

// Resolve the backend destination.
Origin backendOrigin = new Origin(backendScheme, "backend01", backendPort);
Destination backendDestination = httpClient.resolveDestination(backendOrigin);

// Create a request with the original authority.
Request request = httpClient.newRequest("https://yourserver.com/path");

// Send the request to the specific backend.
backendDestination.send(request, result -> { ... });
Parameters
request:Request

the request to send to this destination

listener:Response.CompleteListener

the listener that receives response events