org.xbill.DNS.spi
Class DNSJavaNameService

java.lang.Object
  extended byorg.xbill.DNS.spi.DNSJavaNameService
All Implemented Interfaces:
InvocationHandler

public class DNSJavaNameService
extends Object
implements InvocationHandler

This class implements a Name Service Provider, which Java can use (starting with version 1.4), to perform DNS resolutions instead of using the standard calls.

This Name Service Provider uses dnsjava.

To use this provider, you must set the following system property: sun.net.spi.nameservice.provider.1=dns,dnsjava

Author:
Brian Wellington, Paul Cowan ([email protected])

Constructor Summary
protected DNSJavaNameService()
          Creates a DNSJavaNameService instance.
 
Method Summary
 String getHostByAddr(byte[] addr)
          Performs a reverse DNS lookup.
 Object invoke(Object proxy, Method method, Object[] args)
           
 InetAddress[] lookupAllHostAddr(String host)
          Performs a forward DNS lookup for the host name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DNSJavaNameService

protected DNSJavaNameService()
Creates a DNSJavaNameService instance.

Uses the sun.net.spi.nameservice.nameservers, sun.net.spi.nameservice.domain, and java.net.preferIPv6Addresses properties for configuration.

Method Detail

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Specified by:
invoke in interface InvocationHandler
Throws:
Throwable

lookupAllHostAddr

public InetAddress[] lookupAllHostAddr(String host)
                                throws UnknownHostException
Performs a forward DNS lookup for the host name.

Parameters:
host - The host name to resolve.
Returns:
All the ip addresses found for the host name.
Throws:
UnknownHostException

getHostByAddr

public String getHostByAddr(byte[] addr)
                     throws UnknownHostException
Performs a reverse DNS lookup.

Parameters:
addr - The ip address to lookup.
Returns:
The host name found for the ip address.
Throws:
UnknownHostException


Copyright © 2011. All Rights Reserved.