1 /* 2 * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package sun.net.dns; 27 28 import java.util.List; 29 import java.io.IOException; 30 31 /** 32 * The configuration of the client resolver. 33 * 34 * <p>A ResolverConfiguration is a singleton that represents the 35 * configuration of the client resolver. The ResolverConfiguration 36 * is opened by invoking the {@link #open() open} method. 37 * 38 * @since 1.4 39 */ 40 41 public abstract class ResolverConfiguration { 42 43 private static final Object lock = new Object(); 44 45 private static ResolverConfiguration provider; 46 47 protected ResolverConfiguration() { } 48 49 /** 50 * Opens the resolver configuration. 51 * 52 * @return the resolver configuration 53 */ 54 public static ResolverConfiguration open() { 55 synchronized (lock) { 56 if (provider == null) { 57 provider = new sun.net.dns.ResolverConfigurationImpl(); 58 } 59 return provider; 60 } 61 } 62 63 /** 64 * Returns a list corresponding to the domain search path. The 65 * list is ordered by the search order used for host name lookup. 66 * Each element in the list returns a {@link java.lang.String} 67 * containing a domain name or suffix. 68 * 69 * @return list of domain names 70 */ 71 public abstract List searchlist(); 72 73 /** 74 * Returns a list of name servers used for host name lookup. 75 * Each element in the list returns a {@link java.lang.String} 76 * containing the textual representation of the IP address of 77 * the name server. 78 * 79 * @return list of the name servers 80 */ 81 public abstract List nameservers(); 82 83 84 /** 85 * Options representing certain resolver variables of 86 * a {@link ResolverConfiguration}. 87 */ 88 public static abstract class Options { 89 90 /** 91 * Returns the maximum number of attempts the resolver 92 * will connect to each name server before giving up 93 * and returning an error. 94 * 95 * @return the resolver attempts value or -1 is unknown 96 */ 97 public int attempts() { 98 return -1; 99 } 100 101 /** 102 * Returns the basic retransmit timeout, in milliseconds, 103 * used by the resolver. The resolver will typically use 104 * an exponential backoff algorithm where the timeout is 105 * doubled for every retransmit attempt. The basic 106 * retransmit timeout, returned here, is the initial 107 * timeout for the exponential backoff algorithm. 108 * 109 * @return the basic retransmit timeout value or -1 110 * if unknown 111 */ 112 public int retrans() { 113 return -1; 114 } 115 } 116 117 /** 118 * Returns the {@link #Options} for the resolver. 119 * 120 * @return options for the resolver 121 */ 122 public abstract Options options(); 123 }