org.apache.james.dnsserver
Class DNSServer

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.james.dnsserver.DNSServer
All Implemented Interfaces:
org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.logger.LogEnabled, DNSServerMBean, DNSServer

public class DNSServer
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements org.apache.avalon.framework.configuration.Configurable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.activity.Disposable, DNSServer, DNSServerMBean

Provides DNS client functionality to services running inside James


Field Summary
protected  org.xbill.DNS.Resolver resolver
          A resolver instance used to retrieve DNS records.
 
Fields inherited from interface org.apache.james.services.DNSServer
ROLE
 
Constructor Summary
DNSServer()
           
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration configuration)
           
 void dispose()
          The dispose operation is called at the end of a components lifecycle.
 java.util.Collection findMXRecords(java.lang.String hostname)
          Return a prioritized unmodifiable list of host handling mail for the domain.
 java.util.List findMXRecordsRaw(java.lang.String hostname)
          Return a prioritized unmodifiable list of MX records obtained from the server.
static java.net.InetAddress[] getAllByName(java.lang.String host)
           
static java.net.InetAddress getByName(java.lang.String host)
           
 java.lang.String[] getDNSServers()
          Return the list of DNS servers in use by this service
 java.util.Iterator getSMTPHostAddresses(java.lang.String domainName)
          Performs DNS lookups as needed to find servers which should or might support SMTP.
 void initialize()
           
 org.xbill.DNS.Record[] lookup(java.lang.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)
           
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
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. This is a reference to a third party library object.

Constructor Detail

DNSServer

public DNSServer()
Method Detail

configure

public void configure(org.apache.avalon.framework.configuration.Configuration configuration)
               throws org.apache.avalon.framework.configuration.ConfigurationException
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable
Throws:
org.apache.avalon.framework.configuration.ConfigurationException
See Also:
Configurable.configure(Configuration)

initialize

public void initialize()
                throws java.lang.Exception
Specified by:
initialize in interface org.apache.avalon.framework.activity.Initializable
Throws:
java.lang.Exception
See Also:
Initializable.initialize()

getDNSServers

public java.lang.String[] getDNSServers()

Return the list of DNS servers in use by this service

Specified by:
getDNSServers in interface DNSServerMBean
Returns:
an array of DNS server names

findMXRecordsRaw

public java.util.List findMXRecordsRaw(java.lang.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 java.util.Collection findMXRecords(java.lang.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

Specified by:
findMXRecords in interface DNSServer
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(java.lang.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)

getSMTPHostAddresses

public java.util.Iterator getSMTPHostAddresses(java.lang.String domainName)
Description copied from interface: DNSServer
Performs DNS lookups as needed to find servers which should or might support SMTP. Returns one SMTPHostAddresses for each such host discovered by DNS. If no host is found for domainName, the Iterator returned will be empty and the first call to hasNext() will return false.

Specified by:
getSMTPHostAddresses in interface DNSServer
Parameters:
domainName - the String domain for which SMTP host addresses are sought.
Returns:
an Enumeration in which the Objects returned by next() are instances of SMTPHostAddresses.

getByName

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

getAllByName

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

dispose

public void dispose()
The dispose operation is called at the end of a components lifecycle. Instances of this class use this method to release and destroy any resources that they own. This implementation no longer shuts down org.xbill.DNS.Cache because dnsjava 2.0.0 removed the need for a cleaner thread!

Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable
Throws:
java.lang.Exception - if an error is encountered during shutdown


Copyright ? 2002-2009 The Apache Software Foundation. All Rights Reserved.