當前位置: 首頁>>代碼示例>>Java>>正文


Java Lookup.setDefaultResolver方法代碼示例

本文整理匯總了Java中org.xbill.DNS.Lookup.setDefaultResolver方法的典型用法代碼示例。如果您正苦於以下問題:Java Lookup.setDefaultResolver方法的具體用法?Java Lookup.setDefaultResolver怎麽用?Java Lookup.setDefaultResolver使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.xbill.DNS.Lookup的用法示例。


在下文中一共展示了Lookup.setDefaultResolver方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import org.xbill.DNS.Lookup; //導入方法依賴的package包/類
private void init() {
    if (mInitialized) return; else mInitialized = true;

    try {
        // configure the resolvers, starting with the default ones (based on the current network connection)
        Resolver defaultResolver = Lookup.getDefaultResolver();
        // use Google's public DNS services
        Resolver googleFirstResolver = new SimpleResolver("8.8.8.8");
        Resolver googleSecondResolver = new SimpleResolver("8.8.4.4");
        // also try using Amazon
        Resolver amazonResolver = new SimpleResolver("205.251.198.30");
        Lookup.setDefaultResolver(new ExtendedResolver(new Resolver[]{
                googleFirstResolver, googleSecondResolver, amazonResolver, defaultResolver }));
    } catch (UnknownHostException e) {
        Log.w(TAG, "Couldn't initialize custom resolvers");
    }
}
 
開發者ID:ov3rk1ll,項目名稱:KinoCast,代碼行數:18,代碼來源:CustomDns.java

示例2: setUp

import org.xbill.DNS.Lookup; //導入方法依賴的package包/類
protected void setUp() throws Exception {
    dnsServer = new TestableDNSServer();
    DefaultConfigurationBuilder db = new DefaultConfigurationBuilder();

    db.load(new ByteArrayInputStream("<dnsserver><autodiscover>true</autodiscover><authoritative>false</authoritative></dnsserver>".getBytes()));
    dnsServer.setLog(LoggerFactory.getLogger("MockLog"));
    dnsServer.configure(db);
    dnsServer.init();

    defaultCache = Lookup.getDefaultCache(DClass.IN);
    defaultResolver = Lookup.getDefaultResolver();
    defaultSearchPaths = Lookup.getDefaultSearchPath();
    Lookup.setDefaultCache(null, DClass.IN);
    Lookup.setDefaultResolver(null);
    Lookup.setDefaultSearchPath(new Name[] {});
}
 
開發者ID:twachan,項目名稱:James,代碼行數:17,代碼來源:DNSJavaServiceTest.java

示例3: tearDown

import org.xbill.DNS.Lookup; //導入方法依賴的package包/類
protected void tearDown() throws Exception {
    dnsServer.setCache(null);
    dnsServer = null;
    Lookup.setDefaultCache(defaultCache, DClass.IN);
    Lookup.setDefaultResolver(defaultResolver);
    Lookup.setDefaultSearchPath(defaultSearchPaths);
}
 
開發者ID:twachan,項目名稱:James,代碼行數:8,代碼來源:DNSJavaServiceTest.java

示例4: init

import org.xbill.DNS.Lookup; //導入方法依賴的package包/類
@PostConstruct
public void init() throws Exception {
    logger.debug("DNSService init...");

    // If no DNS servers were configured, default to local host
    if (dnsServers.isEmpty()) {
        try {
            dnsServers.add(InetAddress.getLocalHost().getHostName());
        } catch (UnknownHostException ue) {
            dnsServers.add("127.0.0.1");
        }
    }

    // Create the extended resolver...
    final String[] serversArray = (String[]) dnsServers.toArray(new String[0]);

    if (logger.isInfoEnabled()) {
        for (int c = 0; c < serversArray.length; c++) {
            logger.info("DNS Server is: " + serversArray[c]);
        }
    }

    try {
        resolver = new ExtendedResolver(serversArray);
    } catch (UnknownHostException uhe) {
        logger.error("DNS service could not be initialized.  The DNS servers specified are not recognized hosts.", uhe);
        throw uhe;
    }

    cache = new Cache(DClass.IN);
    cache.setMaxEntries(maxCacheSize);

    if (setAsDNSJavaDefault) {
        Lookup.setDefaultResolver(resolver);
        Lookup.setDefaultCache(cache, DClass.IN);
        Lookup.setDefaultSearchPath(searchPaths);
        logger.info("Registered cache, resolver and search paths as DNSJava defaults");
    }

    // Cache the local hostname and local address. This is needed because
    // the following issues:
    // JAMES-787
    // JAMES-302
    InetAddress addr = getLocalHost();
    localCanonicalHostName = addr.getCanonicalHostName();
    localHostName = addr.getHostName();
    localAddress = addr.getHostAddress();

    logger.debug("DNSService ...init end");
}
 
開發者ID:twachan,項目名稱:James,代碼行數:51,代碼來源:DNSJavaService.java


注:本文中的org.xbill.DNS.Lookup.setDefaultResolver方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。