DirContextUtils Class — netty Architecture
Architecture documentation for the DirContextUtils class in DirContextUtils.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD ecf9deed_d211_8a26_74de_3e6f64680b0b["DirContextUtils"] fe7b278c_667b_385a_5c9a_a461d7643d01["DirContextUtils.java"] ecf9deed_d211_8a26_74de_3e6f64680b0b -->|defined in| fe7b278c_667b_385a_5c9a_a461d7643d01 4b05c1e6_04fc_c088_19bc_6a9eba0a94b6["DirContextUtils()"] ecf9deed_d211_8a26_74de_3e6f64680b0b -->|method| 4b05c1e6_04fc_c088_19bc_6a9eba0a94b6 e6f786c3_a102_5d9f_3a06_48f0cc85bb84["addNameServers()"] ecf9deed_d211_8a26_74de_3e6f64680b0b -->|method| e6f786c3_a102_5d9f_3a06_48f0cc85bb84
Relationship Graph
Source Code
resolver-dns/src/main/java/io/netty/resolver/dns/DirContextUtils.java lines 31–76
final class DirContextUtils {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(DirContextUtils.class);
private DirContextUtils() { }
static void addNameServers(List<InetSocketAddress> defaultNameServers, int defaultPort) {
// Using jndi-dns to obtain the default name servers.
//
// See:
// - https://docs.oracle.com/javase/8/docs/technotes/guides/jndi/jndi-dns.html
// - https://mail.openjdk.java.net/pipermail/net-dev/2017-March/010695.html
Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory");
env.put("java.naming.provider.url", "dns://");
try {
DirContext ctx = new InitialDirContext(env);
String dnsUrls = (String) ctx.getEnvironment().get("java.naming.provider.url");
// Only try if not empty as otherwise we will produce an exception
if (dnsUrls != null && !dnsUrls.isEmpty()) {
String[] servers = dnsUrls.split(" ");
for (String server : servers) {
try {
URI uri = new URI(server);
String host = uri.getHost();
if (host == null || host.isEmpty()) {
logger.debug(
"Skipping a nameserver URI as host portion could not be extracted: {}", server);
// If the host portion can not be parsed we should just skip this entry.
continue;
}
int port = uri.getPort();
defaultNameServers.add(SocketUtils.socketAddress(uri.getHost(), port == -1 ?
defaultPort : port));
} catch (URISyntaxException e) {
logger.debug("Skipping a malformed nameserver URI: {}", server, e);
}
}
}
} catch (Exception ex) {
// Will try reflection if this fails.
logger.debug("Unable to obtain nameservers via InitialDirContext", ex);
}
}
}
Source
Frequently Asked Questions
What is the DirContextUtils class?
DirContextUtils is a class in the netty codebase, defined in resolver-dns/src/main/java/io/netty/resolver/dns/DirContextUtils.java.
Where is DirContextUtils defined?
DirContextUtils is defined in resolver-dns/src/main/java/io/netty/resolver/dns/DirContextUtils.java at line 31.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free