public class DNSJavaService extends Object implements DNSService, DNSServiceMBean, LogEnabled, Configurable
Modifier and Type | Field and Description |
---|---|
protected org.xbill.DNS.Cache |
cache
A TTL cache of results received from the DNS server.
|
protected org.xbill.DNS.Resolver |
resolver
A resolver instance used to retrieve DNS records.
|
Constructor and Description |
---|
DNSJavaService() |
Modifier and Type | Method and Description |
---|---|
void |
clearCache()
Clear the cache of the service
|
void |
configure(org.apache.commons.configuration.HierarchicalConfiguration configuration)
Configure the object.
|
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)
Resolve the given hostname to an array of InetAddress based on the DNS
Server.
|
InetAddress |
getByName(String host)
Resolve the given hostname to an InetAddress based on the DNS Server.
|
int |
getCurrentCacheSize()
Return the current size of the cache
|
String[] |
getDNSServers()
Return the list of DNS servers in use by this service
|
String |
getHostName(InetAddress addr)
Resolve the given InetAddress to an host name based on the DNS Server.
|
InetAddress |
getLocalHost()
Resolve the local hostname of the machine and returns it.
|
int |
getMaximumCacheSize()
Return the maximum cache size
|
org.xbill.DNS.Name[] |
getSearchPaths()
Return the list of DNS servers in use by this service
|
void |
init() |
protected org.xbill.DNS.Record[] |
lookup(String namestr,
int type,
String typeDesc)
Looks up DNS records of the specified type for the specified name.
|
protected org.xbill.DNS.Record[] |
lookupNoException(String namestr,
int type,
String typeDesc) |
void |
setLog(org.slf4j.Logger logger)
Sets the service log.
|
protected org.xbill.DNS.Resolver resolver
protected org.xbill.DNS.Cache cache
public void setLog(org.slf4j.Logger logger)
LogEnabled
setLog
in interface LogEnabled
logger
- not nullLogEnabled.setLog(org.slf4j.Logger)
public void configure(org.apache.commons.configuration.HierarchicalConfiguration configuration) throws org.apache.commons.configuration.ConfigurationException
Configurable
configure
in interface Configurable
org.apache.commons.configuration.ConfigurationException
Configurable.configure(org.apache.commons.configuration.HierarchicalConfiguration)
@PostConstruct public void init() throws Exception
Exception
public String[] getDNSServers()
getDNSServers
in interface DNSServiceMBean
public org.xbill.DNS.Name[] getSearchPaths()
public Collection<String> findMXRecords(String hostname) throws TemporaryResolutionException
DNSService
Return a prioritized unmodifiable list of host handling mail for the domain.
First lookup MX hosts, then MX hosts of the CNAME address, and if no server is found return the IP of the hostname
findMXRecords
in interface DNSService
hostname
- domain name to look upTemporaryResolutionException
- get thrown on temporary problemsDNSService.findMXRecords(String)
protected org.xbill.DNS.Record[] lookup(String namestr, int type, String typeDesc) throws TemporaryResolutionException
namestr
- the name of the host to be looked uptype
- the type of record desiredtypeDesc
- the description of the record type, for debugging purposeTemporaryResolutionException
protected org.xbill.DNS.Record[] lookupNoException(String namestr, int type, String typeDesc)
public InetAddress getByName(String host) throws UnknownHostException
DNSService
getByName
in interface DNSService
UnknownHostException
DNSService.getByName(String)
public InetAddress[] getAllByName(String host) throws UnknownHostException
DNSService
getAllByName
in interface DNSService
UnknownHostException
DNSService.getAllByName(String)
public Collection<String> findTXTRecords(String hostname)
DNSService
findTXTRecords
in interface DNSService
hostname
- The hostname to checkDNSService.findTXTRecords(String)
public String getHostName(InetAddress addr)
DNSService
getHostName
in interface DNSService
DNSService.getHostName(java.net.InetAddress)
public InetAddress getLocalHost() throws UnknownHostException
DNSService
getLocalHost
in interface DNSService
UnknownHostException
DNSService.getLocalHost()
public int getMaximumCacheSize()
DNSServiceMBean
getMaximumCacheSize
in interface DNSServiceMBean
DNSServiceMBean.getMaximumCacheSize()
public int getCurrentCacheSize()
DNSServiceMBean
getCurrentCacheSize
in interface DNSServiceMBean
DNSServiceMBean.getCurrentCacheSize()
public void clearCache()
DNSServiceMBean
clearCache
in interface DNSServiceMBean
DNSServiceMBean.clearCache()
Copyright © 2002-2012 The Apache Software Foundation. All Rights Reserved.