org.apache.james.protocols.smtp
Interface DNSService


public interface DNSService

Provides abstraction for DNS resolutions. The interface is Mail specific. It may be a good idea to make the interface more generic or expose commonly needed DNS methods.


Field Summary
static String ROLE
          The component role used by components implementing this service
 
Method Summary
 Collection<String> findMXRecords(String hostname)
          Return a prioritized unmodifiable list of host handling mail for the domain.
 Collection<String> findTXTRecords(String hostname)
          Get a collection of DNS TXT Records
 InetAddress[] getAllByName(String host)
           
 InetAddress getByName(String host)
           
 String getHostName(InetAddress addr)
          Determines the hostname for an address
 InetAddress getLocalHost()
          get the local hosts InetAddress
 Iterator<org.apache.mailet.HostAddress> getSMTPHostAddresses(String domainName)
          Returns an Iterator over org.apache.mailet.HostAddress, a specialized subclass of javax.mail.URLName, which provides location information for servers that are specified as mail handlers for the given hostname.
 

Field Detail

ROLE

static final String ROLE
The component role used by components implementing this service

See Also:
Constant Field Values
Method Detail

findMXRecords

Collection<String> findMXRecords(String hostname)
                                 throws TemporaryResolutionException

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
Throws:
TemporaryResolutionException - get thrown on temporary problems

findTXTRecords

Collection<String> findTXTRecords(String hostname)
Get a collection of DNS TXT Records

Parameters:
hostname - The hostname to check
Returns:
collection of strings representing TXT record values

getSMTPHostAddresses

Iterator<org.apache.mailet.HostAddress> getSMTPHostAddresses(String domainName)
                                                             throws TemporaryResolutionException
Returns an Iterator over org.apache.mailet.HostAddress, a specialized subclass of javax.mail.URLName, which provides location information for servers that are specified as mail handlers for the given hostname. This is done using MX records, and the HostAddress instances are returned sorted by MX priority. If no host is found for domainName, the Iterator returned will be empty and the first call to hasNext() will return false. The Iterator is a nested iterator: the outer iteration is over the results of the MX record lookup, and the inner iteration is over potentially multiple A records for each MX record. DNS lookups are deferred until actually needed.

Parameters:
domainName - - the domain for which to find mail servers
Returns:
an Iterator over HostAddress instances, sorted by priority
Throws:
TemporaryResolutionException - get thrown on temporary problems
Since:
v2.2.0a16-unstable

getAllByName

InetAddress[] getAllByName(String host)
                           throws UnknownHostException
Throws:
UnknownHostException
See Also:
InetAddress.getAllByName(String)

getByName

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

getHostName

String getHostName(InetAddress addr)
Determines the hostname for an address

Parameters:
addr - the address record
Returns:
the hostname defined in the address record

getLocalHost

InetAddress getLocalHost()
                         throws UnknownHostException
get the local hosts InetAddress

Returns:
the localhosts inet address
Throws:
UnknownHostException


Copyright © 2010-2011 The Apache Software Foundation. All Rights Reserved.