Top Description Fields Constructors Methods
org.apache.http.impl.conn

public Class InMemoryDnsResolver

extends Object
implements DnsResolver
Class Inheritance
All Implemented Interfaces
org.apache.http.conn.DnsResolver
Imports
java.net.InetAddress, .UnknownHostException, java.util.Arrays, .Map, java.util.concurrent.ConcurrentHashMap, org.apache.commons.logging.Log, .LogFactory, org.apache.http.conn.DnsResolver, org.apache.http.util.Args

In-memory DnsResolver implementation.
Since
4.2

Field Summary

Modifier and TypeField and Description
private final Map<String, InetAddress[]>
dnsMap

In-memory collection that will hold the associations between a host name and an array of InetAddress instances.

private final Log
log

Logger associated to this class.

Constructor Summary

AccessConstructor and Description
public
InMemoryDnsResolver()

Builds a DNS resolver that will resolve the host names against a collection held in-memory.

Method Summary

Modifier and TypeMethod and Description
public void
add(final String
The host name to be associated with the given IP.
host
,
final InetAddress...
array of IP addresses to be resolved by this DNS overrider to the given host name.
ips
)

Associates the given array of IP addresses to the given host in this DNS overrider.

public InetAddress[]
resolve(final String
The host name to be resolved by this resolver.
host
)

Implements org.apache.http.conn.DnsResolver.resolve.

Returns the IP address for the specified host name, or null if the given host is not recognized or the associated IP address cannot be used to build an InetAddress instance.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dnsMapback to summary
private final Map<String, InetAddress[]> dnsMap

In-memory collection that will hold the associations between a host name and an array of InetAddress instances.

logback to summary
private final Log log

Logger associated to this class.

Constructor Detail

InMemoryDnsResolverback to summary
public InMemoryDnsResolver()

Builds a DNS resolver that will resolve the host names against a collection held in-memory.

Method Detail

addback to summary
public void add(final String host, final InetAddress... ips)

Associates the given array of IP addresses to the given host in this DNS overrider. The IP addresses are assumed to be already resolved.

Parameters
host:String

The host name to be associated with the given IP.

ips:InetAddress[]

array of IP addresses to be resolved by this DNS overrider to the given host name.

resolveback to summary
public InetAddress[] resolve(final String host) throws UnknownHostException

Implements org.apache.http.conn.DnsResolver.resolve.

Doc from org.apache.http.conn.DnsResolver.resolve.

Returns the IP address for the specified host name, or null if the given host is not recognized or the associated IP address cannot be used to build an InetAddress instance.

Parameters
host:String

The host name to be resolved by this resolver.

Returns:InetAddress[]

The IP address associated to the given host name, or null if the host name is not known by the implementation class.

Annotations
@Override