Class 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 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: DNSResolver
        Resolve a set of DNS records of some type for the given name.
        Specified by:
        resolve in interface DNSResolver<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.