Class SocketAddressResolver.Async

java.lang.Object
org.eclipse.jetty.util.SocketAddressResolver.Async
All Implemented Interfaces:
SocketAddressResolver
Enclosing interface:
SocketAddressResolver

@ManagedObject("The asynchronous address resolver") public static class SocketAddressResolver.Async extends Object implements SocketAddressResolver

Creates InetSocketAddress instances asynchronously in a different thread.

InetSocketAddress(String, int) attempts to perform a DNS resolution of the host name, and this may block for several seconds. This class creates the InetSocketAddress in a separate thread and provides the result through a Promise, with the possibility to specify a timeout for the operation.

Example usage:

 SocketAddressResolver resolver = new SocketAddressResolver.Async(executor, scheduler, timeout);
 resolver.resolve("www.google.com", 80, new Promise<SocketAddress>()
 {
     public void succeeded(SocketAddress result)
     {
         // The address was resolved
     }

     public void failed(Throwable failure)
     {
         // The address resolution failed
     }
 });