Package org.ldaptive.dns
Class AbstractDNSResolver<T>
- java.lang.Object
-
- org.ldaptive.dns.AbstractDNSResolver<T>
-
- Type Parameters:
T- Type of record to resolve.
- All Implemented Interfaces:
DNSResolver<T>
- Direct Known Subclasses:
SRVDNSResolver
public abstract class AbstractDNSResolver<T> extends Object implements DNSResolver<T>
Base class for all DNS resolvers.
-
-
Field Summary
Fields Modifier and Type Field Description private DNSContextFactorycontextFactoryFactory to create DNS connections.protected LoggerloggerClass logger.
-
Constructor Summary
Constructors Constructor Description AbstractDNSResolver(DNSContextFactory factory)Creates a new abstract DNS resolver.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract String[]getAttributes()Get the types of records to query for, e.g.protected abstract Set<T>processRecords(Set<String> records)Process a set of DNS records.Set<T>resolve(String name)Resolve a set of DNS records of some type for the given name.private voidresolveOne(DirContext ctx, String name, String attrId, Set<String> records)Query for a single kind of DNS record.StringtoString()
-
-
-
Field Detail
-
logger
protected final Logger logger
Class logger.
-
contextFactory
private final DNSContextFactory contextFactory
Factory to create DNS connections.
-
-
Constructor Detail
-
AbstractDNSResolver
public AbstractDNSResolver(DNSContextFactory factory)
Creates a new abstract DNS resolver.- Parameters:
factory- DNS context factory
-
-
Method Detail
-
resolve
public Set<T> resolve(String name)
Description copied from interface:DNSResolverResolve a set of DNS records of some type for the given name.- Specified by:
resolvein interfaceDNSResolver<T>- Parameters:
name- Name for which to resolve DNS records.- Returns:
- Set of records of type T bound to the given name.
-
getAttributes
protected abstract String[] getAttributes()
Get the types of records to query for, e.g.{"A", "AAAA"}.- Returns:
- Array of JNDI attribute names.
-
processRecords
protected abstract Set<T> processRecords(Set<String> records)
Process a set of DNS records.- Parameters:
records- Set of raw DNS records returned from a name query.- Returns:
- Set of converted/processed records.
-
resolveOne
private void resolveOne(DirContext ctx, String name, String attrId, Set<String> records) throws NamingException
Query for a single kind of DNS record.- Parameters:
ctx- Directory context.name- Name to query for.attrId- DNS record type, e.g.A.records- Set of records to append results to.- Throws:
NamingException- on DNS lookup failure.
-
-