com.hs.mail.dns
Class DnsServer

java.lang.Object
  extended by com.hs.mail.dns.DnsServer
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean

public class DnsServer
extends Object
implements org.springframework.beans.factory.InitializingBean

Provides DNS client functionality.


Field Summary
protected  org.xbill.DNS.Resolver resolver
          A resolver instance used to retrieve DNS records.
 
Constructor Summary
DnsServer()
           
 
Method Summary
 void afterPropertiesSet()
           
 Collection<String> findMXRecords(String hostname)
           Return a prioritized unmodifiable list of host handling mail for the domain.
 List<String> findMXRecordsRaw(String hostname)
           Return a prioritized unmodifiable list of MX records obtained from the server.
static InetAddress[] getAllByName(String host)
           
static InetAddress getByName(String host)
           
 String[] getDnsServers()
           
 Iterator<HostAddress> getSmtpHostAddress(String domainName)
           
 org.xbill.DNS.Record[] lookup(String name, int type)
          Looks up DNS records of the specified type for the specified name.
protected  org.xbill.DNS.Record[] processSetResponse(org.xbill.DNS.SetResponse sr)
           
 void setDnsServers(List<String> dnsServers)
           
 
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.Resolver resolver
A resolver instance used to retrieve DNS records.

Constructor Detail

DnsServer

public DnsServer()
Method Detail

getDnsServers

public String[] getDnsServers()

setDnsServers

public void setDnsServers(List<String> dnsServers)

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
Exception

findMXRecordsRaw

public List<String> findMXRecordsRaw(String hostname)

Return a prioritized unmodifiable list of MX records obtained from the server.

Parameters:
hostname - domain name to look up
Returns:
a list of MX records corresponding to this mail domain

findMXRecords

public Collection<String> findMXRecords(String hostname)

Return a prioritized unmodifiable list of host handling mail for the domain.

First lookup MX hosts, then MX hosts of the CNAME adress, and if no server is found return the IP of the hostname

Parameters:
hostname - domain name to look up
Returns:
a unmodifiable list of handling servers corresponding to this mail domain name

lookup

public org.xbill.DNS.Record[] lookup(String name,
                                     int type)
Looks up DNS records of the specified type for the specified name. This method is a public wrapper for the private implementation method

Parameters:
name - the name of the host to be looked up
type - the type of record desired

processSetResponse

protected org.xbill.DNS.Record[] processSetResponse(org.xbill.DNS.SetResponse sr)

getSmtpHostAddress

public Iterator<HostAddress> getSmtpHostAddress(String domainName)

getByName

public static InetAddress getByName(String host)
                             throws UnknownHostException
Throws:
UnknownHostException
See Also:
InetAddress.getByName(String)

getAllByName

public static InetAddress[] getAllByName(String host)
                                  throws UnknownHostException
Throws:
UnknownHostException
See Also:
java.net.InetAddress#getByAllName(String)


Copyright © 2011. All Rights Reserved.