class DNSJavaService implements DNSService, DNSServiceMBean, Configurable {

    @Override
    public Collection<String> findMXRecords(String hostname) throws TemporaryResolutionException {
        TimeMetric timeMetric = metricFactory.timer("findMXRecords");
        List<String> servers = new ArrayList<>();
        try {
            servers = findMXRecordsRaw(hostname);
            return Collections.unmodifiableCollection(servers);
        } finally {
            // If we found no results, we'll add the original domain name if
            // it's a valid DNS entry
            if (servers.size() == 0) {
                LOGGER.info("Couldn't resolve MX records for domain {}.", hostname);
                try {
                    getByName(hostname);
                    servers.add(hostname);
                } catch (UnknownHostException uhe) {
                    // The original domain name is not a valid host,
                    // so we can't add it to the server list. In this
                    // case we return an empty list of servers
                    LOGGER.error("Couldn't resolve IP address for host {}.", hostname, uhe);
                }
            }
            timeMetric.stopAndPublish();
        }
    }

    @Inject public  DNSJavaService(MetricFactory metricFactory);

}