com.buzzsurf.dns
Class DNSJavaNameService

java.lang.Object
  |
  +--com.buzzsurf.dns.DNSJavaNameService
All Implemented Interfaces:
sun.net.spi.nameservice.NameService

public class DNSJavaNameService
extends java.lang.Object
implements sun.net.spi.nameservice.NameService

This class implements a Name Service Provider, which Java can use (starting with version 1.4), to perform DNS resolutions instead of using standard native calls. Doing your own name resolutions was possible before Java 1.4, but it required custom code, and you couldn't use it in the URLConnection classes because they provide no access to the underlying socket.
This Name Service Provider uses the dnsjava package (http://www.xbill.org/dnsjava).

Important: To use this service, you must set the following system property:

The following system properties are optional and effect performance of the dns resolver:

Version:
0.9
Author:
Paul Cowan (pwc21@yahoo.com)

Field Summary
protected  org.xbill.DNS.ExtendedResolver resolver
           
 
Constructor Summary
protected DNSJavaNameService()
          Constructor for DNSJavaNameService.
 
Method Summary
 java.lang.String getHostByAddr(byte[] ip)
          Finds PTR records (reverse dns lookups) for the ip address
 byte[][] lookupAllHostAddr(java.lang.String name)
          Finds A records (ip addresses) for the host name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resolver

protected org.xbill.DNS.ExtendedResolver resolver
Constructor Detail

DNSJavaNameService

protected DNSJavaNameService()
                      throws java.net.UnknownHostException
Constructor for DNSJavaNameService. Reads all available property and initializes dnsjava.

This should throw an UnknownHostException if it is not able to find your name servers.

Method Detail

lookupAllHostAddr

public byte[][] lookupAllHostAddr(java.lang.String name)
                           throws java.net.UnknownHostException
Finds A records (ip addresses) for the host name.

Specified by:
lookupAllHostAddr in interface sun.net.spi.nameservice.NameService
Returns:
All the ip addresses found for the host name.
java.net.UnknownHostException

getHostByAddr

public java.lang.String getHostByAddr(byte[] ip)
                               throws java.net.UnknownHostException
Finds PTR records (reverse dns lookups) for the ip address

Specified by:
getHostByAddr in interface sun.net.spi.nameservice.NameService
Returns:
The host name found for the ip address.
java.net.UnknownHostException