public class InMemoryDnsResolver extends Object implements DnsResolver
DnsResolver
implementation.Modifier and Type | Field and Description |
---|---|
private Map<String,InetAddress[]> |
dnsMap
In-memory collection that will hold the associations between a host name
and an array of InetAddress instances.
|
private org.apache.commons.logging.Log |
log
Logger associated to this class.
|
Constructor and Description |
---|
InMemoryDnsResolver()
Builds a DNS resolver that will resolve the host names against a
collection held in-memory.
|
Modifier and Type | Method and Description |
---|---|
void |
add(String host,
InetAddress... ips)
Associates the given array of IP addresses to the given host in this DNS overrider.
|
InetAddress[] |
resolve(String host)
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.
|
private final org.apache.commons.logging.Log log
private final Map<String,InetAddress[]> dnsMap
public InMemoryDnsResolver()
public void add(String host, InetAddress... ips)
host
- The host name to be associated with the given IP.ips
- array of IP addresses to be resolved by this DNS overrider to the given
host name.public InetAddress[] resolve(String host) throws UnknownHostException
resolve
in interface DnsResolver
host
- The host name to be resolved by this resolver.UnknownHostException
InetAddress
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses