1 // 2 // ======================================================================== 3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. 4 // ------------------------------------------------------------------------ 5 // All rights reserved. This program and the accompanying materials 6 // are made available under the terms of the Eclipse Public License v1.0 7 // and Apache License v2.0 which accompanies this distribution. 8 // 9 // The Eclipse Public License is available at 10 // http://www.eclipse.org/legal/epl-v10.html 11 // 12 // The Apache License v2.0 is available at 13 // http://www.opensource.org/licenses/apache2.0.php 14 // 15 // You may elect to redistribute this code under either of these licenses. 16 // ======================================================================== 17 // 18 19 package org.eclipse.jetty.client.api; 20 21 import org.eclipse.jetty.util.Promise; 22 23 /** 24 * {@link Destination} represents the triple made of the {@link #getScheme}, the {@link #getHost} 25 * and the {@link #getPort}. 26 * <p /> 27 * {@link Destination} holds a pool of {@link Connection}s, but allows to create unpooled 28 * connections if the application wants full control over connection management via {@link #newConnection(Promise)}. 29 * <p /> 30 * {@link Destination}s may be obtained via {@link HttpClient#getDestination(String, String, int)} 31 */ 32 public interface Destination 33 { 34 /** 35 * @return the scheme of this destination, such as "http" or "https" 36 */ 37 String getScheme(); 38 39 /** 40 * @return the host of this destination, such as "127.0.0.1" or "google.com" 41 */ 42 String getHost(); 43 44 /** 45 * @return the port of this destination such as 80 or 443 46 */ 47 int getPort(); 48 49 /** 50 * Creates asynchronously a new, unpooled, {@link Connection} that will be returned 51 * at a later time through the given {@link Promise}. 52 * <p /> 53 * Use {@link FuturePromise} to wait for the connection: 54 * <pre> 55 * Destination destination = ...; 56 * FuturePromise<Connection> futureConnection = new FuturePromise<>(); 57 * destination.newConnection(futureConnection); 58 * Connection connection = futureConnection.get(5, TimeUnit.SECONDS); 59 * </pre> 60 * 61 * @param promise the promise of a new, unpooled, {@link Connection} 62 */ 63 void newConnection(Promise<Connection> promise); 64 }